AGX Dynamics  2.35.0.1
XMLInputArchive.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 
20 #include <agx/agxPhysics_export.h>
21 
22 #include <agxStream/InputArchive.h>
23 
24 #ifdef _MSC_VER
25 # pragma warning(push)
26 # pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y
27 #endif
28 
29 
30 namespace agx
31 {
32  class TiXmlDocument;
33  class TiXmlElement;
34  class TiXmlNode;
35 }
36 
37 namespace agxStream
38 {
39 
44  {
45  // copy constructor and assignment operator prohibited
46  XMLInputArchive( const XMLInputArchive& inputStream );
47 
48  XMLInputArchive& operator=( const XMLInputArchive& );
49 
50  public:
51 
56  XMLInputArchive( std::istream& inputStream );
57  XMLInputArchive(std::istream& inputStream, IdToObjectVector& idCache, IdToClassNameVector& nameCache);
58 
59 
60  using InputArchive::read;
61  virtual void read( char& val ) ;
62  virtual void read( bool& val ) ;
63  virtual void read( agx::Int8& val ) ;
64  virtual void read( agx::UInt8& val ) ;
65  virtual void read( agx::Int16& val ) ;
66  virtual void read( agx::UInt16& val ) ;
67 
68  virtual void read( agx::Vec3d& val ) ;
69  virtual void read( agx::Vec3f& val ) ;
70  virtual void read( agx::Uuid& val ) ;
71 
72  virtual void read( agx::UInt32& val ) ;
73  virtual void read( agx::Int32& val ) ;
74  virtual void read( std::string& val ) ;
75  virtual void read( agx::UInt64& val ) ;
76  virtual void read( agx::Int64& val ) ;
77  virtual void read( float& val ) ;
78  virtual void read( double& val ) ;
79 
80 
89  virtual void read(void * buf, size_t size);
90 
91  virtual size_t getNumBytesRead() const;
92 
93  virtual void beginSection( const char* title );
94  virtual void endSection( const char* title );
95 
96 
97 
98 
100 
101  virtual void getAttribute(const char *name, std::string& value);
102  virtual void getAttribute(const char *name, float& value);
103  virtual void getAttribute(const char *name, double& value);
104  virtual void getAttribute(const char *name, bool& value);
105  virtual void getAttribute(const char *name, char& value);
106  virtual void getAttribute(const char *name, agx::Int8& value);
107  virtual void getAttribute(const char *name, agx::UInt8& value);
108  virtual void getAttribute(const char *name, agx::UInt16& value);
109  virtual void getAttribute(const char *name, agx::UInt32& value);
110  virtual void getAttribute(const char *name, agx::Int32& value);
111  virtual void getAttribute(const char *name, agx::UInt64& value);
112  virtual void getAttribute(const char *name, agx::Uuid& value);
113 
114  protected:
116  virtual ~XMLInputArchive();
117 
118  void init();
119  agx::TiXmlElement* getElement( const char *variable );
120 
121  agx::TiXmlDocument *m_document;
122  //agx::TiXmlElement *m_element;
123  //agx::TiXmlElement *m_parent;
124 
125  struct StackElement {
126  agx::TiXmlNode *parent;
127  agx::TiXmlNode *prev;
128  agx::TiXmlNode *curr;
129 
130  StackElement(agx::TiXmlNode *parent_arg, agx::TiXmlNode *prev_arg, agx::TiXmlNode *element_arg) :
131  parent(parent_arg), prev(prev_arg), curr(element_arg)
132  {
133  agxAssert(parent);
134  }
135  };
137  std::stringstream m_stringBuf;
138  std::string m_currTitle;
139  agx::TiXmlElement *m_currentElement;
140  agx::TiXmlNode *m_lastNode;
141  };
143 
144 }
145 
146 #ifdef _MSC_VER
147 #ifdef _MSC_VER
148 # pragma warning(pop)
149 #endif
150 #endif
151 
#define AGXCORE_EXPORT
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
virtual void read(char &val)
XML version of an input archive for restoring data written with the XMLOutputArchive.
virtual void getAttribute(const char *name, agx::UInt64 &value)
virtual void read(char &val)
agx::String getErrorMessage(const agx::String &message)
agx::TiXmlDocument * m_document
agx::Vector< StackElement > m_sectionStack
virtual void read(agx::UInt16 &val)
virtual void getAttribute(const char *name, agx::Int8 &value)
virtual void getAttribute(const char *name, char &value)
virtual size_t getNumBytesRead() const
virtual void read(agx::Int32 &val)
virtual ~XMLInputArchive()
Destructor.
virtual void read(double &val)
virtual void read(agx::Uuid &val)
virtual void read(agx::Int8 &val)
virtual void getAttribute(const char *name, std::string &value)
virtual void getAttribute(const char *name, double &value)
virtual void getAttribute(const char *name, float &value)
virtual void read(void *buf, size_t size)
This method will read raw data from the archive.
virtual void read(agx::UInt32 &val)
virtual void getAttribute(const char *name, agx::Uuid &value)
std::stringstream m_stringBuf
virtual void getAttribute(const char *name, agx::Int32 &value)
XMLInputArchive(std::istream &inputStream)
Constructor creating a XMLInputArchive for reading XML streams.
virtual void getAttribute(const char *name, agx::UInt16 &value)
virtual void read(agx::UInt64 &val)
virtual void read(bool &val)
virtual void getAttribute(const char *name, agx::UInt8 &value)
agx::TiXmlElement * m_currentElement
virtual void read(agx::Int16 &val)
virtual void read(float &val)
virtual void getAttribute(const char *name, agx::UInt32 &value)
virtual void beginSection(const char *title)
agx::TiXmlElement * getElement(const char *variable)
virtual void read(std::string &val)
virtual void read(agx::Vec3d &val)
virtual void read(agx::Int64 &val)
virtual void getAttribute(const char *name, bool &value)
XMLInputArchive(std::istream &inputStream, IdToObjectVector &idCache, IdToClassNameVector &nameCache)
virtual void read(agx::Vec3f &val)
virtual void read(agx::UInt8 &val)
virtual void endSection(const char *title)
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:42
A class holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3Template.h:46
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define agxAssert(expr)
Definition: debug.h:143
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
agx::ref_ptr< XMLInputArchive > XMLInputArchiveRef
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint16_t UInt16
Definition: Integer.h:39
int32_t Int32
Definition: Integer.h:45
uint32_t UInt32
Definition: Integer.h:40
uint64_t UInt64
Definition: Integer.h:41
int64_t Int64
Definition: Integer.h:46
uint8_t UInt8
Definition: Integer.h:38
int8_t Int8
Definition: Integer.h:43
int16_t Int16
Definition: Integer.h:44
StackElement(agx::TiXmlNode *parent_arg, agx::TiXmlNode *prev_arg, agx::TiXmlNode *element_arg)