Torque3D Documentation / _generateds / SimXMLDocument.h

SimXMLDocument.h

Engine/source/console/SimXMLDocument.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24//-----------------------------------------------------------------------------
 25// Console implementation of STL map.
 26//-----------------------------------------------------------------------------
 27
 28#ifndef _XMLDOC_H_
 29#define _XMLDOC_H_
 30
 31#ifndef _SIMBASE_H_
 32#include "console/simBase.h"
 33#endif
 34
 35#ifndef _TVECTOR_H_
 36#include "core/util/tVector.h"
 37#endif // _TVECTOR_H_
 38
 39
 40class TiXmlDocument;
 41class TiXmlElement;
 42class TiXmlAttribute;
 43
 44
 45class SimXMLDocument: public SimObject
 46{
 47   // This typedef is required for tie ins with the script language.
 48   // --------------------------------------------------------------------------
 49   protected:
 50      typedef SimObject Parent;
 51   // --------------------------------------------------------------------------
 52
 53   public:
 54      SimXMLDocument();
 55      ~SimXMLDocument();
 56
 57      // These are overloaded functions from SimObject that we handle for
 58      // tie in to the script language.  The .cc file has more in depth
 59      // comments on these.
 60      //-----------------------------------------------------------------------
 61      bool processArguments(S32 argc, ConsoleValueRef *argv);
 62      bool onAdd();
 63      void onRemove();
 64      static void initPersistFields();
 65      
 66      // Set this to default state at construction.
 67      void reset(void);
 68      
 69      // Read / write / parse XML.
 70      bool loadFile(const char* rFileName);
 71      bool saveFile(const char* rFileName);
 72      S32 parse(const char* rText);
 73      bool saveToString(String& str);
 74      
 75      // Clear XML document.
 76      void clear(void);
 77      
 78      // Get error description if it exists.
 79      const char* getErrorDesc(void) const;
 80      // Clear previously set error.
 81      void clearError(void);
 82
 83      // Push first/last child element onto element stack.
 84      bool pushFirstChildElement(const char* rName);
 85      // Convert top stack element into sibling with given name.
 86      bool nextSiblingElement(const char* rName);
 87      // push child element at index onto stack.
 88      bool pushChildElement(S32 index);
 89     // Get element value
 90     const char* elementValue();
 91      
 92      // Pop last element off of stack.
 93      void popElement(void);
 94
 95      // Get attribute from top element on element stack.
 96      const char* attribute(const char* rAttribute);
 97
 98     // Does the attribute exist in the current element
 99      bool attributeExists(const char* rAttribute);
100
101     // Obtain the name of the current element's first or last attribute
102     const char* firstAttribute();
103     const char* lastAttribute();
104
105     // Move through the current element's attributes to obtain their names
106     const char* nextAttribute();
107     const char* prevAttribute();
108
109      // Set attribute of top element on element stack.
110      void setAttribute(const char* rAttribute, const char* rVal);
111      // Set attributes of a simObject on top element of the stack.
112      void setObjectAttributes(const char* objectID);
113      
114      // Remove attribute with given name from top element on stack.
115      void removeAttribute(const char* rAttribute);
116      
117      // Create a new element and push it onto stack as a new level.
118      void pushNewElement(const char* rName);
119      // Create a new element and push it onto stack on current level.
120      void addNewElement(const char* rName);
121      // Write XML declaration to current level.
122      void addHeader(void);
123      // Write a XML comment to the current level.
124      void addComment(const char* comment);
125      // Read a comment from the current level at the specified index.
126      const char* readComment( S32 index );
127      // Write text to the current level.
128      void addText(const char* text);
129      // Retrieve text from the current level.
130      const char* getText();
131      // Remove Text
132      void removeText();
133      // Write data to the current level.
134      void addData(const char* text);
135      // Retrieve data from the current level.
136      const char* getData();
137      
138   private:
139      // Document.
140      TiXmlDocument* m_qDocument;
141      // Stack of nodes.
142      Vector<TiXmlElement*> m_paNode;
143     // The current attribute
144     TiXmlAttribute* m_CurrentAttribute;
145
146   public:
147      DECLARE_CONOBJECT(SimXMLDocument);
148};
149
150#endif // _XMLDOC_H_
151////EOF/////////////////////////////////////////////////////////////////////////
152