Qpid Proton C++ API 0.40.0
 
Loading...
Searching...
No Matches
data.hpp
1#ifndef PROTON_INTERNAL_DATA_HPP
2#define PROTON_INTERNAL_DATA_HPP
3
4/*
5 *
6 * Licensed to the Apache Software Foundation (ASF) under one
7 * or more contributor license agreements. See the NOTICE file
8 * distributed with this work for additional information
9 * regarding copyright ownership. The ASF licenses this file
10 * to you under the Apache License, Version 2.0 (the
11 * "License"); you may not use this file except in compliance
12 * with the License. You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an
18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 * KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations
21 * under the License.
22 *
23 */
24
25#include "../internal/object.hpp"
26#include "../types_fwd.hpp"
27
28struct pn_data_t;
29
30namespace proton {
31
32class value;
33
34namespace internal {
35
38class data : public object<pn_data_t> {
40 data(pn_data_t* d) : internal::object<pn_data_t>(d) {}
41
42 public:
44 data() : internal::object<pn_data_t>(0) {}
45
47 PN_CPP_EXTERN static data create();
48
50 PN_CPP_EXTERN void copy(const data&);
51
53 PN_CPP_EXTERN void clear();
54
56 PN_CPP_EXTERN void rewind();
57
59 PN_CPP_EXTERN bool empty() const;
60
62 PN_CPP_EXTERN int append(data src);
63
65 PN_CPP_EXTERN int appendn(data src, int limit);
66
67 PN_CPP_EXTERN bool next();
68 PN_CPP_EXTERN const void* point() const;
69 PN_CPP_EXTERN void restore(const void* h);
70
71 protected:
72 void narrow();
73 void widen();
74
75 friend class internal::factory<data>;
76 friend struct state_guard;
77 friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const data&);
78};
80
85struct state_guard {
87 data& data_;
88 const void* point_;
89 bool cancel_;
91
93 state_guard(data& d) : data_(d), point_(data_.point()), cancel_(false) {}
95
96 ~state_guard() { if (!cancel_) data_.restore(point_); }
97
99 void cancel() { cancel_ = true; }
100};
101
102} // internal
103} // proton
104
105#endif // PROTON_INTERNAL_DATA_HPP
The main Proton namespace.
Definition annotation_key.hpp:33
std::ostream & operator<<(std::ostream &, const binary &)
Print a binary value.