Panda3D
|
This is the most fundamental kind of parameter type: a single number or string, one of the DCSubatomicType elements. More...
#include "dcSimpleParameter.h"
Public Member Functions | |
DCSimpleParameter (DCSubatomicType type, unsigned int divisor=1) | |
DCSimpleParameter (const DCSimpleParameter ©) | |
bool | add_keyword (const DCKeyword *keyword) |
Adds the indicated keyword to the list. | |
virtual DCParameter * | append_array_specification (const DCUnsignedIntRange &size) |
Returns the type represented by this_type[size]. | |
virtual const DCArrayParameter * | as_array_parameter () const |
virtual DCArrayParameter * | as_array_parameter () |
virtual DCAtomicField * | as_atomic_field () |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL. | |
virtual const DCAtomicField * | as_atomic_field () const |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL. | |
virtual DCClassParameter * | as_class_parameter () |
virtual const DCClassParameter * | as_class_parameter () const |
virtual const DCField * | as_field () const |
virtual DCField * | as_field () |
virtual DCMolecularField * | as_molecular_field () |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL. | |
virtual const DCMolecularField * | as_molecular_field () const |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL. | |
virtual const DCParameter * | as_parameter () const |
virtual DCParameter * | as_parameter () |
virtual const DCSimpleParameter * | as_simple_parameter () const |
virtual DCSimpleParameter * | as_simple_parameter () |
virtual DCSwitchParameter * | as_switch_parameter () |
virtual const DCSwitchParameter * | as_switch_parameter () const |
virtual int | calc_num_nested_fields (size_t length_bytes) const |
This flavor of get_num_nested_fields is used during unpacking. | |
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 uint32, etc. | |
bool | check_match (const string &description, DCFile *dcfile=NULL) const |
Returns true if this interface is bitwise the same as the interface described with the indicated formatted string, e.g. | |
void | clear_keywords () |
Removes all keywords from the field. | |
bool | compare_keywords (const DCKeywordList &other) const |
Returns true if this list has the same keywords as the other list, false if some keywords differ. | |
void | copy_keywords (const DCKeywordList &other) |
Replaces this keyword list with those from the other list. | |
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 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_switch_parameter (const DCSwitchParameter *other) const |
Returns true if this field matches the indicated switch 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 named field without having to look up the field name in a table later, or -1 if the named field cannot be found. | |
string | format_data (const string &packed_data, bool show_field_names=true) |
Given a blob that represents the packed data for this field, returns a string formatting it for human consumption. | |
virtual void | generate_hash (HashGenerator &hashgen) const |
Accumulates the properties of this type into the hash. | |
const DCPackerCatalog * | get_catalog () const |
Returns the DCPackerCatalog associated with this field, listing all of the nested fields by name. | |
DCClass * | get_class () const |
Returns the DCClass pointer for the class that contains this field. | |
const string & | get_default_value () const |
Returns the default value for this field. | |
int | get_divisor () const |
Returns the divisor associated with this type. | |
size_t | get_fixed_byte_size () const |
If has_fixed_byte_size() returns true, this returns the number of bytes this field type will use. | |
const DCKeyword * | get_keyword (int n) const |
Returns the nth keyword in the list. | |
const DCKeyword * | get_keyword_by_name (const string &name) const |
Returns the keyword in the list with the indicated name, or NULL if there is no keyword in the list with that name. | |
double | get_modulus () const |
Returns the modulus associated with this type, if any. | |
const string & | get_name () const |
Returns the name of this field, or empty string if the field is unnamed. | |
virtual DCPackerInterface * | get_nested_field (int n) const |
Returns the DCPackerInterface object that represents the nth nested field. | |
int | get_num_keywords () const |
Returns the number of keywords in the list. | |
size_t | get_num_length_bytes () const |
Returns the number of bytes that should be written into the stream on a push() to record the number of bytes in the record up until the next pop(). | |
int | get_num_nested_fields () const |
Returns the number of nested fields required by this field type. | |
int | get_number () const |
Returns a unique index number associated with this field. | |
DCPackType | get_pack_type () const |
Returns the type of value expected by this field. | |
DCSubatomicType | get_type () const |
Returns the particular subatomic type represented by this instance. | |
const DCTypedef * | get_typedef () const |
If this type has been referenced from a typedef, returns the DCTypedef instance, or NULL if the type was declared on-the-fly. | |
bool | has_default_value () const |
Returns true if a default value has been explicitly established for this field, false otherwise. | |
bool | has_fixed_byte_size () const |
Returns true if this field type always packs to the same number of bytes, false if it is variable. | |
bool | has_fixed_structure () const |
Returns true if this field type always has the same structure regardless of the data in the stream, or false if its structure may vary. | |
bool | has_keyword (const DCKeyword *keyword) const |
Returns true if this list includes the indicated keyword, false otherwise. | |
bool | has_keyword (const string &name) const |
Returns true if this list includes the indicated keyword, false otherwise. | |
bool | has_modulus () const |
Returns true if there is a modulus associated, false otherwise.,. | |
bool | has_nested_fields () const |
Returns true if this field type has any nested fields (and thus expects a push() . | |
bool | has_range_limits () const |
Returns true if this field, or any sub-field of this field, has a limit imposed in the DC file on its legal values. | |
bool | is_airecv () const |
Returns true if the "airecv" flag is set for this field, false otherwise. | |
bool | is_bogus_field () const |
Returns true if the field has been flagged as a bogus field. | |
bool | is_broadcast () const |
Returns true if the "broadcast" flag is set for this field, false otherwise. | |
bool | is_clrecv () const |
Returns true if the "clrecv" flag is set for this field, false otherwise. | |
bool | is_clsend () const |
Returns true if the "clsend" flag is set for this field, false otherwise. | |
bool | is_db () const |
Returns true if the "db" flag is set for this field, false otherwise. | |
bool | is_numeric_type () const |
Returns true if the type is a numeric type (and therefore can accept a divisor and/or a modulus), or false if it is some string-based type. | |
bool | is_ownrecv () const |
Returns true if the "ownrecv" flag is set for this field, false otherwise. | |
bool | is_ownsend () const |
Returns true if the "ownsend" flag is set for this field, false otherwise. | |
bool | is_ram () const |
Returns true if the "ram" flag is set for this field, false otherwise. | |
bool | is_required () const |
Returns true if the "required" flag is set for this field, false otherwise. | |
virtual bool | is_valid () const |
Returns false if the type is an invalid type (e.g. | |
virtual DCParameter * | make_copy () const |
virtual void | output (ostream &out, bool brief) const |
void | output (ostream &out) const |
Write a string representation of this instance to <out>. | |
virtual void | output_instance (ostream &out, bool brief, const string &prename, const string &name, const string &postname) const |
Formats the parameter in the C++-like dc syntax as a typename and identifier. | |
void | output_keywords (ostream &out) const |
void | output_typedef_name (ostream &out, bool brief, const string &prename, const string &name, const string &postname) const |
Formats the instance like output_instance, but uses the typedef name instead. | |
virtual bool | pack_default_value (DCPackData &pack_data, bool &pack_error) const |
Packs the simpleParameter's specified default value (or a sensible default if no value is specified) into the stream. | |
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 | 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 | 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. | |
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 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 | 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. | |
string | parse_string (const string &formatted_string) |
Given a human-formatted string (for instance, as returned by format_data(), above) that represents the value of this field, parse the string and return the corresponding packed data. | |
void | set_class (DCClass *dclass) |
Assigns the class pointer to this field. | |
void | set_default_value (const string &default_value) |
Establishes a default value for this field. | |
bool | set_divisor (unsigned int divisor) |
Assigns the indicated divisor to the simple type. | |
bool | set_modulus (double modulus) |
Assigns the indicated modulus to the simple type. | |
virtual void | set_name (const string &name) |
Sets the name of this field. | |
void | set_number (int number) |
Assigns the unique number to this field. | |
bool | set_range (const DCDoubleRange &range) |
Sets the parameter with the indicated range. | |
void | set_typedef (const DCTypedef *dtypedef) |
Records the DCTypedef object that generated this parameter. | |
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_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 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 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 range validation. | |
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. | |
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 | 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 | 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, but does not return the value. | |
virtual bool | validate_num_nested_fields (int num_nested_fields) const |
After a number of fields have been packed via push() | |
bool | validate_ranges (const string &packed_data) const |
Verifies that all of the packed values in the field data are within the specified ranges and that there are no extra bytes on the end of the record. | |
void | write (ostream &out, int indent_level) const |
Write a string representation of this instance to <out>. | |
virtual void | write (ostream &out, bool brief, int indent_level) const |
virtual void | write_instance (ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const |
Formats the parameter in the C++-like dc syntax as a typename and identifier. | |
void | write_typedef_name (ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const |
Formats the instance like write_instance, but uses the typedef name instead. | |
Static Public Member Functions | |
static void | do_pack_float64 (char *buffer, double value) |
static void | do_pack_int16 (char *buffer, int value) |
static void | do_pack_int32 (char *buffer, int value) |
static void | do_pack_int64 (char *buffer, PN_int64 value) |
static void | do_pack_int8 (char *buffer, int value) |
static void | do_pack_uint16 (char *buffer, unsigned int value) |
static void | do_pack_uint32 (char *buffer, unsigned int value) |
static void | do_pack_uint64 (char *buffer, PN_uint64 value) |
static void | do_pack_uint8 (char *buffer, unsigned int value) |
static double | do_unpack_float64 (const char *buffer) |
static int | do_unpack_int16 (const char *buffer) |
static int | do_unpack_int32 (const char *buffer) |
static PN_int64 | do_unpack_int64 (const char *buffer) |
static int | do_unpack_int8 (const char *buffer) |
static unsigned int | do_unpack_uint16 (const char *buffer) |
static unsigned int | do_unpack_uint32 (const char *buffer) |
static PN_uint64 | do_unpack_uint64 (const char *buffer) |
static unsigned int | do_unpack_uint8 (const char *buffer) |
static void | validate_int64_limits (PN_int64 value, int num_bits, bool &range_error) |
Confirms that the signed value fits within num_bits bits. | |
static void | validate_int_limits (int value, int num_bits, bool &range_error) |
Confirms that the signed value fits within num_bits bits. | |
static void | validate_uint64_limits (PN_uint64 value, int num_bits, bool &range_error) |
Confirms that the unsigned value fits within num_bits bits. | |
static void | validate_uint_limits (unsigned int value, int num_bits, bool &range_error) |
Confirms that the unsigned value fits within num_bits bits. | |
Protected Member Functions | |
virtual bool | do_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 uint32, etc. | |
virtual bool | do_check_match_array_parameter (const DCArrayParameter *other) const |
Returns true if this field matches the indicated array parameter, false otherwise. | |
virtual bool | do_check_match_simple_parameter (const DCSimpleParameter *other) const |
Returns true if this field matches the indicated simple parameter, false otherwise. | |
void | refresh_default_value () |
Recomputes the default value of the field by repacking it. | |
Protected Attributes | |
bool | _bogus_field |
DCClass * | _dclass |
bool | _default_value_stale |
size_t | _fixed_byte_size |
bool | _has_default_value |
bool | _has_fixed_byte_size |
bool | _has_fixed_structure |
bool | _has_nested_fields |
bool | _has_range_limits |
string | _name |
size_t | _num_length_bytes |
int | _num_nested_fields |
int | _number |
DCPackType | _pack_type |
This is the most fundamental kind of parameter type: a single number or string, one of the DCSubatomicType elements.
It may also optionally have a divisor, which is meaningful only for the numeric type elements (and represents a fixed-point numeric convention).
Definition at line 32 of file dcSimpleParameter.h.
bool DCKeywordList::add_keyword | ( | const DCKeyword * | keyword | ) | [inherited] |
Adds the indicated keyword to the list.
Returns true if it is added, false if it was already there.
Definition at line 157 of file dcKeywordList.cxx.
References DCKeyword::get_historical_flag(), and DCKeyword::get_name().
Referenced by DCFile::add_keyword().
DCParameter * DCParameter::append_array_specification | ( | const DCUnsignedIntRange & | size | ) | [virtual, inherited] |
Returns the type represented by this_type[size].
In the case of a generic DCParameter, this means it returns a DCArrayParameter wrapped around this type.
Reimplemented in DCArrayParameter.
Definition at line 188 of file dcParameter.cxx.
Referenced by DCArrayParameter::append_array_specification().
DCAtomicField * DCField::as_atomic_field | ( | ) | [virtual, inherited] |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL.
Reimplemented in DCAtomicField.
Definition at line 120 of file dcField.cxx.
Referenced by DCClass::add_field().
const DCAtomicField * DCField::as_atomic_field | ( | ) | const [virtual, inherited] |
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic field; otherwise, returns NULL.
Reimplemented in DCAtomicField.
Definition at line 132 of file dcField.cxx.
DCMolecularField * DCField::as_molecular_field | ( | ) | [virtual, inherited] |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL.
Reimplemented in DCMolecularField.
Definition at line 144 of file dcField.cxx.
const DCMolecularField * DCField::as_molecular_field | ( | ) | const [virtual, inherited] |
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular field; otherwise, returns NULL.
Reimplemented in DCMolecularField.
Definition at line 156 of file dcField.cxx.
int DCSimpleParameter::calc_num_nested_fields | ( | size_t | length_bytes | ) | const [virtual] |
This flavor of get_num_nested_fields is used during unpacking.
It returns the number of nested fields to expect, given a certain length in bytes (as read from the _num_length_bytes stored in the stream on the push). This will only be called if _num_length_bytes is nonzero.
Reimplemented from DCPackerInterface.
Definition at line 619 of file dcSimpleParameter.cxx.
bool DCPackerInterface::check_match | ( | const DCPackerInterface * | other | ) | const [inline, inherited] |
Returns true if the other interface is bitwise the same as this one--that is, a uint32 only matches a uint32, etc.
Names of components, and range limits, are not compared.
Definition at line 36 of file dcPackerInterface.I.
Referenced by DCPackerInterface::check_match(), DCArrayParameter::do_check_match_array_parameter(), DCClassParameter::do_check_match_array_parameter(), DCAtomicField::do_check_match_atomic_field(), DCClassParameter::do_check_match_class_parameter(), DCMolecularField::do_check_match_molecular_field(), and DCSwitch::do_check_match_switch().
bool DCPackerInterface::check_match | ( | const string & | description, |
DCFile * | dcfile = NULL |
||
) | const [inherited] |
Returns true if this interface is bitwise the same as the interface described with the indicated formatted string, e.g.
"(uint8, uint8, int16)", or false otherwise.
If DCFile is not NULL, it specifies the DCFile that was previously loaded, from which some predefined structs and typedefs may be referenced in the description string.
Definition at line 167 of file dcPackerInterface.cxx.
References DCPackerInterface::check_match().
void DCKeywordList::clear_keywords | ( | ) | [inherited] |
Removes all keywords from the field.
Definition at line 173 of file dcKeywordList.cxx.
Referenced by DCFile::clear().
bool DCKeywordList::compare_keywords | ( | const DCKeywordList & | other | ) | const [inherited] |
Returns true if this list has the same keywords as the other list, false if some keywords differ.
Order is not considered important.
Definition at line 135 of file dcKeywordList.cxx.
void DCKeywordList::copy_keywords | ( | const DCKeywordList & | other | ) | [inherited] |
Replaces this keyword list with those from the other list.
Definition at line 146 of file dcKeywordList.cxx.
Referenced by DCMolecularField::add_atomic().
bool DCSimpleParameter::do_check_match | ( | const DCPackerInterface * | other | ) | const [protected, virtual] |
Returns true if the other interface is bitwise the same as this one--that is, a uint32 only matches a uint32, etc.
Names of components, and range limits, are not compared.
Implements DCPackerInterface.
Definition at line 2386 of file dcSimpleParameter.cxx.
References DCPackerInterface::do_check_match_simple_parameter().
bool DCSimpleParameter::do_check_match_array_parameter | ( | const DCArrayParameter * | other | ) | const [protected, virtual] |
Returns true if this field matches the indicated array parameter, false otherwise.
Reimplemented from DCPackerInterface.
Definition at line 2445 of file dcSimpleParameter.cxx.
References DCArrayParameter::get_array_size(), and DCArrayParameter::get_element_type().
bool DCPackerInterface::do_check_match_atomic_field | ( | const DCAtomicField * | other | ) | const [virtual, inherited] |
Returns true if this field matches the indicated atomic field, false otherwise.
Reimplemented in DCAtomicField.
Definition at line 516 of file dcPackerInterface.cxx.
Referenced by DCAtomicField::do_check_match().
bool DCPackerInterface::do_check_match_class_parameter | ( | const DCClassParameter * | other | ) | const [virtual, inherited] |
Returns true if this field matches the indicated class parameter, false otherwise.
Reimplemented in DCArrayParameter, and DCClassParameter.
Definition at line 483 of file dcPackerInterface.cxx.
Referenced by DCClassParameter::do_check_match().
bool DCPackerInterface::do_check_match_molecular_field | ( | const DCMolecularField * | other | ) | const [virtual, inherited] |
Returns true if this field matches the indicated molecular field, false otherwise.
Reimplemented in DCMolecularField.
Definition at line 527 of file dcPackerInterface.cxx.
Referenced by DCMolecularField::do_check_match().
bool DCSimpleParameter::do_check_match_simple_parameter | ( | const DCSimpleParameter * | other | ) | const [protected, virtual] |
Returns true if this field matches the indicated simple parameter, false otherwise.
Reimplemented from DCPackerInterface.
Definition at line 2397 of file dcSimpleParameter.cxx.
bool DCPackerInterface::do_check_match_switch_parameter | ( | const DCSwitchParameter * | other | ) | const [virtual, inherited] |
Returns true if this field matches the indicated switch parameter, false otherwise.
Reimplemented in DCSwitchParameter.
Definition at line 494 of file dcPackerInterface.cxx.
Referenced by DCSwitchParameter::do_check_match().
int DCPackerInterface::find_seek_index | ( | const string & | name | ) | const [inherited] |
Returns the index number to be passed to a future call to DCPacker::seek() to seek directly to the named field without having to look up the field name in a table later, or -1 if the named field cannot be found.
If the named field is nested within a switch or some similar dynamic structure that reveals different fields based on the contents of the data, this mechanism cannot be used to pre-fetch the field index number--you must seek for the field by name.
Definition at line 89 of file dcPackerInterface.cxx.
References DCPackerCatalog::find_entry_by_name(), and DCPackerInterface::get_catalog().
string DCField::format_data | ( | const string & | packed_data, |
bool | show_field_names = true |
||
) | [inherited] |
Given a blob that represents the packed data for this field, returns a string formatting it for human consumption.
Returns empty string if there is an error.
Definition at line 188 of file dcField.cxx.
References DCPacker::begin_unpack(), DCPacker::end_unpack(), DCPacker::set_unpack_data(), and DCPacker::unpack_and_format().
Referenced by DCSwitch::output_instance(), and DCSwitch::write_instance().
void DCSimpleParameter::generate_hash | ( | HashGenerator & | hashgen | ) | const [virtual] |
Accumulates the properties of this type into the hash.
Reimplemented from DCParameter.
Definition at line 2361 of file dcSimpleParameter.cxx.
References HashGenerator::add_int(), and DCParameter::generate_hash().
const DCPackerCatalog * DCPackerInterface::get_catalog | ( | ) | const [inherited] |
Returns the DCPackerCatalog associated with this field, listing all of the nested fields by name.
Definition at line 458 of file dcPackerInterface.cxx.
Referenced by DCPacker::begin_repack(), DCPackerInterface::find_seek_index(), and DCPacker::seek().
DCClass * DCField::get_class | ( | ) | const [inline, inherited] |
Returns the DCClass pointer for the class that contains this field.
Reimplemented in DCClassParameter.
Definition at line 35 of file dcField.I.
Referenced by DCClass::add_field().
const string & DCField::get_default_value | ( | ) | const [inline, inherited] |
Returns the default value for this field.
If a default value has been explicitly set (e.g. has_default_value() returns true), returns that value; otherwise, returns an implicit default for the field.
int DCSimpleParameter::get_divisor | ( | ) | const |
Returns the divisor associated with this type.
This is 1 by default, but if this is other than one it represents the scale to apply when packing and unpacking numeric values (to store fixed-point values in an integer field). It is only meaningful for numeric-type fields.
Definition at line 315 of file dcSimpleParameter.cxx.
size_t DCPackerInterface::get_fixed_byte_size | ( | ) | const [inline, inherited] |
If has_fixed_byte_size() returns true, this returns the number of bytes this field type will use.
Definition at line 58 of file dcPackerInterface.I.
Referenced by DCMolecularField::add_atomic(), DCAtomicField::add_element(), DCSwitch::SwitchFields::add_field(), and DCArrayParameter::calc_num_nested_fields().
const DCKeyword * DCKeywordList::get_keyword | ( | int | n | ) | const [inherited] |
Returns the nth keyword in the list.
Definition at line 104 of file dcKeywordList.cxx.
Referenced by DCFile::get_keyword().
const DCKeyword * DCKeywordList::get_keyword_by_name | ( | const string & | name | ) | const [inherited] |
Returns the keyword in the list with the indicated name, or NULL if there is no keyword in the list with that name.
Definition at line 117 of file dcKeywordList.cxx.
Referenced by DCFile::get_keyword_by_name().
double DCSimpleParameter::get_modulus | ( | ) | const |
Returns the modulus associated with this type, if any.
It is an error to call this if has_modulus() returned false.
If present, this is the modulus that is used to constrain the numeric value of the field before it is packed (and range-checked).
Definition at line 300 of file dcSimpleParameter.cxx.
const string & DCPackerInterface::get_name | ( | ) | const [inline, inherited] |
Returns the name of this field, or empty string if the field is unnamed.
Definition at line 23 of file dcPackerInterface.I.
Referenced by DCSwitch::SwitchFields::add_field(), DCClass::add_field(), DCPacker::get_current_field_name(), DCTypedef::get_name(), DCClass::rebuild_inherited_fields(), DCField::refresh_default_value(), and DCPacker::unpack_and_format().
DCPackerInterface * DCSimpleParameter::get_nested_field | ( | int | n | ) | const [virtual] |
Returns the DCPackerInterface object that represents the nth nested field.
This may return NULL if there is no such field (but it shouldn't do this if n is in the range 0 <= n < get_num_nested_fields()).
Reimplemented from DCPackerInterface.
Definition at line 635 of file dcSimpleParameter.cxx.
int DCKeywordList::get_num_keywords | ( | ) | const [inherited] |
Returns the number of keywords in the list.
Definition at line 93 of file dcKeywordList.cxx.
Referenced by DCParameter::generate_hash(), and DCFile::get_num_keywords().
size_t DCPackerInterface::get_num_length_bytes | ( | ) | const [inline, inherited] |
Returns the number of bytes that should be written into the stream on a push() to record the number of bytes in the record up until the next pop().
This is only meaningful if _has_nested_fields is true.
Definition at line 102 of file dcPackerInterface.I.
Referenced by DCPacker::pop(), and DCPacker::push().
int DCPackerInterface::get_num_nested_fields | ( | ) | const [inline, inherited] |
Returns the number of nested fields required by this field type.
These may be array elements or structure elements. The return value may be -1 to indicate the number of nested fields is variable.
Definition at line 130 of file dcPackerInterface.I.
Referenced by DCMolecularField::add_atomic(), DCPacker::output_hex_string(), DCPacker::pop(), DCPacker::push(), and DCPacker::seek().
int DCField::get_number | ( | ) | const [inline, inherited] |
Returns a unique index number associated with this field.
This is defined implicitly when the .dc file(s) are read.
Definition at line 24 of file dcField.I.
Referenced by DCClass::add_field().
DCPackType DCPackerInterface::get_pack_type | ( | ) | const [inline, inherited] |
Returns the type of value expected by this field.
Definition at line 140 of file dcPackerInterface.I.
Referenced by DCPacker::get_pack_type().
DCSubatomicType DCSimpleParameter::get_type | ( | ) | const |
Returns the particular subatomic type represented by this instance.
Definition at line 273 of file dcSimpleParameter.cxx.
Referenced by DCArrayParameter::pack_string(), and DCArrayParameter::unpack_string().
const DCTypedef * DCParameter::get_typedef | ( | ) | const [inherited] |
If this type has been referenced from a typedef, returns the DCTypedef instance, or NULL if the type was declared on-the-fly.
Definition at line 163 of file dcParameter.cxx.
Referenced by DCArrayParameter::append_array_specification(), DCArrayParameter::output_instance(), DCClassParameter::output_instance(), DCParameter::output_typedef_name(), and DCParameter::write_typedef_name().
bool DCField::has_default_value | ( | ) | const [inline, inherited] |
Returns true if a default value has been explicitly established for this field, false otherwise.
Definition at line 46 of file dcField.I.
Referenced by DCMolecularField::add_atomic(), DCAtomicField::add_element(), and DCSwitch::SwitchFields::add_field().
bool DCPackerInterface::has_fixed_byte_size | ( | ) | const [inline, inherited] |
Returns true if this field type always packs to the same number of bytes, false if it is variable.
Definition at line 47 of file dcPackerInterface.I.
Referenced by DCMolecularField::add_atomic(), DCAtomicField::add_element(), DCSwitch::SwitchFields::add_field(), and DCArrayParameter::calc_num_nested_fields().
bool DCPackerInterface::has_fixed_structure | ( | ) | const [inline, inherited] |
Returns true if this field type always has the same structure regardless of the data in the stream, or false if its structure may vary.
This is almost, but not quite, the same thing as has_fixed_byte_size. The difference is that a DCSwitch may have multiple cases all with the same byte size, but they will still (presumably) have different structures, in the sense that the actual list of fields varies according to the live data.
Definition at line 76 of file dcPackerInterface.I.
Referenced by DCMolecularField::add_atomic(), DCAtomicField::add_element(), DCSwitch::SwitchFields::add_field(), and DCPackerCatalog::get_live_catalog().
bool DCKeywordList::has_keyword | ( | const string & | name | ) | const [inherited] |
Returns true if this list includes the indicated keyword, false otherwise.
Definition at line 72 of file dcKeywordList.cxx.
Referenced by DCKeywordList::has_keyword(), DCField::is_airecv(), DCField::is_broadcast(), DCField::is_clrecv(), DCField::is_clsend(), DCField::is_db(), DCField::is_ownrecv(), DCField::is_ownsend(), DCField::is_ram(), and DCField::is_required().
bool DCKeywordList::has_keyword | ( | const DCKeyword * | keyword | ) | const [inherited] |
Returns true if this list includes the indicated keyword, false otherwise.
Definition at line 83 of file dcKeywordList.cxx.
References DCKeyword::get_name(), and DCKeywordList::has_keyword().
bool DCSimpleParameter::has_modulus | ( | ) | const |
Returns true if there is a modulus associated, false otherwise.,.
Definition at line 284 of file dcSimpleParameter.cxx.
bool DCPackerInterface::has_nested_fields | ( | ) | const [inline, inherited] |
Returns true if this field type has any nested fields (and thus expects a push() .
. pop() interface to the DCPacker), 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 117 of file dcPackerInterface.I.
Referenced by DCPacker::has_nested_fields().
bool DCPackerInterface::has_range_limits | ( | ) | const [inline, inherited] |
Returns true if this field, or any sub-field of this field, has a limit imposed in the DC file on its legal values.
If this is false, then unpack_validate() is trivial.
Definition at line 89 of file dcPackerInterface.I.
Referenced by DCMolecularField::add_atomic(), DCAtomicField::add_element(), and DCSwitch::SwitchFields::add_field().
bool DCField::is_airecv | ( | ) | const [inline, inherited] |
Returns true if the "airecv" flag is set for this field, false otherwise.
Definition at line 176 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_bogus_field | ( | ) | const [inline, inherited] |
Returns true if the field has been flagged as a bogus field.
This is set for fields that are generated by the parser as placeholder for missing fields, as when reading a partial file; it should not occur in a normal valid dc file.
Definition at line 77 of file dcField.I.
Referenced by DCMolecularField::add_atomic().
bool DCField::is_broadcast | ( | ) | const [inline, inherited] |
Returns true if the "broadcast" flag is set for this field, false otherwise.
Definition at line 99 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_clrecv | ( | ) | const [inline, inherited] |
Returns true if the "clrecv" flag is set for this field, false otherwise.
Definition at line 143 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_clsend | ( | ) | const [inline, inherited] |
Returns true if the "clsend" flag is set for this field, false otherwise.
Definition at line 132 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_db | ( | ) | const [inline, inherited] |
Returns true if the "db" flag is set for this field, false otherwise.
Definition at line 121 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCSimpleParameter::is_numeric_type | ( | ) | const |
Returns true if the type is a numeric type (and therefore can accept a divisor and/or a modulus), or false if it is some string-based type.
Definition at line 327 of file dcSimpleParameter.cxx.
bool DCField::is_ownrecv | ( | ) | const [inline, inherited] |
Returns true if the "ownrecv" flag is set for this field, false otherwise.
Definition at line 165 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_ownsend | ( | ) | const [inline, inherited] |
Returns true if the "ownsend" flag is set for this field, false otherwise.
Definition at line 154 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_ram | ( | ) | const [inline, inherited] |
Returns true if the "ram" flag is set for this field, false otherwise.
Definition at line 110 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCField::is_required | ( | ) | const [inline, inherited] |
Returns true if the "required" flag is set for this field, false otherwise.
Definition at line 88 of file dcField.I.
References DCKeywordList::has_keyword().
bool DCSimpleParameter::is_valid | ( | ) | const [virtual] |
Returns false if the type is an invalid type (e.g.
declared from an undefined typedef), true if it is valid.
Implements DCParameter.
Definition at line 262 of file dcSimpleParameter.cxx.
void DCField::output | ( | ostream & | out | ) | const [inline, inherited] |
Write a string representation of this instance to <out>.
Definition at line 187 of file dcField.I.
Referenced by DCSwitch::output_instance(), DCClass::output_instance(), and DCSwitch::write_instance().
void DCSimpleParameter::output_instance | ( | ostream & | out, |
bool | brief, | ||
const string & | prename, | ||
const string & | name, | ||
const string & | postname | ||
) | const [virtual] |
Formats the parameter in the C++-like dc syntax as a typename and identifier.
Implements DCParameter.
Definition at line 2270 of file dcSimpleParameter.cxx.
void DCParameter::output_typedef_name | ( | ostream & | out, |
bool | brief, | ||
const string & | prename, | ||
const string & | name, | ||
const string & | postname | ||
) | const [inherited] |
Formats the instance like output_instance, but uses the typedef name instead.
Definition at line 246 of file dcParameter.cxx.
References DCTypedef::get_name(), and DCParameter::get_typedef().
Referenced by DCArrayParameter::output_instance(), and DCClassParameter::output_instance().
bool DCSimpleParameter::pack_default_value | ( | DCPackData & | pack_data, |
bool & | pack_error | ||
) | const [virtual] |
Packs the simpleParameter's specified default value (or a sensible default if no value is specified) into the stream.
Returns true if the default value is packed, false if the simpleParameter doesn't know how to pack its default value.
Reimplemented from DCField.
Definition at line 1147 of file dcSimpleParameter.cxx.
References DCPackData::append_data(), DCPacker::begin_pack(), DCPacker::end_pack(), DCPacker::get_data(), DCPacker::get_length(), DCPacker::pack_default_value(), DCField::pack_default_value(), DCPacker::pop(), and DCPacker::push().
void DCSimpleParameter::pack_double | ( | DCPackData & | pack_data, |
double | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Packs the indicated numeric or string value into the stream.
Reimplemented from DCPackerInterface.
Definition at line 646 of file dcSimpleParameter.cxx.
References DCPackData::get_write_pointer().
void DCSimpleParameter::pack_int | ( | DCPackData & | pack_data, |
int | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Packs the indicated numeric or string value into the stream.
Reimplemented from DCPackerInterface.
Definition at line 747 of file dcSimpleParameter.cxx.
References DCPackData::get_write_pointer().
void DCSimpleParameter::pack_int64 | ( | DCPackData & | pack_data, |
PN_int64 | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Packs the indicated numeric or string value into the stream.
Reimplemented from DCPackerInterface.
Definition at line 923 of file dcSimpleParameter.cxx.
References DCPackData::get_write_pointer().
void DCSimpleParameter::pack_string | ( | DCPackData & | pack_data, |
const string & | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Packs the indicated numeric or string value into the stream.
Reimplemented from DCPackerInterface.
Definition at line 1095 of file dcSimpleParameter.cxx.
References DCPackData::append_data(), and DCPackData::get_write_pointer().
void DCSimpleParameter::pack_uint | ( | DCPackData & | pack_data, |
unsigned int | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Packs the indicated numeric or string value into the stream.
Reimplemented from DCPackerInterface.
Definition at line 841 of file dcSimpleParameter.cxx.
References DCPackData::get_write_pointer().
void DCSimpleParameter::pack_uint64 | ( | DCPackData & | pack_data, |
PN_uint64 | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Packs the indicated numeric or string value into the stream.
Reimplemented from DCPackerInterface.
Definition at line 1011 of file dcSimpleParameter.cxx.
References DCPackData::get_write_pointer().
string DCField::parse_string | ( | const string & | formatted_string | ) | [inherited] |
Given a human-formatted string (for instance, as returned by format_data(), above) that represents the value of this field, parse the string and return the corresponding packed data.
Returns empty string if there is an error.
Definition at line 209 of file dcField.cxx.
References DCPacker::begin_pack(), DCPacker::end_pack(), DCPacker::get_string(), and DCPacker::parse_and_pack().
void DCField::refresh_default_value | ( | ) | [protected, inherited] |
Recomputes the default value of the field by repacking it.
Definition at line 620 of file dcField.cxx.
References DCPacker::begin_pack(), DCPacker::end_pack(), DCPacker::get_data(), DCPacker::get_length(), DCPackerInterface::get_name(), and DCPacker::pack_default_value().
void DCField::set_class | ( | DCClass * | dclass | ) | [inline, inherited] |
Assigns the class pointer to this field.
This is normally called only by the DCClass interface as the field is added.
Definition at line 222 of file dcField.I.
Referenced by DCClass::add_field().
void DCField::set_default_value | ( | const string & | default_value | ) | [inline, inherited] |
bool DCSimpleParameter::set_divisor | ( | unsigned int | divisor | ) |
Assigns the indicated divisor to the simple type.
Returns true if assigned, false if this type cannot accept a divisor or if the divisor is invalid.
Definition at line 412 of file dcSimpleParameter.cxx.
bool DCSimpleParameter::set_modulus | ( | double | modulus | ) |
Assigns the indicated modulus to the simple type.
Any packed value will be constrained to be within [0, modulus).
Returns true if assigned, false if this type cannot accept a modulus or if the modulus is invalid.
Definition at line 342 of file dcSimpleParameter.cxx.
void DCField::set_name | ( | const string & | name | ) | [virtual, inherited] |
Sets the name of this field.
Reimplemented from DCPackerInterface.
Definition at line 566 of file dcField.cxx.
References DCFile::mark_inherited_fields_stale().
Referenced by DCTypedef::DCTypedef(), and DCTypedef::make_new_parameter().
void DCField::set_number | ( | int | number | ) | [inline, inherited] |
Assigns the unique number to this field.
This is normally called only by the DCClass interface as the field is added.
Definition at line 210 of file dcField.I.
Referenced by DCClass::add_field(), and DCFile::set_new_index_number().
bool DCSimpleParameter::set_range | ( | const DCDoubleRange & | range | ) |
Sets the parameter with the indicated range.
A DCDoubleRange is used for specification, since this is the most generic type; but it is converted to the appropriate type internally. The return value is true if successful, or false if the range is inappropriate for the type.
Definition at line 445 of file dcSimpleParameter.cxx.
References DCNumericRange< NUM >::get_max(), DCNumericRange< NUM >::get_min(), and DCNumericRange< NUM >::get_num_ranges().
void DCParameter::set_typedef | ( | const DCTypedef * | dtypedef | ) | [inherited] |
Records the DCTypedef object that generated this parameter.
This is normally called only from DCTypedef::make_new_parameter().
Definition at line 175 of file dcParameter.cxx.
Referenced by DCTypedef::make_new_parameter().
void DCSimpleParameter::unpack_double | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
double & | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Unpacks the current numeric or string value from the stream.
Reimplemented from DCPackerInterface.
Definition at line 1241 of file dcSimpleParameter.cxx.
void DCSimpleParameter::unpack_int | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
int & | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Unpacks the current numeric or string value from the stream.
Reimplemented from DCPackerInterface.
Definition at line 1380 of file dcSimpleParameter.cxx.
void DCSimpleParameter::unpack_int64 | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
PN_int64 & | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Unpacks the current numeric or string value from the stream.
Reimplemented from DCPackerInterface.
Definition at line 1670 of file dcSimpleParameter.cxx.
bool DCSimpleParameter::unpack_skip | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
bool & | pack_error | ||
) | const [virtual] |
Increments p to the end of the current field without actually unpacking any data or performing any range validation.
Returns true on success, false on failure (e.g. we don't know how to skip this field).
Reimplemented from DCPackerInterface.
Definition at line 2198 of file dcSimpleParameter.cxx.
void DCSimpleParameter::unpack_string | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
string & | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Unpacks the current numeric or string value from the stream.
Reimplemented from DCPackerInterface.
Definition at line 1959 of file dcSimpleParameter.cxx.
void DCSimpleParameter::unpack_uint | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
unsigned int & | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Unpacks the current numeric or string value from the stream.
Reimplemented from DCPackerInterface.
Definition at line 1521 of file dcSimpleParameter.cxx.
void DCSimpleParameter::unpack_uint64 | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
PN_uint64 & | value, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Unpacks the current numeric or string value from the stream.
Reimplemented from DCPackerInterface.
Definition at line 1810 of file dcSimpleParameter.cxx.
bool DCSimpleParameter::unpack_validate | ( | const char * | data, |
size_t | length, | ||
size_t & | p, | ||
bool & | pack_error, | ||
bool & | range_error | ||
) | const [virtual] |
Internally unpacks the current numeric or string value and validates it against the type range limits, but does not return the value.
Returns true on success, false on failure (e.g. we don't know how to validate this field).
Reimplemented from DCPackerInterface.
Definition at line 2036 of file dcSimpleParameter.cxx.
void DCPackerInterface::validate_int64_limits | ( | PN_int64 | value, |
int | num_bits, | ||
bool & | range_error | ||
) | [inline, static, inherited] |
Confirms that the signed value fits within num_bits bits.
Sets range_error true if it does not.
Definition at line 416 of file dcPackerInterface.I.
void DCPackerInterface::validate_int_limits | ( | int | value, |
int | num_bits, | ||
bool & | range_error | ||
) | [inline, static, inherited] |
Confirms that the signed value fits within num_bits bits.
Sets range_error true if it does not.
Definition at line 394 of file dcPackerInterface.I.
bool DCPackerInterface::validate_num_nested_fields | ( | int | num_nested_fields | ) | const [virtual, inherited] |
After a number of fields have been packed via push()
. pack_*() .. pop(), this is called to confirm that the number of nested fields that were added is valid for this type. This is primarily useful for array types with dynamic ranges that can't validate the number of fields any other way.
Reimplemented in DCArrayParameter.
Definition at line 238 of file dcPackerInterface.cxx.
Referenced by DCPacker::pop().
bool DCField::validate_ranges | ( | const string & | packed_data | ) | const [inherited] |
Verifies that all of the packed values in the field data are within the specified ranges and that there are no extra bytes on the end of the record.
Returns true if all fields are valid, false otherwise.
Definition at line 233 of file dcField.cxx.
References DCPacker::begin_unpack(), DCPacker::end_unpack(), DCPacker::get_num_unpacked_bytes(), DCPacker::set_unpack_data(), and DCPacker::unpack_validate().
void DCPackerInterface::validate_uint64_limits | ( | PN_uint64 | value, |
int | num_bits, | ||
bool & | range_error | ||
) | [inline, static, inherited] |
Confirms that the unsigned value fits within num_bits bits.
Sets range_error true if it does not.
Definition at line 451 of file dcPackerInterface.I.
void DCPackerInterface::validate_uint_limits | ( | unsigned int | value, |
int | num_bits, | ||
bool & | range_error | ||
) | [inline, static, inherited] |
Confirms that the unsigned value fits within num_bits bits.
Sets range_error true if it does not.
Definition at line 432 of file dcPackerInterface.I.
Referenced by DCPacker::pop().
void DCField::write | ( | ostream & | out, |
int | indent_level | ||
) | const [inline, inherited] |
Write a string representation of this instance to <out>.
Definition at line 198 of file dcField.I.
Referenced by DCClass::write().
void DCParameter::write_instance | ( | ostream & | out, |
bool | brief, | ||
int | indent_level, | ||
const string & | prename, | ||
const string & | name, | ||
const string & | postname | ||
) | const [virtual, inherited] |
Formats the parameter in the C++-like dc syntax as a typename and identifier.
Reimplemented in DCSwitchParameter.
Definition at line 226 of file dcParameter.cxx.
void DCParameter::write_typedef_name | ( | ostream & | out, |
bool | brief, | ||
int | indent_level, | ||
const string & | prename, | ||
const string & | name, | ||
const string & | postname | ||
) | const [inherited] |
Formats the instance like write_instance, but uses the typedef name instead.
Definition at line 261 of file dcParameter.cxx.
References DCTypedef::get_name(), and DCParameter::get_typedef().