AGX Dynamics  2.37.2.0
XMLOutputArchive.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 #ifdef _MSC_VER
21 # pragma warning( push )
22 # pragma warning( disable : 4290 )
23 #endif
24 
25 #include <agx/agxPhysics_export.h>
26 
27 
28 #include <string>
29 #include <sstream>
30 
31 #include <agx/byteswap.h>
33 
34 namespace agx
35 {
36  class TiXmlNode;
37  class TiXmlElement;
38  class TiXmlDocument;
39  class Uuid;
40 }
41 
42 
43 namespace agxStream
44 {
45 
52  {
53  public:
54 
61  XMLOutputArchive( std::ostream& outputStream ) ;
62  XMLOutputArchive( std::ostream& outputStream, ObjectToIdMapContext& mapCache );
63 
64 
65  virtual void write( char val ) ;
66  virtual void write( bool val ) ;
67  virtual void write( agx::UInt8 val ) ;
68  virtual void write( agx::Int8 val ) ;
69  virtual void write( agx::Int16 val ) ;
70  virtual void write( agx::UInt16 val ) ;
71 
72  virtual void write( agx::UInt32 val ) ;
73  virtual void write( agx::Int32 val ) ;
74 
75  virtual void write( agx::UInt64 val ) ;
76  virtual void write( agx::Int64 val ) ;
77  virtual void write( float val ) ;
78  virtual void write( double val ) ;
79 
80  virtual void write( const char* val ) ;
81  virtual void write( const std::string& val ) ;
82 
83  virtual void write( const agx::Vec3f& val ) ;
84  virtual void write( const agx::Vec3d& val ) ;
85  virtual void write( const agx::Uuid& val ) ;
86 
97  virtual void write( const void* buf, size_t len ) ;
98 
100 
101  virtual void beginSection( const char* title );
102  virtual void endSection( const char* title );
103 
104 
105  virtual void addAttribute(const char *name, bool value);
106  virtual void addAttribute(const char *name, const char* value);
107  virtual void addAttribute(const char *name, char value);
108  virtual void addAttribute(const char *name, agx::UInt8 value);
109  virtual void addAttribute(const char *name, agx::Int8 value);
110  virtual void addAttribute(const char *name, agx::UInt16 value);
111  virtual void addAttribute(const char *name, agx::UInt32 value);
112  virtual void addAttribute(const char *name, agx::Int32 value);
113  virtual void addAttribute(const char *name, agx::UInt64 value);
114  virtual void addAttribute(const char *name, float value);
115  virtual void addAttribute(const char *name, double value);
116  virtual void addAttribute(const char *name, const agx::Uuid& value);
117 
119  void close() { OutputArchive::close(); flush(); }
120  protected:
122  virtual ~XMLOutputArchive();
123 
124  void addString(const char *str);
125 
126  bool flush();
127 
128  // copy constructor and assignment operator prohibited
130  XMLOutputArchive& operator=( const XMLOutputArchive& );
131  //void createXMLNode( const char *value );
132 
133  private:
134 
135  agx::TiXmlDocument *m_document;
136  agx::TiXmlElement *m_element;
137  agx::TiXmlElement *m_parent;
138  agx::Int32 m_precision;
139 
140  std::stringstream m_stringBuf;
141 
142  };
144 
145 }
146 
147 #ifdef _MSC_VER
148 # pragma warning( pop )
149 #endif
int64_t Int64
Definition: Integer.h:46
int32_t Int32
Definition: Integer.h:45
uint8_t UInt8
Definition: Integer.h:38
agx::ref_ptr< XMLOutputArchive > XMLOutputArchiveRef
This struct is used to handle id-collisions when using incremental journal.
Definition: OutputArchive.h:76
void close()
Method for closing the archive, important to call this as it will flush the data to the outputstream...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
bool AGXPHYSICS_EXPORT write(const std::string &filename, const agxStream::Serializable *data)
Write a Serializable object to a file.
int8_t Int8
Definition: Integer.h:43
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
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
int16_t Int16
Definition: Integer.h:44
uint16_t UInt16
Definition: Integer.h:39
XML version of an OutputArchive (for storing serialized objects).
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
uint32_t UInt32
Definition: Integer.h:40
#define AGXCORE_EXPORT