Panda3D
|
This class can be used for packing a series of numeric and string data into a binary stream, according to the DC specification. More...
#include "dcPacker.h"
Public Member Functions | |
void | append_data (const unsigned char *buffer, size_t size) |
Adds the indicated bytes to the end of the data. More... | |
void | begin_pack (const DCPackerInterface *root) |
Begins a packing session. More... | |
void | begin_repack (const DCPackerInterface *root) |
Begins a repacking session. More... | |
void | begin_unpack (const DCPackerInterface *root) |
Begins an unpacking session. More... | |
void | clear_data () |
Empties the data in the pack buffer and unpack buffer. More... | |
bool | end_pack () |
Finishes a packing session. More... | |
bool | end_repack () |
Finishes the repacking session. More... | |
bool | end_unpack () |
Finishes the unpacking session. More... | |
std::vector< unsigned char > | get_bytes () const |
Returns the packed data buffer as a bytes object. More... | |
const DCPackerInterface * | get_current_field () const |
Returns the field that will be referenced by the next call to pack_*() or unpack_*(). More... | |
std::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. More... | |
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. More... | |
const char * | get_data () const |
Returns the beginning of the data buffer. More... | |
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. More... | |
size_t | get_length () const |
Returns the current length of the buffer. More... | |
int | get_num_nested_fields () const |
Returns the number of nested fields associated with the current field, if has_nested_fields() returned true. More... | |
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. More... | |
DCPackType | get_pack_type () const |
Returns the type of value expected by the current field. More... | |
std::string | get_string () const |
Returns the packed data buffer as a string. More... | |
void | get_string (std::string &data) const |
Copies the packed data into the indicated string. More... | |
const char * | get_unpack_data () const |
Returns a read pointer to the unpack data buffer. More... | |
size_t | get_unpack_length () const |
Returns the total number of bytes in the unpack data buffer. More... | |
std::string | get_unpack_string () const |
Returns the unpack data buffer, as a string. More... | |
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. More... | |
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(). More... | |
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. More... | |
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(). More... | |
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. More... | |
bool | has_nested_fields () const |
Returns true if the current field has any nested fields (and thus expects a push() . More... | |
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(). More... | |
void | pack_blob (const std::vector< unsigned char > &value) |
Packs the indicated numeric or string value into the stream. More... | |
void | pack_default_value () |
Adds the default value for the current element into the stream. More... | |
void | pack_double (double value) |
Packs the indicated numeric or string value into the stream. More... | |
void | pack_int (int value) |
Packs the indicated numeric or string value into the stream. More... | |
void | pack_int64 (int64_t value) |
Packs the indicated numeric or string value into the stream. More... | |
void | pack_literal_value (const std::vector< unsigned char > &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. More... | |
void | pack_string (const std::string &value) |
Packs the indicated numeric or string value into the stream. More... | |
void | pack_uint (unsigned int value) |
Packs the indicated numeric or string value into the stream. More... | |
void | pack_uint64 (uint64_t value) |
Packs the indicated numeric or string value into the stream. More... | |
bool | parse_and_pack (const std::string &formatted_object) |
Parses an object's value according to the DC file syntax (e.g. More... | |
bool | parse_and_pack (std::istream &in) |
Parses an object's value according to the DC file syntax (e.g. More... | |
void | pop () |
Marks the end of a nested series of fields. More... | |
void | push () |
Marks the beginning of a nested series of fields. More... | |
void | raw_pack_blob (const std::vector< unsigned char > &value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_float64 (double value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_int16 (int value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_int32 (int value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_int64 (int64_t value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_int8 (int value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_string (const std::string &value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_uint16 (unsigned int value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_uint32 (unsigned int value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_uint64 (uint64_t value) |
Packs the data into the buffer between packing sessions. More... | |
void | raw_pack_uint8 (unsigned int value) |
Packs the data into the buffer between packing sessions. More... | |
std::vector< unsigned char > | raw_unpack_blob () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_blob (std::vector< unsigned char > &value) |
double | raw_unpack_float64 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_float64 (double &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
int | raw_unpack_int16 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_int16 (int &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
int | raw_unpack_int32 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_int32 (int &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
int64_t | raw_unpack_int64 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_int64 (int64_t &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
int | raw_unpack_int8 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_int8 (int &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
std::string | raw_unpack_string () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_string (std::string &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
unsigned int | raw_unpack_uint16 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_uint16 (unsigned int &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
unsigned int | raw_unpack_uint32 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_uint32 (unsigned int &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
uint64_t | raw_unpack_uint64 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_uint64 (uint64_t &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
unsigned int | raw_unpack_uint8 () |
Unpacks the data from the buffer between unpacking sessions. More... | |
void | raw_unpack_uint8 (unsigned int &value) |
Unpacks the data from the buffer between unpacking sessions. More... | |
bool | seek (const std::string &field_name) |
Sets the current unpack (or repack) position to the named field. More... | |
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. More... | |
void | set_unpack_data (const char *unpack_data, size_t unpack_length, bool owns_unpack_data) |
Sets up the unpack_data pointer. More... | |
void | set_unpack_data (const std::vector< unsigned char > &data) |
Sets up the unpack_data pointer. More... | |
char * | take_data () |
Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the caller. More... | |
std::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. More... | |
void | unpack_and_format (std::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. More... | |
std::vector< unsigned char > | unpack_blob () |
Unpacks the current binary data value from the stream. More... | |
void | unpack_blob (std::vector< unsigned char > &value) |
double | unpack_double () |
Unpacks the current numeric or string value from the stream. More... | |
void | unpack_double (double &value) |
Unpacks the current numeric or string value from the stream. More... | |
int | unpack_int () |
Unpacks the current numeric or string value from the stream. More... | |
void | unpack_int (int &value) |
Unpacks the current numeric or string value from the stream. More... | |
int64_t | unpack_int64 () |
Unpacks the current numeric or string value from the stream. More... | |
void | unpack_int64 (int64_t &value) |
Unpacks the current numeric or string value from the stream. More... | |
std::vector< unsigned char > | unpack_literal_value () |
Returns the literal string that represents the packed value of the current field, and advances the field pointer. More... | |
void | unpack_literal_value (std::vector< unsigned char > &value) |
void | unpack_skip () |
Skips the current field without unpacking it and advances to the next field. More... | |
std::string | unpack_string () |
Unpacks the current numeric or string value from the stream. More... | |
void | unpack_string (std::string &value) |
Unpacks the current numeric or string value from the stream. More... | |
unsigned int | unpack_uint () |
Unpacks the current numeric or string value from the stream. More... | |
void | unpack_uint (unsigned int &value) |
Unpacks the current numeric or string value from the stream. More... | |
uint64_t | unpack_uint64 () |
Unpacks the current numeric or string value from the stream. More... | |
void | unpack_uint64 (uint64_t &value) |
Unpacks the current numeric or string value from the stream. More... | |
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. More... | |
Static Public Member Functions | |
static void | enquote_string (std::ostream &out, char quote_mark, const std::string &str) |
Outputs the indicated string within quotation marks. More... | |
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. More... | |
static void | output_hex_string (std::ostream &out, const std::vector< unsigned char > &str) |
Outputs the indicated string as a hex constant. More... | |
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 34 of file dcPacker.h.
|
inline |
Adds the indicated bytes to the end of the data.
This may only be called between packing sessions.
Definition at line 663 of file dcPacker.I.
void DCPacker::begin_pack | ( | const DCPackerInterface * | root | ) |
Begins a packing session.
The parameter is the DC object that describes the packing format; it may be a DCParameter or DCField.
Unless you call clear_data() between sessions, multiple packing sessions will be concatenated together into the same buffer. If you wish to add bytes to the buffer between packing sessions, use append_data() or get_write_pointer().
Definition at line 72 of file dcPacker.cxx.
Referenced by DCArrayParameter::pack_default_value(), DCSimpleParameter::pack_default_value(), and DCSwitch::pack_default_value().
void DCPacker::begin_repack | ( | const DCPackerInterface * | root | ) |
Begins a repacking session.
You must have previously called set_unpack_data() to specify a buffer to unpack.
Unlike begin_pack() or begin_unpack() you may not concatenate the results of multiple begin_repack() sessions in one buffer.
Also, unlike in packing or unpacking modes, you may not walk through the fields from beginning to end, or even pack two consecutive fields at once. Instead, you must call seek() for each field you wish to modify and pack only that one field; then call seek() again to modify another field.
Definition at line 212 of file dcPacker.cxx.
void DCPacker::begin_unpack | ( | const DCPackerInterface * | root | ) |
Begins an unpacking session.
You must have previously called set_unpack_data() to specify a buffer to unpack.
If there was data left in the buffer after a previous begin_unpack() .. end_unpack() session, the new session will resume from the current point. This method may be used, therefore, to unpack a sequence of objects from the same buffer.
Definition at line 152 of file dcPacker.cxx.
|
inline |
Empties the data in the pack buffer and unpack buffer.
This should be called between calls to begin_pack(), unless you want to concatenate all of the pack results together.
Definition at line 19 of file dcPacker.I.
bool DCPacker::end_pack | ( | ) |
Finishes a packing session.
The return value is true on success, or false if there has been some error during packing.
Definition at line 97 of file dcPacker.cxx.
Referenced by DCSwitch::pack_default_value().
bool DCPacker::end_repack | ( | ) |
Finishes the repacking session.
The return value is true on success, or false if there has been some error during repacking (or if all fields have not been repacked).
Definition at line 247 of file dcPacker.cxx.
bool DCPacker::end_unpack | ( | ) |
Finishes the unpacking session.
The return value is true on success, or false if there has been some error during unpacking (or if all fields have not been unpacked).
Definition at line 178 of file dcPacker.cxx.
|
static |
Outputs the indicated string within quotation marks.
Definition at line 1096 of file dcPacker.cxx.
|
inline |
Returns the packed data buffer as a bytes object.
Also see get_data().
Definition at line 598 of file dcPacker.I.
|
inline |
Returns the field that will be referenced by the next call to pack_*() or unpack_*().
This will be NULL if we have unpacked (or packed) all fields, or if it is time to call pop().
Definition at line 86 of file dcPacker.I.
|
inline |
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.
Definition at line 126 of file dcPacker.I.
Referenced by unpack_and_format().
|
inline |
Returns the field that we left in our last call to push(): the owner of the current level of fields.
This may be NULL at the beginning of the pack operation.
Definition at line 76 of file dcPacker.I.
|
inline |
Returns the beginning of the data buffer.
The buffer is not null- terminated, but see also get_string().
This may be used in conjunction with get_length() to copy all of the bytes out of the buffer. Also see take_data() to get the packed data without a copy operation.
Definition at line 640 of file dcPacker.I.
|
inline |
Returns a pointer to the last DCSwitch instance that we have passed by and selected one case of during the pack/unpack process.
Each time we encounter a new DCSwitch and select a case, this will change state.
This may be used to detect when a DCSwitch has been selected. At the moment this changes state, get_current_parent() will contain the particular SwitchCase that was selected by the switch.
Definition at line 100 of file dcPacker.I.
|
inline |
Returns the current length of the buffer.
This is the number of useful bytes stored in the buffer, not the amount of memory it takes up.
Definition at line 582 of file dcPacker.I.
|
inline |
Returns the number of nested fields associated with the current field, if has_nested_fields() returned true.
The return value may be -1 to indicate that a variable number of nested fields are accepted by this field type (e.g. a variable-length array).
Note that this method is unreliable to determine how many fields you must traverse before you can call pop(), since particularly in the presence of a DCSwitch, it may change during traversal. Use more_nested_fields() instead.
Definition at line 57 of file dcPacker.I.
|
inlinestatic |
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.
Definition at line 695 of file dcPacker.I.
|
inline |
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.
This can be used to validate that all of the bytes in the buffer were actually unpacked (which is not otherwise considered an error).
Definition at line 573 of file dcPacker.I.
|
inline |
Returns the type of value expected by the current field.
See the enumerated type definition at the top of DCPackerInterface.h. If this returns one of PT_double, PT_int, PT_int64, or PT_string, then you should call the corresponding pack_double(), pack_int() function (or unpack_double(), unpack_int(), etc.) to transfer data. Otherwise, you should call push() and begin packing or unpacking the nested fields.
Definition at line 113 of file dcPacker.I.
Referenced by unpack_and_format().
|
inline |
Returns the packed data buffer as a string.
Also see get_data().
Definition at line 590 of file dcPacker.I.
|
inline |
Copies the packed data into the indicated string.
Also see get_data().
Definition at line 627 of file dcPacker.I.
|
inline |
Returns a read pointer to the unpack data buffer.
This is the buffer used when unpacking; it is separate from the pack data returned by get_data(), which is filled during packing.
Definition at line 685 of file dcPacker.I.
|
inline |
Returns the total number of bytes in the unpack data buffer.
This is the buffer used when unpacking; it is separate from the pack data returned by get_length(), which is filled during packing.
Definition at line 609 of file dcPacker.I.
|
inline |
Returns the unpack data buffer, as a string.
This is the buffer used when unpacking; it is separate from the pack data returned by get_string(), which is filled during packing. Also see get_unpack_data().
Definition at line 619 of file dcPacker.I.
|
inline |
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.
This may only be called between packing sessions.
Definition at line 674 of file dcPacker.I.
|
inline |
Returns true if there has been any error (either a pack error or a range error) since the most recent call to begin().
If this returns true, then the matching call to end() will indicate an error (false).
Definition at line 562 of file dcPacker.I.
|
inline |
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.
A return value of true indicates there was a push/pop mismatch, or the push/pop structure did not match the data structure, or there were the wrong number of elements in a nested push/pop structure, or on unpack that the data stream was truncated.
Definition at line 538 of file dcPacker.I.
|
inline |
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().
Definition at line 523 of file dcPacker.I.
|
inline |
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.
A return value of true indicates a value that was packed or unpacked did not fit within the specified legal range for a parameter, or within the limits of the field size.
Definition at line 552 of file dcPacker.I.
|
inline |
Returns true if the current field has any nested fields (and thus expects a push() .
. pop() interface), or false otherwise. If this returns true, get_num_nested_fields() may be called to determine how many nested fields are expected.
Definition at line 36 of file dcPacker.I.
Referenced by push().
|
inline |
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().
Definition at line 66 of file dcPacker.I.
|
static |
Outputs the indicated string as a hex constant.
Definition at line 1120 of file dcPacker.cxx.
|
inline |
Packs the indicated numeric or string value into the stream.
Definition at line 222 of file dcPacker.I.
void DCPacker::pack_default_value | ( | ) |
Adds the default value for the current element into the stream.
If no default has been set for the current element, creates a sensible default.
Definition at line 551 of file dcPacker.cxx.
Referenced by DCSwitch::pack_default_value().
|
inline |
Packs the indicated numeric or string value into the stream.
Definition at line 138 of file dcPacker.I.
|
inline |
Packs the indicated numeric or string value into the stream.
Definition at line 152 of file dcPacker.I.
|
inline |
Packs the indicated numeric or string value into the stream.
Definition at line 180 of file dcPacker.I.
|
inline |
Adds the indicated string value into the stream, representing a single pre- packed field element, or a whole group of field elements at once.
Definition at line 237 of file dcPacker.I.
Referenced by DCSwitch::pack_default_value().
|
inline |
Packs the indicated numeric or string value into the stream.
Definition at line 208 of file dcPacker.I.
|
inline |
Packs the indicated numeric or string value into the stream.
Definition at line 166 of file dcPacker.I.
|
inline |
Packs the indicated numeric or string value into the stream.
Definition at line 194 of file dcPacker.I.
bool DCPacker::parse_and_pack | ( | const std::string & | formatted_object | ) |
Parses an object's value according to the DC file syntax (e.g.
as a default value string) and packs it. Returns true on success, false on a parse error.
Definition at line 959 of file dcPacker.cxx.
bool DCPacker::parse_and_pack | ( | std::istream & | in | ) |
Parses an object's value according to the DC file syntax (e.g.
as a default value string) and packs it. Returns true on success, false on a parse error.
Definition at line 970 of file dcPacker.cxx.
void DCPacker::pop | ( | ) |
Marks the end of a nested series of fields.
This must be called to match a previous push() only after all the expected number of nested fields have been packed. It is an error to call it too early, or too late.
Definition at line 494 of file dcPacker.cxx.
References DCPackData::get_length(), DCPackerInterface::get_num_length_bytes(), DCPackerInterface::get_num_nested_fields(), DCPackData::get_rewrite_pointer(), DCPackerInterface::validate_num_nested_fields(), and DCPackerInterface::validate_uint_limits().
void DCPacker::push | ( | ) |
Marks the beginning of a nested series of fields.
This must be called before filling the elements of an array or the individual fields in a structure field. It must also be balanced by a matching pop().
It is necessary to use push() / pop() only if has_nested_fields() returns true.
Definition at line 410 of file dcPacker.cxx.
References DCPackData::append_junk(), DCPackerInterface::calc_num_nested_fields(), DCPackData::get_length(), DCPackerInterface::get_nested_field(), DCPackerInterface::get_num_length_bytes(), DCPackerInterface::get_num_nested_fields(), and has_nested_fields().
Referenced by DCArrayParameter::pack_default_value(), and DCSimpleParameter::pack_default_value().
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 794 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 775 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 712 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 721 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 730 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 703 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 784 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 748 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 757 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 766 of file dcPacker.I.
|
inline |
Packs the data into the buffer between packing sessions.
Definition at line 739 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 946 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 926 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 1026 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 814 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 858 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 824 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 872 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 834 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 956 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 804 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 844 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 936 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 1040 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 896 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 984 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 906 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 998 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 916 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 1012 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 886 of file dcPacker.I.
|
inline |
Unpacks the data from the buffer between unpacking sessions.
Definition at line 970 of file dcPacker.I.
bool DCPacker::seek | ( | const std::string & | field_name | ) |
Sets the current unpack (or repack) position to the named field.
In unpack mode, the next call to unpack_*() or push() will begin to read the named field. In repack mode, the next call to pack_*() or push() will modify the named field.
Returns true if successful, false if the field is not known (or if the packer is in an invalid mode).
Definition at line 269 of file dcPacker.cxx.
References DCPackerInterface::get_catalog(), and DCPackerCatalog::get_live_catalog().
bool DCPacker::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.
Also see the version of seek() that accepts a field name.
Returns true if successful, false if the field is not known (or if the packer is in an invalid mode).
Definition at line 299 of file dcPacker.cxx.
References DCPackerInterface::get_catalog(), and DCPackerCatalog::get_live_catalog().
void DCPacker::set_unpack_data | ( | const char * | unpack_data, |
size_t | unpack_length, | ||
bool | owns_unpack_data | ||
) |
Sets up the unpack_data pointer.
You may call this before calling the version of begin_unpack() that takes only one parameter.
Definition at line 129 of file dcPacker.cxx.
void DCPacker::set_unpack_data | ( | const std::vector< unsigned char > & | data | ) |
Sets up the unpack_data pointer.
You may call this before calling the version of begin_unpack() that takes only one parameter.
Definition at line 116 of file dcPacker.cxx.
|
inline |
Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the caller.
The caller is now responsible for ultimately freeing the returned pointer with delete[], if it is non-NULL. This may (or may not) return NULL if the buffer is empty.
This also empties the DCPackData structure, and sets its length to zero (so you should call get_length() before calling this method).
Definition at line 654 of file dcPacker.I.
string DCPacker::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.
as a default value), or as an input to parse_object.
Definition at line 988 of file dcPacker.cxx.
void DCPacker::unpack_and_format | ( | std::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.
as a default value), or as an input to parse_object.
Definition at line 999 of file dcPacker.cxx.
References get_current_field_name(), and get_pack_type().
|
inline |
Unpacks the current binary data value from the stream.
Definition at line 365 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 251 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 397 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 270 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 413 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 308 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 445 of file dcPacker.I.
|
inline |
Returns the literal string that represents the packed value of the current field, and advances the field pointer.
Definition at line 385 of file dcPacker.I.
void DCPacker::unpack_skip | ( | ) |
Skips the current field without unpacking it and advances to the next field.
If the current field contains nested fields, skips all of them.
Definition at line 603 of file dcPacker.cxx.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 346 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 477 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 289 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 429 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 327 of file dcPacker.I.
|
inline |
Unpacks the current numeric or string value from the stream.
Definition at line 461 of file dcPacker.I.
void DCPacker::unpack_validate | ( | ) |
Internally unpacks the current numeric or string value and validates it against the type range limits, but does not return the value.
If the current field contains nested fields, validates all of them.
Definition at line 577 of file dcPacker.cxx.