15 #include "dcPackerInterface.h" 16 #include "dcPackerCatalog.h" 18 #include "dcParserDefs.h" 19 #include "dcLexerDefs.h" 27 DCPackerInterface(
const string &name) :
30 _has_fixed_byte_size =
false;
32 _has_fixed_structure =
false;
33 _has_range_limits =
false;
34 _num_length_bytes = 0;
35 _has_nested_fields =
false;
36 _num_nested_fields = -1;
37 _pack_type = PT_invalid;
49 _has_fixed_byte_size(copy._has_fixed_byte_size),
50 _fixed_byte_size(copy._fixed_byte_size),
51 _has_fixed_structure(copy._has_fixed_structure),
52 _has_range_limits(copy._has_range_limits),
53 _num_length_bytes(copy._num_length_bytes),
54 _has_nested_fields(copy._has_nested_fields),
55 _num_nested_fields(copy._num_nested_fields),
56 _pack_type(copy._pack_type)
67 ~DCPackerInterface() {
108 const DCField *DCPackerInterface::
119 as_switch_parameter() {
129 as_switch_parameter()
const {
139 as_class_parameter() {
149 as_class_parameter()
const {
170 istringstream strm(description);
171 dc_init_parser_parameter_description(strm,
"check_match", dcfile);
175 DCField *field = dc_get_parameter_description();
181 if (dc_error_count() == 0) {
329 unpack_double(
const char *,
size_t,
size_t &,
double &,
bool &pack_error,
bool &)
const {
340 unpack_int(
const char *,
size_t,
size_t &,
int &,
bool &pack_error,
bool &)
const {
351 unpack_uint(
const char *,
size_t,
size_t &,
unsigned int &,
bool &pack_error,
bool &)
const {
362 unpack_int64(
const char *,
size_t,
size_t &, PN_int64 &,
bool &pack_error,
bool &)
const {
373 unpack_uint64(
const char *,
size_t,
size_t &, PN_uint64 &,
bool &pack_error,
bool &)
const {
384 unpack_string(
const char *,
size_t,
size_t &,
string &,
bool &pack_error,
bool &)
const {
399 bool &pack_error,
bool &)
const {
400 if (!_has_range_limits) {
416 bool &pack_error)
const {
417 if (_has_fixed_byte_size) {
419 p += _fixed_byte_size;
426 if (_has_nested_fields && _num_length_bytes != 0) {
428 if (p + _num_length_bytes > length) {
432 if (_num_length_bytes == 4) {
433 size_t this_length = do_unpack_uint32(data + p);
434 p += this_length + 4;
436 size_t this_length = do_unpack_uint16(data + p);
437 p += this_length + 2;
537 void DCPackerInterface::
542 _catalog->r_fill_catalog(
"",
this, NULL, 0);
This is a block of data that receives the results of DCPacker.
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...
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_uint(DCPackData &pack_data, unsigned int value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.
This represents a class (or struct) object used as a parameter itself.
A single field of a Distributed Class, either atomic or molecular.
This is the most fundamental kind of parameter type: a single number or string, one of the DCSubatomi...
virtual void pack_int64(DCPackData &pack_data, PN_int64 value, bool &pack_error, bool &range_error) const
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...
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const
Returns true if this field matches the indicated simple parameter, false otherwise.
int find_seek_index(const string &name) const
Returns the index number to be passed to a future call to DCPacker::seek() to seek directly to the na...
A single atomic field of a Distributed Class, as read from a .dc file.
Represents the complete list of Distributed Class descriptions as read from a .dc file...
virtual void pack_string(DCPackData &pack_data, const string &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...
This represents an array of some other kind of object, meaning this parameter type accepts an arbitra...
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...
const DCPackerCatalog * get_catalog() const
Returns the DCPackerCatalog associated with this field, listing all of the nested fields by name...
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 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 do_check_match_atomic_field(const DCAtomicField *other) const
Returns true if this field matches the indicated atomic field, false otherwise.
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 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 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_switch_parameter(const DCSwitchParameter *other) const
Returns true if this field matches the indicated switch parameter, false otherwise.
int find_entry_by_name(const string &name) const
Returns the index number of the entry with the indicated name, or -1 if no entry has the indicated na...
virtual void set_name(const string &name)
Sets the name of this field.
virtual void unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
virtual bool do_check_match_molecular_field(const DCMolecularField *other) const
Returns true if this field matches the indicated molecular field, false otherwise.
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 unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const
Unpacks the current numeric or string value from the stream.
This object contains the names of all of the nested fields available within a particular field...
virtual bool validate_num_nested_fields(int num_nested_fields) const
After a number of fields have been packed via push()
A single molecular field of a Distributed Class, as read from a .dc file.
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.
This defines the internal interface for packing values into a DCField.
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 void unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &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, PN_uint64 value, bool &pack_error, bool &range_error) const
Packs the indicated numeric or string value into the stream.