 |
Kea
1.5.0
|
Go to the documentation of this file.
7 #ifndef OPAQUE_DATA_TUPLE_H
8 #define OPAQUE_DATA_TUPLE_H
81 template<
typename InputIterator>
84 : length_field_type_(length_field_type) {
101 template<
typename InputIterator>
102 void append(InputIterator data,
const size_t len) {
103 data_.insert(data_.end(), data, data + len);
112 void append(
const std::string& text);
126 template<
typename InputIterator>
127 void assign(InputIterator data,
const size_t len) {
128 data_.assign(data, data + len);
137 void assign(
const std::string& text);
145 bool equals(
const std::string& other)
const;
149 return (length_field_type_);
154 return (data_.size());
212 template<
typename InputIterator>
213 void unpack(InputIterator begin, InputIterator end) {
218 "unable to parse the opaque data tuple, the buffer"
219 " length is " << std::distance(begin, end)
229 if (std::distance(begin, end) < len) {
231 "unable to parse the opaque data tuple, the buffer"
232 " length is " << std::distance(begin, end)
233 <<
", but the length of the tuple in the length field"
258 bool operator==(
const std::string& other)
const;
OpaqueDataTuple(LengthFieldType length_field_type, InputIterator begin, InputIterator end)
Constructor.
size_t getLength() const
Returns the length of the data in the tuple.
std::string getText() const
Return the tuple data in the textual format.
bool equals(const std::string &other) const
Checks if the data carried in the tuple match the string.
void append(InputIterator data, const size_t len)
Appends data to the tuple.
bool operator!=(const std::string &other)
Inequality operator.
LengthFieldType
Size of the length field in the tuple.
OpaqueDataTuple & operator=(const std::string &other)
Assignment operator.
LengthFieldType getLengthFieldType() const
Returns tuple length data field type.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void assign(InputIterator data, const size_t len)
Assigns data to the tuple.
Exception to be thrown when the operation on OpaqueDataTuple object results in an error.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
uint16_t readUint16(const void *buffer, size_t length)
Read Unsigned 16-Bit Integer from Buffer.
OpaqueDataTupleError(const char *file, size_t line, const char *what)
size_t getTotalLength() const
Returns a total size of the tuple, including length field.
bool operator==(const std::string &other) const
Equality operator.
int getDataFieldSize() const
Returns the size of the tuple length field.
boost::shared_ptr< OpaqueDataTuple > OpaqueDataTuplePtr
Pointer to the OpaqueDataTuple object.
Represents a single instance of the opaque data preceded by length.
void pack(isc::util::OutputBuffer &buf) const
Renders the tuple to a buffer in the wire format.
std::vector< uint8_t > Buffer
Defines a type of the data buffer used to hold the opaque data.
std::istream & operator>>(std::istream &is, OpaqueDataTuple &tuple)
Inserts data carried in the stream into the tuple.
std::ostream & operator<<(std::ostream &os, const OpaqueDataTuple &tuple)
Inserts the OpaqueDataTuple as a string into stream.
OpaqueDataTuple(LengthFieldType length_field_type)
Default constructor.
const Buffer & getData() const
Returns a reference to the buffer holding tuple data.
void unpack(InputIterator begin, InputIterator end)
Parses wire data and creates a tuple from it.
void clear()
Removes the contents of the tuple.