Panda3D
Classes | Public Member Functions | Static Public Member Functions

DCPacker Class Reference

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"

List of all members.

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 DCPackerInterfaceget_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 DCPackerInterfaceget_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 DCSwitchParameterget_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.

Detailed Description

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.


Member Function Documentation

void DCPacker::append_data ( const char *  buffer,
size_t  size 
) [inline]

Adds the indicated bytes to the end of the data.

This may only be called between packing sessions.

Definition at line 747 of file dcPacker.I.

References DCPackData::append_data().

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 DCSimpleParameter::pack_default_value(), DCSwitch::pack_default_value(), DCArrayParameter::pack_default_value(), DCField::parse_string(), and DCField::refresh_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 234 of file dcPacker.cxx.

References DCPackData::clear(), DCPackerInterface::get_catalog(), and DCPackerCatalog::get_live_catalog().

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 164 of file dcPacker.cxx.

Referenced by DCField::format_data(), DCPackerCatalog::get_live_catalog(), and DCField::validate_ranges().

void DCPacker::clear_data ( ) [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 25 of file dcPacker.I.

References DCPackData::clear().

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 99 of file dcPacker.cxx.

References had_error().

Referenced by DCSimpleParameter::pack_default_value(), DCSwitch::pack_default_value(), DCArrayParameter::pack_default_value(), DCField::parse_string(), and DCField::refresh_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 272 of file dcPacker.cxx.

References DCPackData::append_data(), and had_error().

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 193 of file dcPacker.cxx.

References had_error().

Referenced by DCField::format_data(), DCPackerCatalog::get_live_catalog(), and DCField::validate_ranges().

void DCPacker::enquote_string ( ostream &  out,
char  quote_mark,
const string &  str 
) [static]

Outputs the indicated string within quotation marks.

Definition at line 1120 of file dcPacker.cxx.

Referenced by unpack_and_format().

const DCPackerInterface * DCPacker::get_current_field ( ) const [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 109 of file dcPacker.I.

string DCPacker::get_current_field_name ( ) const [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 161 of file dcPacker.I.

References DCPackerInterface::get_name().

Referenced by unpack_and_format().

const DCPackerInterface * DCPacker::get_current_parent ( ) const [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 96 of file dcPacker.I.

const char * DCPacker::get_data ( ) const [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 717 of file dcPacker.I.

References DCPackData::get_data().

Referenced by DCSwitch::pack_default_value(), DCSimpleParameter::pack_default_value(), DCArrayParameter::pack_default_value(), and DCField::refresh_default_value().

const DCSwitchParameter * DCPacker::get_last_switch ( ) const [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 127 of file dcPacker.I.

size_t DCPacker::get_length ( ) const [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 652 of file dcPacker.I.

References DCPackData::get_length().

Referenced by DCSwitch::pack_default_value(), DCSimpleParameter::pack_default_value(), DCArrayParameter::pack_default_value(), and DCField::refresh_default_value().

int DCPacker::get_num_nested_fields ( ) const [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 71 of file dcPacker.I.

int DCPacker::get_num_stack_elements_ever_allocated ( ) [inline, static]

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 788 of file dcPacker.I.

size_t DCPacker::get_num_unpacked_bytes ( ) const [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 640 of file dcPacker.I.

Referenced by DCField::validate_ranges().

DCPackType DCPacker::get_pack_type ( ) const [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 145 of file dcPacker.I.

References DCPackerInterface::get_pack_type().

Referenced by unpack_and_format().

string DCPacker::get_string ( ) const [inline]

Returns the packed data buffer as a string.

Also see get_data().

Definition at line 663 of file dcPacker.I.

References DCPackData::get_string().

Referenced by DCField::parse_string().

void DCPacker::get_string ( string &  data) const [inline]

Copies the packed data into the indicated string.

Also see get_data().

Definition at line 701 of file dcPacker.I.

References DCPackData::get_data(), and DCPackData::get_length().

const char * DCPacker::get_unpack_data ( ) const [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 775 of file dcPacker.I.

size_t DCPacker::get_unpack_length ( ) const [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 676 of file dcPacker.I.

string DCPacker::get_unpack_string ( ) const [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 690 of file dcPacker.I.

char * DCPacker::get_write_pointer ( size_t  size) [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 761 of file dcPacker.I.

References DCPackData::get_write_pointer().

bool DCPacker::had_error ( ) const [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 625 of file dcPacker.I.

Referenced by end_pack(), end_repack(), and end_unpack().

bool DCPacker::had_pack_error ( ) const [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 592 of file dcPacker.I.

Referenced by unpack_and_format().

bool DCPacker::had_parse_error ( ) const [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 573 of file dcPacker.I.

bool DCPacker::had_range_error ( ) const [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 611 of file dcPacker.I.

bool DCPacker::has_nested_fields ( ) const [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 45 of file dcPacker.I.

References DCPackerInterface::has_nested_fields().

Referenced by push().

bool DCPacker::more_nested_fields ( ) const [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 83 of file dcPacker.I.

Referenced by pack_default_value(), unpack_and_format(), unpack_skip(), and unpack_validate().

void DCPacker::output_hex_string ( ostream &  out,
const string &  str 
) [static]

Outputs the indicated string as a hex constant.

Definition at line 1146 of file dcPacker.cxx.

References DCPackData::get_data(), DCPackData::get_length(), DCPackerInterface::get_nested_field(), and DCPackerInterface::get_num_nested_fields().

Referenced by unpack_and_format().

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 593 of file dcPacker.cxx.

References more_nested_fields(), DCPackerInterface::pack_default_value(), pop(), and push().

Referenced by DCSimpleParameter::pack_default_value(), DCSwitch::pack_default_value(), DCArrayParameter::pack_default_value(), and DCField::refresh_default_value().

void DCPacker::pack_double ( double  value) [inline]

Packs the indicated numeric or string value into the stream.

Definition at line 176 of file dcPacker.I.

References DCPackerInterface::pack_double().

void DCPacker::pack_int ( int  value) [inline]

Packs the indicated numeric or string value into the stream.

Definition at line 193 of file dcPacker.I.

References DCPackerInterface::pack_int().

void DCPacker::pack_int64 ( PN_int64  value) [inline]

Packs the indicated numeric or string value into the stream.

Definition at line 227 of file dcPacker.I.

References DCPackerInterface::pack_int64().

void DCPacker::pack_literal_value ( const string &  value) [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 279 of file dcPacker.I.

References DCPackData::append_data().

Referenced by DCSwitch::pack_default_value().

void DCPacker::pack_string ( const string &  value) [inline]

Packs the indicated numeric or string value into the stream.

Definition at line 261 of file dcPacker.I.

References DCPackerInterface::pack_string().

void DCPacker::pack_uint ( unsigned int  value) [inline]

Packs the indicated numeric or string value into the stream.

Definition at line 210 of file dcPacker.I.

References DCPackerInterface::pack_uint().

void DCPacker::pack_uint64 ( PN_uint64  value) [inline]

Packs the indicated numeric or string value into the stream.

Definition at line 244 of file dcPacker.I.

References DCPackerInterface::pack_uint64().

bool DCPacker::parse_and_pack ( const 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 973 of file dcPacker.cxx.

Referenced by DCField::parse_string().

bool DCPacker::parse_and_pack ( 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 986 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 533 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().

Referenced by pack_default_value(), DCSimpleParameter::pack_default_value(), DCArrayParameter::pack_default_value(), unpack_and_format(), unpack_skip(), and unpack_validate().

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 444 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 pack_default_value(), DCSimpleParameter::pack_default_value(), DCArrayParameter::pack_default_value(), unpack_and_format(), unpack_skip(), and unpack_validate().

void DCPacker::raw_pack_float64 ( double  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 895 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_int16 ( int  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 811 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_int32 ( int  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 823 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_int64 ( PN_int64  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 835 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_int8 ( int  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 799 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_string ( const string &  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 907 of file dcPacker.I.

References DCPackData::append_data(), and DCPackData::get_write_pointer().

void DCPacker::raw_pack_uint16 ( unsigned int  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 859 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_uint32 ( unsigned int  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 871 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_uint64 ( PN_uint64  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 883 of file dcPacker.I.

References DCPackData::get_write_pointer().

void DCPacker::raw_pack_uint8 ( unsigned int  value) [inline]

Packs the data into the buffer between packing sessions.

Definition at line 847 of file dcPacker.I.

References DCPackData::get_write_pointer().

double DCPacker::raw_unpack_float64 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1075 of file dcPacker.I.

void DCPacker::raw_unpack_float64 ( double &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1186 of file dcPacker.I.

int DCPacker::raw_unpack_int16 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 933 of file dcPacker.I.

void DCPacker::raw_unpack_int16 ( int &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 989 of file dcPacker.I.

int DCPacker::raw_unpack_int32 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 946 of file dcPacker.I.

void DCPacker::raw_unpack_int32 ( int &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1006 of file dcPacker.I.

void DCPacker::raw_unpack_int64 ( PN_int64 &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1101 of file dcPacker.I.

PN_int64 DCPacker::raw_unpack_int64 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 959 of file dcPacker.I.

int DCPacker::raw_unpack_int8 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 920 of file dcPacker.I.

void DCPacker::raw_unpack_int8 ( int &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 972 of file dcPacker.I.

string DCPacker::raw_unpack_string ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1088 of file dcPacker.I.

void DCPacker::raw_unpack_string ( string &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1203 of file dcPacker.I.

References raw_unpack_uint16().

unsigned int DCPacker::raw_unpack_uint16 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1036 of file dcPacker.I.

Referenced by raw_unpack_string().

void DCPacker::raw_unpack_uint16 ( unsigned int &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1135 of file dcPacker.I.

unsigned int DCPacker::raw_unpack_uint32 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1049 of file dcPacker.I.

void DCPacker::raw_unpack_uint32 ( unsigned int &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1152 of file dcPacker.I.

PN_uint64 DCPacker::raw_unpack_uint64 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1062 of file dcPacker.I.

void DCPacker::raw_unpack_uint64 ( PN_uint64 &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1169 of file dcPacker.I.

unsigned int DCPacker::raw_unpack_uint8 ( ) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1023 of file dcPacker.I.

void DCPacker::raw_unpack_uint8 ( unsigned int &  value) [inline]

Unpacks the data from the buffer between unpacking sessions.

Definition at line 1118 of file dcPacker.I.

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 331 of file dcPacker.cxx.

References DCPackData::append_data(), DCPackerCatalog::LiveCatalog::get_begin(), DCPackerInterface::get_catalog(), DCPackerCatalog::LiveCatalog::get_end(), DCPackerCatalog::LiveCatalog::get_entry(), DCPackData::get_length(), DCPackerCatalog::get_live_catalog(), DCPackerInterface::get_num_nested_fields(), DCPackerCatalog::release_live_catalog(), set_unpack_data(), and DCPackData::take_data().

bool DCPacker::seek ( const 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 297 of file dcPacker.cxx.

References DCPackerCatalog::LiveCatalog::find_entry_by_name(), DCPackerInterface::get_catalog(), and DCPackerCatalog::get_live_catalog().

void DCPacker::set_unpack_data ( const string &  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 121 of file dcPacker.cxx.

Referenced by DCField::format_data(), DCPackerCatalog::get_live_catalog(), seek(), and DCField::validate_ranges().

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 137 of file dcPacker.cxx.

char * DCPacker::take_data ( ) [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 736 of file dcPacker.I.

References DCPackData::take_data().

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 1007 of file dcPacker.cxx.

Referenced by DCField::format_data(), and unpack_and_format().

void DCPacker::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.

as a default value), or as an input to parse_object.

Definition at line 1021 of file dcPacker.cxx.

References enquote_string(), get_current_field_name(), DCPackerInterface::get_name(), get_pack_type(), had_pack_error(), more_nested_fields(), output_hex_string(), pop(), push(), unpack_and_format(), unpack_double(), unpack_int(), unpack_int64(), unpack_literal_value(), unpack_string(), unpack_uint(), and unpack_uint64().

void DCPacker::unpack_double ( double &  value) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 443 of file dcPacker.I.

References DCPackerInterface::unpack_double().

double DCPacker::unpack_double ( ) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 296 of file dcPacker.I.

References DCPackerInterface::unpack_double().

Referenced by unpack_and_format().

int DCPacker::unpack_int ( ) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 318 of file dcPacker.I.

References DCPackerInterface::unpack_int().

Referenced by unpack_and_format().

void DCPacker::unpack_int ( int &  value) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 462 of file dcPacker.I.

References DCPackerInterface::unpack_int().

PN_int64 DCPacker::unpack_int64 ( ) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 362 of file dcPacker.I.

References DCPackerInterface::unpack_int64().

Referenced by unpack_and_format().

void DCPacker::unpack_int64 ( PN_int64 &  value) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 500 of file dcPacker.I.

References DCPackerInterface::unpack_int64().

string DCPacker::unpack_literal_value ( ) [inline]

Returns the literal string that represents the packed value of the current field, and advances the field pointer.

Definition at line 429 of file dcPacker.I.

References unpack_skip().

Referenced by unpack_and_format().

void DCPacker::unpack_literal_value ( string &  value) [inline]

Returns the literal string that represents the packed value of the current field, and advances the field pointer.

Definition at line 558 of file dcPacker.I.

References unpack_skip().

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 651 of file dcPacker.cxx.

References more_nested_fields(), pop(), push(), and DCPackerInterface::unpack_skip().

Referenced by unpack_literal_value().

void DCPacker::unpack_string ( string &  value) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 538 of file dcPacker.I.

References DCPackerInterface::unpack_string().

string DCPacker::unpack_string ( ) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 406 of file dcPacker.I.

References DCPackerInterface::unpack_string().

Referenced by unpack_and_format().

unsigned int DCPacker::unpack_uint ( ) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 340 of file dcPacker.I.

References DCPackerInterface::unpack_uint().

Referenced by unpack_and_format().

void DCPacker::unpack_uint ( unsigned int &  value) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 481 of file dcPacker.I.

References DCPackerInterface::unpack_uint().

void DCPacker::unpack_uint64 ( PN_uint64 &  value) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 519 of file dcPacker.I.

References DCPackerInterface::unpack_uint64().

PN_uint64 DCPacker::unpack_uint64 ( ) [inline]

Unpacks the current numeric or string value from the stream.

Definition at line 384 of file dcPacker.I.

References DCPackerInterface::unpack_uint64().

Referenced by unpack_and_format().

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 622 of file dcPacker.cxx.

References more_nested_fields(), pop(), push(), and DCPackerInterface::unpack_validate().

Referenced by DCField::validate_ranges().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations