AGXDynamics  2.35.0.2
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 
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 
agxPhysics_export.h
agx::UInt64
uint64_t UInt64
Definition: Integer.h:41
AGXCORE_EXPORT
#define AGXCORE_EXPORT
agxStream::XMLInputArchive::m_sectionStack
agx::Vector< StackElement > m_sectionStack
Definition: XMLInputArchive.h:136
agx::Int16
int16_t Int16
Definition: Integer.h:44
InputArchive.h
agx::Vector< std::string >
agxStream::XMLInputArchive
XML version of an input archive for restoring data written with the XMLOutputArchive.
Definition: XMLInputArchive.h:43
agxStream::XMLInputArchive::m_currentElement
agx::TiXmlElement * m_currentElement
Definition: XMLInputArchive.h:139
agxAssert
#define agxAssert(expr)
Definition: debug.h:143
agxStream::XMLInputArchiveRef
agx::ref_ptr< XMLInputArchive > XMLInputArchiveRef
Definition: XMLInputArchive.h:142
agxStream::XMLInputArchive::StackElement::parent
agx::TiXmlNode * parent
Definition: XMLInputArchive.h:126
agx::VectorPOD< Serializable * >
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agxStream::XMLInputArchive::m_lastNode
agx::TiXmlNode * m_lastNode
Definition: XMLInputArchive.h:140
agxStream::XMLInputArchive::StackElement::curr
agx::TiXmlNode * curr
Definition: XMLInputArchive.h:128
agxStream::InputArchive::read
virtual void read(char &val)
agx::UInt16
uint16_t UInt16
Definition: Integer.h:39
agxStream::XMLInputArchive::StackElement
Definition: XMLInputArchive.h:125
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agx::UInt8
uint8_t UInt8
Definition: Integer.h:38
agxStream::XMLInputArchive::m_document
agx::TiXmlDocument * m_document
Definition: XMLInputArchive.h:121
agxStream::XMLInputArchive::m_currTitle
std::string m_currTitle
Definition: XMLInputArchive.h:138
agx::Int8
int8_t Int8
Definition: Integer.h:43
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agxStream::XMLInputArchive::StackElement::prev
agx::TiXmlNode * prev
Definition: XMLInputArchive.h:127
agxStream::read
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.
agxStream
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
Definition: ElementaryConstraint.h:31
agx::Int64
int64_t Int64
Definition: Integer.h:46
agx::AgXString< std::string >
agx::init
void AGXPHYSICS_EXPORT init()
Initialize agx.
agx::Vec3T
A class holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3Template.h:45
agx::Uuid
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
agxStream::XMLInputArchive::m_stringBuf
std::stringstream m_stringBuf
Definition: XMLInputArchive.h:137
agxStream::XMLInputArchive::StackElement::StackElement
StackElement(agx::TiXmlNode *parent_arg, agx::TiXmlNode *prev_arg, agx::TiXmlNode *element_arg)
Definition: XMLInputArchive.h:130
agx::Int32
int32_t Int32
Definition: Integer.h:45
agx::UInt32
uint32_t UInt32
Definition: Integer.h:40