tXmlParserNamespace::tXmlResource Class Reference

#include <tXmlParser.h>

Inheritance diagram for tXmlParserNamespace::tXmlResource:

Inheritance graph
[legend]
Collaboration diagram for tXmlParserNamespace::tXmlResource:

Collaboration graph
[legend]

List of all members.

Public Member Functions

bool LoadFile (const char *filename, const char *uri="")
tResourcePath const & Path () const
 get the resource path this file was loaded from

Protected Member Functions

bool ValidateXml (FILE *docfd, const char *uri, const char *filepath)
node GetFileContents (void)
 Returns the node the "real" file contents are within.

Protected Attributes

tResourcePath m_Path
 the resource identifier of this resource


Detailed Description

Definition at line 143 of file tXmlParser.h.


Member Function Documentation

bool tXmlParserNamespace::tXmlResource::LoadFile ( const char *  filename,
const char *  uri = "" 
) [virtual]

Reimplemented from tXmlParserNamespace::tXmlParser.

Definition at line 294 of file tXmlParser.cpp.

References tXmlParserNamespace::tXmlParser::LoadXmlFile(), tResourceManager::locateResource(), and tXmlParserNamespace::tXmlParser::m_Filename.

00294                                                                  {
00295     m_Filename = tResourceManager::locateResource(filename, uri);
00296     return LoadXmlFile(m_Filename, uri);
00297 }

Here is the call graph for this function:

tResourcePath const& tXmlParserNamespace::tXmlResource::Path (  )  const [inline]

get the resource path this file was loaded from

Definition at line 146 of file tXmlParser.h.

bool tXmlParserNamespace::tXmlResource::ValidateXml ( FILE *  docfd,
const char *  uri,
const char *  filepath 
) [protected, virtual]

Reimplemented from tXmlParserNamespace::tXmlParser.

Definition at line 457 of file tXmlParser.cpp.

References con, tXmlParserNamespace::tXmlParser::node::GetName(), tXmlParserNamespace::tXmlParser::node::GetProp(), tXmlParserNamespace::tXmlParser::GetRoot(), tXmlParserNamespace::tXmlParser::node::IsOfType(), m_Path, tResourcePath::Path(), pos, and tXmlParserNamespace::tXmlParser::ValidateXml().

00457                                                                                  {
00458     bool validated = tXmlParser::ValidateXml(docfd, uri, filepath);
00459 
00460     /* check filepath */
00461     if ( validated && filepath )
00462     {
00463         node root = GetRoot();
00464 
00465         if (!root) {
00466             con << "Empty document\n";
00467             return false;
00468         } else if (root.IsOfType("Resource")) {
00469             m_Path = tResourcePath (
00470                 root.GetProp("author"),
00471                 root.GetProp("category"),
00472                 root.GetProp("name"),
00473                 root.GetProp("version"),
00474                 root.GetProp("type"),
00475                 tString("xml"),
00476                 tString("")
00477             );
00478             tString rightFilepath( m_Path.Path() );
00479             tString pureFilepath( filepath );
00480             int pos;
00481             while((pos = pureFilepath.StrPos("//")) != -1) {
00482                 pureFilepath.RemoveSubStr(pos, 1);
00483             }
00484             tResourcePath purepath(pureFilepath);
00485             if ( purepath != m_Path )
00486             {
00487                 con << "\nWARNING: incorrect filepath. The resource wants to be at \"" << rightFilepath << "\", but was loaded from \"" << filepath << "\".\n\n";
00488             }
00489         }
00490         else {
00491             con << "Root node is not of type 'Resource' but '" << root.GetName() << "'.\n";
00492             return false;
00493         }
00494     }
00495 
00496     return validated;
00497 }

Here is the call graph for this function:

tXmlParser::node tXmlParserNamespace::tXmlResource::GetFileContents ( void   )  [protected]

Returns the node the "real" file contents are within.

Definition at line 499 of file tXmlParser.cpp.

References tXmlParserNamespace::tXmlParser::GetRoot().

00499                                                  {
00500     for(node cur = GetRoot().GetFirstChild(); cur; ++cur) {
00501         if(!cur.IsOfType("comment") && !cur.IsOfType("text")) {
00502             return cur;
00503         }
00504     }
00505     return 0;
00506 }

Here is the call graph for this function:


Member Data Documentation

tResourcePath tXmlParserNamespace::tXmlResource::m_Path [protected]

the resource identifier of this resource

Definition at line 149 of file tXmlParser.h.

Referenced by ValidateXml().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:05:29 2008 for Armagetron Advanced by  doxygen 1.5.4