Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
DCSwitch::SwitchFields Class Reference
Inheritance diagram for DCSwitch::SwitchFields:
DCPackerInterface

Public Member Functions

 SwitchFields (const std::string &name)
 
bool add_field (DCField *field)
 Adds a field to this case.
 
bool do_check_match_switch_case (const SwitchFields *other) const
 Returns true if this case matches the indicated case, false otherwise.
 
virtual DCPackerInterfaceget_nested_field (int n) const
 Returns the DCPackerInterface object that represents the nth nested field.
 
void output (std::ostream &out, bool brief) const
 
void write (std::ostream &out, bool brief, int indent_level) const
 
- Public Member Functions inherited from DCPackerInterface
 DCPackerInterface (const DCPackerInterface &copy)
 
 DCPackerInterface (const std::string &name=std::string())
 
virtual DCClassParameteras_class_parameter ()
 
virtual const DCClassParameteras_class_parameter () const
 
virtual DCFieldas_field ()
 
virtual const DCFieldas_field () const
 
virtual DCSwitchParameteras_switch_parameter ()
 
virtual const DCSwitchParameteras_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 std::string &description, DCFile *dcfile=nullptr) const
 Returns true if this interface is bitwise the same as the interface described with the indicated formatted string, e.g.
 
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_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_simple_parameter (const DCSimpleParameter *other) const
 Returns true if this field matches the indicated simple parameter, 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 std::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.
 
const DCPackerCatalogget_catalog () const
 Returns the DCPackerCatalog associated with this field, listing all of the nested fields by name.
 
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 std::string & get_name () const
 Returns the name of this field, or empty string if the field is unnamed.
 
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.
 
DCPackType get_pack_type () const
 Returns the type of value expected by this field.
 
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_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.
 
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 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 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, int64_t 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 std::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, uint64_t value, bool &pack_error, bool &range_error) const
 Packs the indicated numeric or string value into the stream.
 
virtual void set_name (const std::string &name)
 Sets the name of this field.
 
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 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, int64_t &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, std::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, uint64_t &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() .
 

Public Attributes

Fields _fields
 
FieldsByName _fields_by_name
 
bool _has_default_value
 

Additional Inherited Members

- Static Public Member Functions inherited from DCPackerInterface
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, int64_t 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, uint64_t 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 int64_t 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 uint64_t do_unpack_uint64 (const char *buffer)
 
static unsigned int do_unpack_uint8 (const char *buffer)
 
static void validate_int64_limits (int64_t 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 (uint64_t 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.
 

Detailed Description

Definition at line 78 of file dcSwitch.h.

Constructor & Destructor Documentation

◆ SwitchFields()

DCSwitch::SwitchFields::SwitchFields ( const std::string & name)

Definition at line 562 of file dcSwitch.cxx.

◆ ~SwitchFields()

DCSwitch::SwitchFields::~SwitchFields ( )

Definition at line 580 of file dcSwitch.cxx.

Member Function Documentation

◆ add_field()

bool DCSwitch::SwitchFields::add_field ( DCField * field)

Adds a field to this case.

Returns true if successful, false if the field duplicates a field already named within this case. This is normally called only by the parser.

Definition at line 603 of file dcSwitch.cxx.

References DCPackerInterface::get_fixed_byte_size(), DCPackerInterface::get_name(), DCField::has_default_value(), DCPackerInterface::has_fixed_byte_size(), DCPackerInterface::has_fixed_structure(), and DCPackerInterface::has_range_limits().

Referenced by DCSwitch::add_field().

◆ do_check_match_switch_case()

bool DCSwitch::SwitchFields::do_check_match_switch_case ( const SwitchFields * other) const

Returns true if this case matches the indicated case, false otherwise.

This is only intended to be called internally from DCSwitch::do_check_match_switch().

Definition at line 640 of file dcSwitch.cxx.

◆ get_nested_field()

DCPackerInterface * DCSwitch::SwitchFields::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 592 of file dcSwitch.cxx.

◆ output()

void DCSwitch::SwitchFields::output ( std::ostream & out,
bool brief ) const

Definition at line 657 of file dcSwitch.cxx.

◆ write()

void DCSwitch::SwitchFields::write ( std::ostream & out,
bool brief,
int indent_level ) const

Definition at line 675 of file dcSwitch.cxx.

Member Data Documentation

◆ _fields

Fields DCSwitch::SwitchFields::_fields

Definition at line 94 of file dcSwitch.h.

◆ _fields_by_name

FieldsByName DCSwitch::SwitchFields::_fields_by_name

Definition at line 95 of file dcSwitch.h.

◆ _has_default_value

bool DCSwitch::SwitchFields::_has_default_value

Definition at line 96 of file dcSwitch.h.


The documentation for this class was generated from the following files: