27XFileDataNodeTemplate::
28XFileDataNodeTemplate(
XFile *x_file,
const string &name,
58 pdata._double_list = double_list;
59 pdata._parse_flags = XFileParseData::PF_double;
61 _parse_data_list._list.push_back(pdata);
71 pdata._int_list = int_list;
72 pdata._parse_flags = XFileParseData::PF_int;
74 _parse_data_list._list.push_back(pdata);
85 pdata._parse_flags = XFileParseData::PF_string;
87 _parse_data_list._list.push_back(pdata);
103 size_t sub_index = 0;
105 if (!_template->repack_data(
this, _parse_data_list,
106 prev_data, index, sub_index)) {
110 if (index != _parse_data_list._list.size()) {
111 xyywarning(
"Too many data elements in structure.");
124 _nested_elements.push_back(element);
132write_text(std::ostream &out,
int indent_level)
const {
134 << _template->get_name();
136 out <<
" " << get_name();
140 NestedElements::const_iterator ni;
141 for (ni = _nested_elements.begin(); ni != _nested_elements.end(); ++ni) {
142 (*ni)->write_data(out, indent_level + 2,
";");
154write_data(std::ostream &out,
int indent_level,
const char *separator)
const {
155 if (!_nested_elements.empty()) {
156 bool indented =
false;
157 for (
size_t i = 0;
i < _nested_elements.size() - 1;
i++) {
165 object->write_data(out, indent_level,
";");
170 indent(out, indent_level);
173 out << *
object <<
"; ";
184 string combined_separator = string(
";") + string(separator);
185 object->write_data(out, indent_level, combined_separator.c_str());
189 indent(out, indent_level);
191 out << *
object <<
";" << separator <<
"\n";
200int XFileDataNodeTemplate::
201get_num_elements()
const {
202 return _nested_elements.size();
210 nassertr(n >= 0 && n < (
int)_nested_elements.size(),
nullptr);
211 return _nested_elements[n];
219get_element(
const string &name) {
220 int child_index = _template->find_child_index(name);
221 if (child_index >= 0) {
222 return get_element(child_index);
225 <<
"\"" << name <<
"\" not a member of " << _template->get_name()
bool has_name() const
Returns true if the Namable has a nonempty name set, false if the name is empty.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void write_data(std::ostream &out, int indent_level, const char *separator) const
Writes a suitable representation of this node to an .x file in text mode.
bool finalize_parse_data()
Processes all of the data elements added by add_parse_*(), checks them for syntactic and semantic cor...
void add_parse_double(PTA_double double_list)
Adds the indicated list of doubles as a data element encountered in the parser.
virtual bool add_element(XFileDataObject *element)
Adds the indicated element as a nested data element, if this data object type supports it.
void zero_fill()
Fills the data node with zero-valued elements appropriate to the template.
virtual bool is_complex_object() const
Returns true if this kind of data object is a complex object that can hold nested data elements,...
void add_parse_int(PTA_int int_list)
Adds the indicated list of ints as a data element encountered in the parser.
virtual void write_text(std::ostream &out, int indent_level) const
Writes a suitable representation of this node to an .x file in text mode.
void add_parse_string(const std::string &str)
Adds the indicated string as a data element encountered in the parser.
This is an abstract base class for an XFileNode which is also an XFileDataObject.
The abstract base class for a number of different types of data elements that may be stored in the X ...
virtual bool is_complex_object() const
Returns true if this kind of data object is a complex object that can hold nested data elements,...
int i() const
Unambiguously returns the object's representation as an integer, or 0 if the object has no integer re...
virtual void write_text(std::ostream &out, int indent_level) const
Writes a suitable representation of this node to an .x file in text mode.
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 te...
This class is used to fill up the data into an XFileDataNodeTemplate object as the data values are pa...
A template definition in the X file.
This represents the complete contents of an X file (file.x) in memory.
This is our own Panda specialization on the default STL map.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
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.