Panda3D
|
This represents the complete contents of an X file (file.x) in memory. More...
#include "xFile.h"
Public Types | |
enum | FloatSize { FS_32, FS_64 } |
enum | FormatType { FT_text, FT_binary, FT_compressed } |
Public Member Functions | |
XFile (bool keep_names=false) | |
virtual void | clear () |
Removes all of the classes defined within the XFile and prepares it for reading a new file. | |
XFileDataNodeTemplate * | find_data_object (const string &name) const |
Returns the data object associated with the indicated name, if any, or NULL if none. | |
XFileDataNodeTemplate * | find_data_object (const WindowsGuid &guid) const |
Returns the data object associated with the indicated GUID, if any, or NULL if none. | |
XFileTemplate * | find_template (const string &name) const |
Returns the template associated with the indicated name, if any, or NULL if none. | |
XFileTemplate * | find_template (const WindowsGuid &guid) const |
Returns the template associated with the indicated GUID, if any, or NULL if none. | |
virtual TypeHandle | force_init_type () |
virtual TypeHandle | get_type () const |
bool | read (Filename filename) |
Opens and reads the indicated .x file by name. | |
bool | read (istream &in, const string &filename=string()) |
Parses the already-opened input stream for distributed class descriptions. | |
bool | write (Filename filename) const |
Opens the indicated filename for output and writes a parseable description of all the known distributed classes to the file. | |
bool | write (ostream &out) const |
Writes a parseable description of all the known nodes and templates to the stream. | |
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 XFileTemplate * | find_standard_template (const string &name) |
Returns the standard template associated with the indicated name, if any, or NULL if none. | |
static XFileTemplate * | find_standard_template (const WindowsGuid &guid) |
Returns the template associated with the indicated GUID, if any, or NULL if none. | |
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. | |
Friends | |
class | XFileNode |
This represents the complete contents of an X file (file.x) in memory.
It may be read or written from or to a disk file.
void XFile::clear | ( | void | ) | [virtual] |
XFileDataNodeTemplate * XFile::find_data_object | ( | const string & | name | ) | const |
Returns the data object associated with the indicated name, if any, or NULL if none.
Definition at line 286 of file xFile.cxx.
References XFileNode::find_descendent(), and TypedObject::is_of_type().
XFileDataNodeTemplate * XFile::find_data_object | ( | const WindowsGuid & | guid | ) | const |
XFileTemplate * XFile::find_standard_template | ( | const string & | name | ) | [static] |
Returns the standard template associated with the indicated name, if any, or NULL if none.
Definition at line 262 of file xFile.cxx.
References find_template().
Referenced by XFileDataObject::add_Coords2d(), XFileNode::add_Frame(), XFileNode::add_FrameTransformMatrix(), XFileDataObject::add_IndexedColor(), XFileNode::add_Material(), XFileNode::add_Mesh(), XFileDataObject::add_MeshFace(), XFileNode::add_MeshMaterialList(), XFileNode::add_MeshNormals(), XFileNode::add_MeshTextureCoords(), XFileNode::add_MeshVertexColors(), XFileNode::add_TextureFilename(), and XFileDataObject::add_Vector().
XFileTemplate * XFile::find_standard_template | ( | const WindowsGuid & | guid | ) | [static] |
Returns the template associated with the indicated GUID, if any, or NULL if none.
Definition at line 274 of file xFile.cxx.
References find_template().
XFileTemplate * XFile::find_template | ( | const string & | name | ) | const |
Returns the template associated with the indicated name, if any, or NULL if none.
Definition at line 199 of file xFile.cxx.
References XFileNode::find_child(), find_template(), TypedObject::is_of_type(), and XFileTemplate::matches().
Referenced by find_standard_template(), and find_template().
XFileTemplate * XFile::find_template | ( | const WindowsGuid & | guid | ) | const |
Returns the template associated with the indicated GUID, if any, or NULL if none.
Definition at line 230 of file xFile.cxx.
References find_template(), and XFileTemplate::matches().
static void XFile::init_type | ( | ) | [inline, static] |
bool XFile::read | ( | Filename | filename | ) |
Opens and reads the indicated .x file by name.
The nodes and templates defined in the file will be appended to the set of nodes already recorded, if any.
Returns true if the file is successfully read, false if there was an error (in which case the file might have been partially read).
Definition at line 79 of file xFile.cxx.
References VirtualFileSystem::close_read_file(), VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_read_file(), and Filename::set_text().
bool XFile::read | ( | istream & | in, |
const string & | filename = string() |
||
) |
Parses the already-opened input stream for distributed class descriptions.
The filename parameter is optional and is only used when reporting errors.
The distributed classes defined in the file will be appended to the set of distributed classes already recorded, if any.
Returns true if the file is successfully read, false if there was an error (in which case the file might have been partially read).
bool XFile::write | ( | Filename | filename | ) | const |
Opens the indicated filename for output and writes a parseable description of all the known distributed classes to the file.
Returns true if the description is successfully written, false otherwise.
Definition at line 146 of file xFile.cxx.
References Filename::get_extension(), Filename::open_write(), and Filename::set_binary().
bool XFile::write | ( | ostream & | out | ) | const |
Writes a parseable description of all the known nodes and templates to the stream.
Returns true if the description is successfully written, false otherwise.
Definition at line 182 of file xFile.cxx.
References write_text().
void XFile::write_text | ( | ostream & | out, |
int | indent_level | ||
) | const [virtual] |