data.hpp
#ifndef PROTON_INTERNAL_DATA_HPP
#define PROTON_INTERNAL_DATA_HPP
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
#include "../internal/object.hpp"
#include "../types_fwd.hpp"
struct pn_data_t;
namespace proton {
class value;
namespace internal {
class data : public object<pn_data_t> {
data(pn_data_t* d) : internal::object<pn_data_t>(d) {}
public:
data() : internal::object<pn_data_t>(0) {}
PN_CPP_EXTERN static data create();
PN_CPP_EXTERN void copy(const data&);
PN_CPP_EXTERN void clear();
PN_CPP_EXTERN void rewind();
PN_CPP_EXTERN bool empty() const;
PN_CPP_EXTERN int append(data src);
PN_CPP_EXTERN int appendn(data src, int limit);
PN_CPP_EXTERN bool next();
PN_CPP_EXTERN void* point() const;
PN_CPP_EXTERN void restore(void* h);
protected:
void narrow();
void widen();
friend class internal::factory<data>;
friend struct state_guard;
friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const data&);
};
struct state_guard {
data& data_;
void* point_;
bool cancel_;
state_guard(data& d) : data_(d), point_(data_.point()), cancel_(false) {}
~state_guard() { if (!cancel_) data_.restore(point_); }
void cancel() { cancel_ = true; }
};
} // internal
} // proton
#endif // PROTON_INTERNAL_DATA_HPP
proton::operator<<
std::ostream & operator<<(std::ostream &, const binary &)
Print a binary value.
proton
Type traits for mapping between AMQP and C++ types.
Definition: annotation_key.hpp:28