Panda3D
|
A definition of a single data element appearing within a template record. More...
#include "xFileDataDef.h"
Public Types | |
enum | Type { T_word, T_dword, T_float, T_double, T_char, T_uchar, T_sword, T_sdword, T_string, T_cstring, T_unicode, T_template } |
Public Member Functions | |
XFileDataDef (XFile *x_file, const string &name, Type type, XFileTemplate *xtemplate=NULL) | |
void | add_array_def (const XFileArrayDef &array_def) |
Adds an additional array dimension to the data description. | |
virtual void | clear () |
Removes all children from the node, and otherwise resets it to its initial state. | |
virtual bool | fill_zero_data (XFileDataObject *object) const |
This is similar to repack_data(), except it is used to fill the initial values for a newly-created template object to zero. | |
virtual TypeHandle | force_init_type () |
const XFileArrayDef & | get_array_def (int i) const |
Returns the description of the nth dimension of array elements on this data object. | |
Type | get_data_type () const |
Returns the primitive type of this element, or T_template if this represents a nested template object. | |
int | get_num_array_defs () const |
Returns the number of dimensions of array elements on this data object, or 0 if the data object is not an array. | |
XFileTemplate * | get_template () const |
If get_data_type() returned T_template, this returns the particular template pointer that this object represents. | |
virtual TypeHandle | get_type () const |
virtual bool | matches (const XFileNode *other) const |
Returns true if the node, particularly a template node, is structurally equivalent to the other node (which must be of the same type). | |
virtual bool | repack_data (XFileDataObject *object, const XFileParseDataList &parse_data_list, PrevData &prev_data, size_t &index, size_t &sub_index) const |
This is called on the template that defines an object, once the data for the object has been parsed. | |
virtual void | write_text (ostream &out, int indent_level) const |
Writes a suitable representation of this node to an .x file in text mode. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. |
A definition of a single data element appearing within a template record.
This class represents the definition* of the data element (e.g. DWORD nVertices); see XFileDataObject for its *value* (e.g. 12).
Definition at line 35 of file xFileDataDef.h.
void XFileDataDef::add_array_def | ( | const XFileArrayDef & | array_def | ) |
Adds an additional array dimension to the data description.
Definition at line 56 of file xFileDataDef.cxx.
void XFileDataDef::clear | ( | void | ) | [virtual] |
Removes all children from the node, and otherwise resets it to its initial state.
Reimplemented from XFileNode.
Definition at line 44 of file xFileDataDef.cxx.
bool XFileDataDef::fill_zero_data | ( | XFileDataObject * | object | ) | const [virtual] |
This is similar to repack_data(), except it is used to fill the initial values for a newly-created template object to zero.
Reimplemented from XFileNode.
Definition at line 210 of file xFileDataDef.cxx.
const XFileArrayDef & XFileDataDef::get_array_def | ( | int | i | ) | const [inline] |
Returns the description of the nth dimension of array elements on this data object.
Definition at line 73 of file xFileDataDef.I.
Referenced by matches().
XFileDataDef::Type XFileDataDef::get_data_type | ( | ) | const [inline] |
Returns the primitive type of this element, or T_template if this represents a nested template object.
Definition at line 38 of file xFileDataDef.I.
Referenced by matches().
int XFileDataDef::get_num_array_defs | ( | ) | const [inline] |
Returns the number of dimensions of array elements on this data object, or 0 if the data object is not an array.
Definition at line 62 of file xFileDataDef.I.
Referenced by matches().
XFileTemplate * XFileDataDef::get_template | ( | ) | const [inline] |
If get_data_type() returned T_template, this returns the particular template pointer that this object represents.
Definition at line 50 of file xFileDataDef.I.
Referenced by matches().
static void XFileDataDef::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from XFileNode.
Definition at line 125 of file xFileDataDef.h.
bool XFileDataDef::matches | ( | const XFileNode * | other | ) | const [virtual] |
Returns true if the node, particularly a template node, is structurally equivalent to the other node (which must be of the same type).
This checks data element types, but does not compare data element names.
Reimplemented from XFileNode.
Definition at line 257 of file xFileDataDef.cxx.
References get_array_def(), get_data_type(), get_num_array_defs(), get_template(), XFileArrayDef::matches(), XFileTemplate::matches(), and XFileNode::matches().
bool XFileDataDef::repack_data | ( | XFileDataObject * | object, |
const XFileParseDataList & | parse_data_list, | ||
XFileDataDef::PrevData & | prev_data, | ||
size_t & | index, | ||
size_t & | sub_index | ||
) | const [virtual] |
This is called on the template that defines an object, once the data for the object has been parsed.
It is responsible for identifying which component of the template owns each data element, and packing the data elements appropriately back into the object.
It returns true on success, or false on an error (e.g. not enough data elements, mismatched data type).
Reimplemented from XFileNode.
Definition at line 150 of file xFileDataDef.cxx.
void XFileDataDef::write_text | ( | ostream & | out, |
int | indent_level | ||
) | const [virtual] |
Writes a suitable representation of this node to an .x file in text mode.
Reimplemented from XFileNode.
Definition at line 67 of file xFileDataDef.cxx.
References Namable::has_name().