| 1 |
/* |
| 2 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
* or more contributor license agreements. See the NOTICE file |
| 4 |
* distributed with this work for additional information |
| 5 |
* regarding copyright ownership. The ASF licenses this file |
| 6 |
* to you under the Apache License, Version 2.0 (the |
| 7 |
* "License"); you may not use this file except in compliance |
| 8 |
* with the License. You may obtain a copy of the License at |
| 9 |
* |
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
* |
| 12 |
* Unless required by applicable law or agreed to in writing, |
| 13 |
* software distributed under the License is distributed on an |
| 14 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
* KIND, either express or implied. See the License for the |
| 16 |
* specific language governing permissions and limitations |
| 17 |
* under the License. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "proton/internal/data.hpp" |
| 21 |
|
| 22 |
#include "proton/binary.hpp" |
| 23 |
#include "proton/codec/encoder.hpp" |
| 24 |
#include "proton/decimal.hpp" |
| 25 |
#include "proton/message_id.hpp" |
| 26 |
#include "proton/symbol.hpp" |
| 27 |
#include "proton/timestamp.hpp" |
| 28 |
#include "proton/value.hpp" |
| 29 |
|
| 30 |
#include <proton/codec.h> |
| 31 |
|
| 32 |
#include <ostream> |
| 33 |
|
| 34 |
#include "proton_bits.hpp" |
| 35 |
|
| 36 |
namespace proton { |
| 37 |
namespace internal { |
| 38 |
|
| 39 |
data data::create() { return internal::take_ownership(pn_data(0)).get(); } |
| 40 |
|
| 41 |
void data::copy(const data& x) { ::pn_data_copy(pn_object(), x.pn_object()); } |
| 42 |
|
| 43 |
void data::clear() { ::pn_data_clear(pn_object()); } |
| 44 |
|
| 45 |
void data::rewind() { ::pn_data_rewind(pn_object()); } |
| 46 |
|
| 47 |
bool data::empty() const { return ::pn_data_size(pn_object()) == 0; } |
| 48 |
|
| 49 |
const void* data::point() const { return pn_data_point(pn_object()); } |
| 50 |
|
| 51 |
void data::restore(const void* h) { pn_data_restore(pn_object(), pn_handle_t(h)); } |
| 52 |
|
| 53 |
void data::narrow() { pn_data_narrow(pn_object()); } |
| 54 |
|
| 55 |
void data::widen() { pn_data_widen(pn_object()); } |
| 56 |
|
| 57 |
int data::append(data src) { return pn_data_append(pn_object(), src.pn_object());} |
| 58 |
|
| 59 |
int data::appendn(data src, int limit) { return pn_data_appendn(pn_object(), src.pn_object(), limit);} |
| 60 |
|
| 61 |
bool data::next() { return pn_data_next(pn_object()); } |
| 62 |
|
| 63 |
std::ostream& operator<<(std::ostream& o, const data& d) { |
| 64 |
state_guard sg(const_cast<data&>(d)); |
| 65 |
const_cast<data&>(d).rewind(); |
| 66 |
return o << inspectable(d.pn_object()); |
| 67 |
} |
| 68 |
|
| 69 |
} // internal |
| 70 |
} // proton |