Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Friends

XFile Class Reference

This represents the complete contents of an X file (file.x) in memory. More...

#include "xFile.h"

Inheritance diagram for XFile:
XFileNode TypedObject Namable ReferenceCount MemoryBase MemoryBase MemoryBase

List of all members.

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.
XFileDataNodeTemplatefind_data_object (const string &name) const
 Returns the data object associated with the indicated name, if any, or NULL if none.
XFileDataNodeTemplatefind_data_object (const WindowsGuid &guid) const
 Returns the data object associated with the indicated GUID, if any, or NULL if none.
XFileTemplatefind_template (const string &name) const
 Returns the template associated with the indicated name, if any, or NULL if none.
XFileTemplatefind_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 (ostream &out) const
 Writes a parseable description of all the known nodes and templates to the stream.
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.
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 XFileTemplatefind_standard_template (const string &name)
 Returns the standard template associated with the indicated name, if any, or NULL if none.
static XFileTemplatefind_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

Detailed Description

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.

Definition at line 35 of file xFile.h.


Member Function Documentation

void XFile::clear ( void  ) [virtual]

Removes all of the classes defined within the XFile and prepares it for reading a new file.

Reimplemented from XFileNode.

Definition at line 60 of file xFile.cxx.

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

Returns the data object associated with the indicated GUID, if any, or NULL if none.

Definition at line 303 of file xFile.cxx.

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_standard_template ( const string &  name) [static]
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]

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 89 of file xFile.h.

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).

Definition at line 110 of file xFile.cxx.

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::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]

Writes a suitable representation of this node to an .x file in text mode.

Reimplemented from XFileNode.

Definition at line 321 of file xFile.cxx.

Referenced by write().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations