34class EXPCL_DIRECT_DCPARSER DCPacker {
47 bool owns_unpack_data);
56 bool seek(
const std::string &field_name);
57 bool seek(
int seek_index);
74 INLINE
void pack_uint(
unsigned int value);
78 INLINE
void pack_blob(
const vector_uchar &value);
108 void pack_object(PyObject *
object);
109 PyObject *unpack_object();
129 INLINE
void get_string(std::string &data)
const;
130 INLINE
const char *
get_data()
const;
133 INLINE
void append_data(
const unsigned char *buffer,
size_t size);
159#define RAW_PACK_CHANNEL(in) raw_pack_uint64(in)
160#define RAW_UNPACK_CHANNEL() raw_unpack_uint64()
189 static void enquote_string(std::ostream &out,
char quote_mark,
const std::string &str);
193 INLINE
void advance();
199 void pack_class_object(
const DCClass *dclass, PyObject *
object);
200 PyObject *unpack_class_object(
const DCClass *dclass);
201 void set_class_element(PyObject *class_def, PyObject *&
object,
203 void get_class_element(
const DCClass *dclass, PyObject *
object,
217 const char *_unpack_data;
218 size_t _unpack_length;
219 bool _owns_unpack_data;
230 INLINE
void *
operator new(
size_t size);
231 INLINE
void operator delete(
void *ptr);
234 int _current_field_index;
239 static StackElement *_deleted_chain;
240 static int _num_ever_allocated;
242 StackElement *_stack;
246 int _current_field_index;
255 int _num_nested_fields;
Defines a particular DistributedClass as read from an input .dc file.
A single field of a Distributed Class, either atomic or molecular.
This is a block of data that receives the results of DCPacker.
This object contains the names of all of the nested fields available within a particular field.
This defines the internal interface for packing values into a DCField.
const DCPackerInterface * get_current_field() const
Returns the field that will be referenced by the next call to pack_*() or unpack_*().
int raw_unpack_int32()
Unpacks the data from the buffer between unpacking sessions.
std::vector< unsigned char > get_bytes() const
Returns the packed data buffer as a bytes object.
void unpack_validate()
Internally unpacks the current numeric or string value and validates it against the type range limits...
void push()
Marks the beginning of a nested series of fields.
bool more_nested_fields() const
Returns true if there are more nested fields to pack or unpack in the current push sequence,...
void raw_pack_int8(int value)
Packs the data into the buffer between packing sessions.
unsigned int raw_unpack_uint32()
Unpacks the data from the buffer between unpacking sessions.
std::string unpack_string()
Unpacks the current numeric or string value from the stream.
std::string raw_unpack_string()
Unpacks the data from the buffer between unpacking sessions.
void clear_data()
Empties the data in the pack buffer and unpack buffer.
void pack_blob(const std::vector< unsigned char > &value)
Packs the indicated numeric or string value into the stream.
int unpack_int()
Unpacks the current numeric or string value from the stream.
std::string get_string() const
Returns the packed data buffer as a string.
std::vector< unsigned char > raw_unpack_blob()
Unpacks the data from the buffer between unpacking sessions.
void append_data(const unsigned char *buffer, size_t size)
Adds the indicated bytes to the end of the data.
void pack_uint(unsigned int value)
Packs the indicated numeric or string value into the stream.
std::vector< unsigned char > unpack_literal_value()
Returns the literal string that represents the packed value of the current field, and advances the fi...
void begin_pack(const DCPackerInterface *root)
Begins a packing session.
bool had_range_error() const
Returns true if there has been an range validation error since the most recent call to begin(); in pa...
void pack_int(int value)
Packs the indicated numeric or string value into the stream.
void raw_pack_string(const std::string &value)
Packs the data into the buffer between packing sessions.
char * get_write_pointer(size_t size)
Adds the indicated number of bytes to the end of the data without initializing them,...
void begin_unpack(const DCPackerInterface *root)
Begins an unpacking session.
void begin_repack(const DCPackerInterface *root)
Begins a repacking session.
bool end_repack()
Finishes the repacking session.
DCPackType get_pack_type() const
Returns the type of value expected by the current field.
bool end_unpack()
Finishes the unpacking session.
const DCSwitchParameter * get_last_switch() const
Returns a pointer to the last DCSwitch instance that we have passed by and selected one case of durin...
void raw_pack_float64(double value)
Packs the data into the buffer between packing sessions.
bool has_nested_fields() const
Returns true if the current field has any nested fields (and thus expects a push() .
uint64_t raw_unpack_uint64()
Unpacks the data from the buffer between unpacking sessions.
void raw_pack_uint32(unsigned int value)
Packs the data into the buffer between packing sessions.
void pack_uint64(uint64_t value)
Packs the indicated numeric or string value into the stream.
bool had_error() const
Returns true if there has been any error (either a pack error or a range error) since the most recent...
int get_num_nested_fields() const
Returns the number of nested fields associated with the current field, if has_nested_fields() returne...
void raw_pack_uint16(unsigned int value)
Packs the data into the buffer between packing sessions.
double unpack_double()
Unpacks the current numeric or string value from the stream.
void raw_pack_uint8(unsigned int value)
Packs the data into the buffer between packing sessions.
size_t get_unpack_length() const
Returns the total number of bytes in the unpack data buffer.
void pop()
Marks the end of a nested series of fields.
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,...
std::string get_unpack_string() const
Returns the unpack data buffer, as a string.
bool had_pack_error() const
Returns true if there has been an packing error since the most recent call to begin(); in particular,...
bool end_pack()
Finishes a packing session.
void pack_int64(int64_t value)
Packs the indicated numeric or string value into the stream.
const char * get_data() const
Returns the beginning of the data buffer.
bool had_parse_error() const
Returns true if there has been an parse error since the most recent call to begin(); this can only ha...
int raw_unpack_int16()
Unpacks the data from the buffer between unpacking sessions.
double raw_unpack_float64()
Unpacks the data from the buffer between unpacking sessions.
void unpack_skip()
Skips the current field without unpacking it and advances to the next field.
static void output_hex_string(std::ostream &out, const std::vector< unsigned char > &str)
Outputs the indicated string as a hex constant.
bool seek(const std::string &field_name)
Sets the current unpack (or repack) position to the named 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.
void set_unpack_data(const std::vector< unsigned char > &data)
Sets up the unpack_data pointer.
bool parse_and_pack(const std::string &formatted_object)
Parses an object's value according to the DC file syntax (e.g.
void pack_default_value()
Adds the default value for the current element into the stream.
int64_t raw_unpack_int64()
Unpacks the data from the buffer between unpacking sessions.
void raw_pack_int64(int64_t value)
Packs the data into the buffer between packing sessions.
const char * get_unpack_data() const
Returns a read pointer to the unpack data buffer.
size_t get_num_unpacked_bytes() const
Returns the number of bytes that have been unpacked so far, or after unpack_end(),...
unsigned int raw_unpack_uint8()
Unpacks the data from the buffer between unpacking sessions.
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....
std::vector< unsigned char > unpack_blob()
Unpacks the current binary data value from the stream.
unsigned int raw_unpack_uint16()
Unpacks the data from the buffer between unpacking sessions.
void pack_double(double value)
Packs the indicated numeric or string value into the stream.
size_t get_length() const
Returns the current length of the buffer.
int64_t unpack_int64()
Unpacks the current numeric or string value from the stream.
void raw_pack_blob(const std::vector< unsigned char > &value)
Packs the data into the buffer between packing sessions.
static int get_num_stack_elements_ever_allocated()
Returns the number of DCPacker::StackElement pointers ever simultaneously allocated; these are now ei...
void raw_pack_uint64(uint64_t value)
Packs the data into the buffer between packing sessions.
int raw_unpack_int8()
Unpacks the data from the buffer between unpacking sessions.
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 ha...
unsigned int unpack_uint()
Unpacks the current numeric or string value from the stream.
uint64_t unpack_uint64()
Unpacks the current numeric or string value from the stream.
void raw_pack_int32(int value)
Packs the data into the buffer between packing sessions.
char * take_data()
Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the...
void raw_pack_int16(int value)
Packs the data into the buffer between packing sessions.
void pack_string(const std::string &value)
Packs the indicated numeric or string value into the stream.
This represents a switch object used as a parameter itself, which packs the appropriate fields of the...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ostream & enquote_string(ostream &out, const string &str, int indent_level, bool always_quote)
Writes the string to the indicated output stream.