This class can be used for packing a series of numeric and string data into a binary stream, according to the DC specification.
More...
Classes |
| class | StackElement |
Public Member Functions |
| void | append_data (const char *buffer, size_t size) |
| | Adds the indicated bytes to the end of the data.
|
| void | begin_pack (const DCPackerInterface *root) |
| | Begins a packing session.
|
| void | begin_repack (const DCPackerInterface *root) |
| | Begins a repacking session.
|
| void | begin_unpack (const DCPackerInterface *root) |
| | Begins an unpacking session.
|
| void | clear_data () |
| | Empties the data in the pack buffer and unpack buffer.
|
| bool | end_pack () |
| | Finishes a packing session.
|
| bool | end_repack () |
| | Finishes the repacking session.
|
| bool | end_unpack () |
| | Finishes the unpacking session.
|
| const DCPackerInterface * | get_current_field () const |
| | Returns the field that will be referenced by the next call to pack_*() or unpack_*().
|
| string | get_current_field_name () const |
| | Returns the name of the current field, if it has a name, or the empty string if the field does not have a name or there is no current field.
|
| const DCPackerInterface * | get_current_parent () const |
| | Returns the field that we left in our last call to push(): the owner of the current level of fields.
|
| const char * | get_data () const |
| | Returns the beginning of the data buffer.
|
| const DCSwitchParameter * | get_last_switch () const |
| | Returns a pointer to the last DCSwitch instance that we have passed by and selected one case of during the pack/unpack process.
|
| size_t | get_length () const |
| | Returns the current length of the buffer.
|
| int | get_num_nested_fields () const |
| | Returns the number of nested fields associated with the current field, if has_nested_fields() returned true.
|
| size_t | get_num_unpacked_bytes () const |
| | Returns the number of bytes that have been unpacked so far, or after unpack_end(), the total number of bytes that were unpacked at all.
|
| DCPackType | get_pack_type () const |
| | Returns the type of value expected by the current field.
|
| string | get_string () const |
| | Returns the packed data buffer as a string.
|
| void | get_string (string &data) const |
| | Copies the packed data into the indicated string.
|
| const char * | get_unpack_data () const |
| | Returns a read pointer to the unpack data buffer.
|
| size_t | get_unpack_length () const |
| | Returns the total number of bytes in the unpack data buffer.
|
| string | get_unpack_string () const |
| | Returns the unpack data buffer, as a string.
|
| char * | get_write_pointer (size_t size) |
| | Adds the indicated number of bytes to the end of the data without initializing them, and returns a pointer to the beginning of the new data.
|
| bool | had_error () const |
| | Returns true if there has been any error (either a pack error or a range error) since the most recent call to begin().
|
| bool | had_pack_error () const |
| | Returns true if there has been an packing error since the most recent call to begin(); in particular, this may be called after end() has returned false to determine the nature of the failure.
|
| bool | had_parse_error () const |
| | Returns true if there has been an parse error since the most recent call to begin(); this can only happen if you call parse_and_pack().
|
| bool | had_range_error () const |
| | Returns true if there has been an range validation error since the most recent call to begin(); in particular, this may be called after end() has returned false to determine the nature of the failure.
|
| bool | has_nested_fields () const |
| | Returns true if the current field has any nested fields (and thus expects a push() .
|
| bool | more_nested_fields () const |
| | Returns true if there are more nested fields to pack or unpack in the current push sequence, false if it is time to call pop().
|
| void | pack_default_value () |
| | Adds the default value for the current element into the stream.
|
| void | pack_double (double value) |
| | Packs the indicated numeric or string value into the stream.
|
| void | pack_int (int value) |
| | Packs the indicated numeric or string value into the stream.
|
| void | pack_int64 (PN_int64 value) |
| | Packs the indicated numeric or string value into the stream.
|
| void | pack_literal_value (const string &value) |
| | Adds the indicated string value into the stream, representing a single pre-packed field element, or a whole group of field elements at once.
|
| void | pack_string (const string &value) |
| | Packs the indicated numeric or string value into the stream.
|
| void | pack_uint (unsigned int value) |
| | Packs the indicated numeric or string value into the stream.
|
| void | pack_uint64 (PN_uint64 value) |
| | Packs the indicated numeric or string value into the stream.
|
| bool | parse_and_pack (const string &formatted_object) |
| | Parses an object's value according to the DC file syntax (e.g.
|
| bool | parse_and_pack (istream &in) |
| | Parses an object's value according to the DC file syntax (e.g.
|
| void | pop () |
| | Marks the end of a nested series of fields.
|
| void | push () |
| | Marks the beginning of a nested series of fields.
|
| void | raw_pack_float64 (double value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_int16 (int value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_int32 (int value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_int64 (PN_int64 value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_int8 (int value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_string (const string &value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_uint16 (unsigned int value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_uint32 (unsigned int value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_uint64 (PN_uint64 value) |
| | Packs the data into the buffer between packing sessions.
|
| void | raw_pack_uint8 (unsigned int value) |
| | Packs the data into the buffer between packing sessions.
|
| double | raw_unpack_float64 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_float64 (double &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| int | raw_unpack_int16 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_int16 (int &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| int | raw_unpack_int32 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_int32 (int &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| PN_int64 | raw_unpack_int64 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_int64 (PN_int64 &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_int8 (int &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| int | raw_unpack_int8 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| string | raw_unpack_string () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_string (string &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| unsigned int | raw_unpack_uint16 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_uint16 (unsigned int &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| unsigned int | raw_unpack_uint32 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_uint32 (unsigned int &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_uint64 (PN_uint64 &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| PN_uint64 | raw_unpack_uint64 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| unsigned int | raw_unpack_uint8 () |
| | Unpacks the data from the buffer between unpacking sessions.
|
| void | raw_unpack_uint8 (unsigned int &value) |
| | Unpacks the data from the buffer between unpacking sessions.
|
| bool | seek (const string &field_name) |
| | Sets the current unpack (or repack) position to the named field.
|
| bool | seek (int seek_index) |
| | Seeks to the field indentified by seek_index, which was returned by an earlier call to DCField::find_seek_index() to get the index of some nested field.
|
| void | set_unpack_data (const char *unpack_data, size_t unpack_length, bool owns_unpack_data) |
| | Sets up the unpack_data pointer.
|
| void | set_unpack_data (const string &data) |
| | Sets up the unpack_data pointer.
|
| char * | take_data () |
| | Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the caller.
|
| void | unpack_and_format (ostream &out, bool show_field_names=true) |
| | Unpacks an object and formats its value into a syntax suitable for parsing in the dc file (e.g.
|
| string | unpack_and_format (bool show_field_names=true) |
| | Unpacks an object and formats its value into a syntax suitable for parsing in the dc file (e.g.
|
| double | unpack_double () |
| | Unpacks the current numeric or string value from the stream.
|
| void | unpack_double (double &value) |
| | Unpacks the current numeric or string value from the stream.
|
| int | unpack_int () |
| | Unpacks the current numeric or string value from the stream.
|
| void | unpack_int (int &value) |
| | Unpacks the current numeric or string value from the stream.
|
| PN_int64 | unpack_int64 () |
| | Unpacks the current numeric or string value from the stream.
|
| void | unpack_int64 (PN_int64 &value) |
| | Unpacks the current numeric or string value from the stream.
|
| string | unpack_literal_value () |
| | Returns the literal string that represents the packed value of the current field, and advances the field pointer.
|
| void | unpack_literal_value (string &value) |
| | Returns the literal string that represents the packed value of the current field, and advances the field pointer.
|
| void | unpack_skip () |
| | Skips the current field without unpacking it and advances to the next field.
|
| void | unpack_string (string &value) |
| | Unpacks the current numeric or string value from the stream.
|
| string | unpack_string () |
| | Unpacks the current numeric or string value from the stream.
|
| void | unpack_uint (unsigned int &value) |
| | Unpacks the current numeric or string value from the stream.
|
| unsigned int | unpack_uint () |
| | Unpacks the current numeric or string value from the stream.
|
| void | unpack_uint64 (PN_uint64 &value) |
| | Unpacks the current numeric or string value from the stream.
|
| PN_uint64 | unpack_uint64 () |
| | Unpacks the current numeric or string value from the stream.
|
| void | unpack_validate () |
| | Internally unpacks the current numeric or string value and validates it against the type range limits, but does not return the value.
|
Static Public Member Functions |
| static void | enquote_string (ostream &out, char quote_mark, const string &str) |
| | Outputs the indicated string within quotation marks.
|
| static int | get_num_stack_elements_ever_allocated () |
| | Returns the number of DCPacker::StackElement pointers ever simultaneously allocated; these are now either in active use or have been recycled into the deleted DCPacker::StackElement pool to be used again.
|
| static void | output_hex_string (ostream &out, const string &str) |
| | Outputs the indicated string as a hex constant.
|
This class can be used for packing a series of numeric and string data into a binary stream, according to the DC specification.
See also direct/src/doc/dcPacker.txt for a more complete description and examples of using this class.
Definition at line 38 of file dcPacker.h.