27 #ifndef HYPERTABLE_BYTESTRING_H
28 #define HYPERTABLE_BYTESTRING_H
32 #include <boost/shared_array.hpp>
33 #include <boost/shared_ptr.hpp>
65 const uint8_t *tmp_ptr =
ptr;
67 return (tmp_ptr -
ptr) + len;
72 uint8_t *rptr = (uint8_t *)
ptr;
93 size_t write(uint8_t *dst)
const {
98 memcpy(dst,
ptr, len);
107 const uint8_t *rptr =
ptr;
109 return (
const char *)rptr;
116 operator bool ()
const {
131 uint32_t value_len) {
132 dst_buf.
ensure(7 + value_len);
135 memcpy(dst_buf.
ptr, value, value_len);
136 dst_buf.
ptr += value_len;
155 #endif // HYPERTABLE_BYTESTRING_H
Po::typed_value< String > * str(String *v=0)
uint8_t * ptr
Pointer to the end of the used part of the buffer.
size_t write(uint8_t *dst) const
Writes the data of this ByteString into a pointer.
A dynamic, resizable and reference counted memory buffer.
void append_as_byte_string(DynamicBuffer &dst_buf, const void *value, uint32_t value_len)
Serializes and appends a byte array to a DynamicBuffer object.
A class managing one or more serializable ByteStrings.
const char * str() const
Returns a pointer to the String's deserialized data.
ByteString(const uint8_t *buf)
Overloaded constructor: takes ownership of a pointer.
A dynamic, resizable memory buffer.
ByteString()
Default constructor: starts with an empty string.
Functions to serialize/deserialize primitives to/from a memory buffer.
size_t length() const
Retrieves the length of the serialized string.
const uint8_t * ptr
The pointer to the serialized data.
void encode_vi32(uint8_t **bufp, uint32_t val)
Encode a integer (up to 32-bit) in variable length encoding.
size_t decode_length(const uint8_t **dptr) const
Retrieves the decoded length and returns a pointer to the string.
void ensure(size_t len)
Ensure space for additional data Will grow the space to 1.5 of the needed space with existing data un...
uint32_t decode_vi32(const uint8_t **bufp, size_t *remainp)
Decode a variable length encoded integer up to 32-bit.
uint8_t * next()
Retrieves the next serialized String in the buffer.