AGX Dynamics  2.37.2.0
XMLInputArchive.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 
99  agx::String getErrorMessage( const agx::String& message );
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 
int64_t Int64
Definition: Integer.h:46
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
bool AGXPHYSICS_EXPORT read(const std::string &filename, agxStream::SerializablePtrVector &readObjects)
Open and read serializable objects from a file on disk with previously stored objects.
agx::ref_ptr< XMLInputArchive > XMLInputArchiveRef
int32_t Int32
Definition: Integer.h:45
agx::Vector< StackElement > m_sectionStack
agx::TiXmlElement * m_currentElement
uint8_t UInt8
Definition: Integer.h:38
agx::TiXmlDocument * m_document
StackElement(agx::TiXmlNode *parent_arg, agx::TiXmlNode *prev_arg, agx::TiXmlNode *element_arg)
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::stringstream m_stringBuf
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
int8_t Int8
Definition: Integer.h:43
XML version of an input archive for restoring data written with the XMLOutputArchive.
#define agxAssert(expr)
Definition: debug.h:143
A class holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3Template.h:45
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
uint64_t UInt64
Definition: Integer.h:41
int16_t Int16
Definition: Integer.h:44
uint16_t UInt16
Definition: Integer.h:39
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
uint32_t UInt32
Definition: Integer.h:40
#define AGXCORE_EXPORT