26 DCPackerInterface(
const string &name) :
29 _has_fixed_byte_size =
false;
31 _has_fixed_structure =
false;
32 _has_range_limits =
false;
33 _num_length_bytes = 0;
34 _has_nested_fields =
false;
35 _num_nested_fields = -1;
36 _pack_type = PT_invalid;
46 _has_fixed_byte_size(copy._has_fixed_byte_size),
47 _fixed_byte_size(copy._fixed_byte_size),
48 _has_fixed_structure(copy._has_fixed_structure),
49 _has_range_limits(copy._has_range_limits),
50 _num_length_bytes(copy._num_length_bytes),
51 _has_nested_fields(copy._has_nested_fields),
52 _num_nested_fields(copy._num_nested_fields),
53 _pack_type(copy._pack_type)
62 ~DCPackerInterface() {
63 if (_catalog !=
nullptr) {
94 const DCField *DCPackerInterface::
103 as_switch_parameter() {
111 as_switch_parameter()
const {
119 as_class_parameter() {
127 as_class_parameter()
const {
144 std::istringstream strm(description);
145 dc_init_parser_parameter_description(strm,
"check_match", dcfile);
149 DCField *field = dc_get_parameter_description();
150 if (field !=
nullptr) {
155 if (dc_error_count() == 0) {
273 unpack_double(
const char *,
size_t,
size_t &,
double &,
bool &pack_error,
bool &)
const {
281 unpack_int(
const char *,
size_t,
size_t &,
int &,
bool &pack_error,
bool &)
const {
289 unpack_uint(
const char *,
size_t,
size_t &,
unsigned int &,
bool &pack_error,
bool &)
const {
297 unpack_int64(
const char *,
size_t,
size_t &, int64_t &,
bool &pack_error,
bool &)
const {
305 unpack_uint64(
const char *,
size_t,
size_t &, uint64_t &,
bool &pack_error,
bool &)
const {
313 unpack_string(
const char *,
size_t,
size_t &,
string &,
bool &pack_error,
bool &)
const {
321 unpack_blob(
const char *,
size_t,
size_t &, vector_uchar &,
bool &pack_error,
bool &)
const {
333 bool &pack_error,
bool &)
const {
334 if (!_has_range_limits) {
346 unpack_skip(
const char *data,
size_t length,
size_t &p,
347 bool &pack_error)
const {
348 if (_has_fixed_byte_size) {
350 p += _fixed_byte_size;
357 if (_has_nested_fields && _num_length_bytes != 0) {
359 if (p + _num_length_bytes > length) {
363 if (_num_length_bytes == 4) {
364 size_t this_length = do_unpack_uint32(data + p);
365 p += this_length + 4;
367 size_t this_length = do_unpack_uint16(data + p);
368 p += this_length + 2;
388 if (_catalog ==
nullptr) {
451 void DCPackerInterface::
453 nassertv(_catalog ==
nullptr);
456 _catalog->r_fill_catalog(
"",
this,
nullptr, 0);
This represents an array of some other kind of object, meaning this parameter type accepts an arbitra...
A single atomic field of a Distributed Class, as read from a .dc file.
This represents a class (or struct) object used as a parameter itself.
A single field of a Distributed Class, either atomic or molecular.
Represents the complete list of Distributed Class descriptions as read from a .dc file.
A single molecular field of a Distributed Class, as read from a .dc file.
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.
int find_entry_by_name(const std::string &name) const
Returns the index number of the entry with the indicated name, or -1 if no entry has the indicated na...
This defines the internal interface for packing values into a DCField.
const DCPackerCatalog * get_catalog() const
Returns the DCPackerCatalog associated with this field, listing all of the nested fields by name.
virtual void pack_int64(DCPackData &pack_data, int64_t value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_blob(const char *data, size_t length, size_t &p, std::vector< unsigned char > &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void pack_uint(DCPackData &pack_data, unsigned int value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_uint64(const char *data, size_t length, size_t &p, uint64_t &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void unpack_double(const char *data, size_t length, size_t &p, double &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void pack_uint64(DCPackData &pack_data, uint64_t value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const
Internally unpacks the current numeric or string value and validates it against the type range limits...
virtual int calc_num_nested_fields(size_t length_bytes) const
This flavor of get_num_nested_fields is used during unpacking.
virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const
Returns true if this field matches the indicated simple parameter, false otherwise.
virtual void unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_string(const char *data, size_t length, size_t &p, std::string &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual void unpack_int(const char *data, size_t length, size_t &p, int &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual bool do_check_match_atomic_field(const DCAtomicField *other) const
Returns true if this field matches the indicated atomic field, false otherwise.
virtual void pack_int(DCPackData &pack_data, int value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual bool validate_num_nested_fields(int num_nested_fields) const
After a number of fields have been packed via push() .
bool check_match(const DCPackerInterface *other) const
Returns true if the other interface is bitwise the same as this oneāthat is, a uint32 only matches a ...
virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const
Returns true if this field matches the indicated switch parameter, false otherwise.
virtual void pack_double(DCPackData &pack_data, double value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual void unpack_int64(const char *data, size_t length, size_t &p, int64_t &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
virtual bool do_check_match_class_parameter(const DCClassParameter *other) const
Returns true if this field matches the indicated class parameter, false otherwise.
virtual void set_name(const std::string &name)
Sets the name of this field.
virtual bool do_check_match_molecular_field(const DCMolecularField *other) const
Returns true if this field matches the indicated molecular field, false otherwise.
virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const
Returns true if this field matches the indicated array parameter, false otherwise.
virtual void pack_blob(DCPackData &pack_data, const std::vector< unsigned char > &value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
virtual bool unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const
Increments p to the end of the current field without actually unpacking any data or performing any ra...
virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const
Packs the field's specified default value (or a sensible default if no value is specified) into the s...
int find_seek_index(const std::string &name) const
Returns the index number to be passed to a future call to DCPacker::seek() to seek directly to the na...
This is the most fundamental kind of parameter type: a single number or string, one of the DCSubatomi...
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.