13#ifndef ML_XMLPERSISTENCE_STREAM_H
14#define ML_XMLPERSISTENCE_STREAM_H
22#include <xercesc/dom/DOMElement.hpp>
23#include <xercesc/dom/DOMNode.hpp>
24#include <xercesc/util/XercesVersion.hpp>
41 : itemName(anItemName)
42 , suppressScope(aSuppressScope)
87 void writeString(
const char* name,
const std::string& value)
override;
89 void writeData(
const void* data,
size_t len,
const char* name)
override;
92 void startListImpl(
const char* name,
const char* xmlItemName,
bool xmlSuppressScope)
override;
111 template <
typename T>
void _writeValuesT(
const char* name,
const T* values,
size_t n,
bool fixedList);
114 void _setAttribute(
const char* attrName,
const char* value);
115 void _setAttribute(
const char* attrName,
int value);
119 void _createScope(
const char* tagName);
125 DOMElement* _rootNode;
127 DOMElement* _currentNode;
161 void readString(
const char* name, std::string& value)
override;
163 void readData(std::string& value,
const char* name)
override;
166 void startListImpl(
const char* name,
const char* xmlItemName,
bool xmlSuppressScope)
override;
178 void readValues(
const char* name,
size_t expected, std::vector<MLint32>& values)
override;
179 void readValues(
const char* name,
size_t expected, std::vector<MLuint32>& values)
override;
180 void readValues(
const char* name,
size_t expected, std::vector<MLint64>& values)
override;
181 void readValues(
const char* name,
size_t expected, std::vector<MLuint64>& values)
override;
182 void readValues(
const char* name,
size_t expected, std::vector<MLfloat>& values)
override;
183 void readValues(
const char* name,
size_t expected, std::vector<MLdouble>& values)
override;
191 template <
typename T>
void _readValuesT(
const char* name,
size_t expected, std::vector<T>& values);
194 bool _getAttribute(
const char* attrName, std::string& value);
195 bool _getAttribute(
const char* attrName,
int& value);
198 bool _checkElement(
const char* name,
bool throwError =
true);
201 void _toNextElement(
bool reset =
false);
204 void _enterScope(
const char* tagName);
210 DOMElement* _rootNode;
212 DOMElement* _currentNode;
214 DOMElement* _nextNode;
Class for writing object data to a stream.
Implementation for AbstractPersistenceOutputStream using Xerces DOM Parser.
virtual void writeToFile(const std::string &fileName)
Writes the complete tree to a file.
XMLPersistenceOutputStream()
this constructor creates a new XML document that can be written afterwards with writeToFile or writeT...
void writeValues(const char *name, const MLuint32 *values, size_t n, bool fixedList) override
void writeData(const void *data, size_t len, const char *name) override
Writes binary data to stream.
void writeValues(const char *name, const MLdouble *values, size_t n, bool fixedList) override
void endStructImpl() override
void writeValues(const char *name, const MLint32 *values, size_t n, bool fixedList) override
Abstract writing methods that need to be implemented by derived classes.
void startStructImpl(const char *name) override
bool isBinary() const override
overridden methods
virtual void writeToString(std::string &str)
Writes the subtree rooted by this node to a string.
void writeString(const char *name, const std::string &value) override
Abstract writing method that needs to be implemented by derived classes.
XMLPersistenceOutputStream(DOMElement *container)
this constructor takes an existing XML element - everything will be written relative to this element
virtual ~XMLPersistenceOutputStream()
this will free the XML document if the first constructor was used
void startListImpl(const char *name, const char *xmlItemName, bool xmlSuppressScope) override
Abstract methods called by above methods, needs to be implemented in derived classes.
void setObjectID(int id) override
Implementation of Base object persistence, sets attribute on currently open struct Implementation hin...
void writeValues(const char *name, const MLfloat *values, size_t n, bool fixedList) override
void writeValues(const char *name, const MLint64 *values, size_t n, bool fixedList) override
void endListImpl() override
void setObjectVersion(int version) override
Sets persistence version.
void setObjectType(const char *type) override
Sets base type.
void writeValues(const char *name, const MLuint64 *values, size_t n, bool fixedList) override
mix-in class that manages a stack of names for list elements and if the parent scope of the list is s...
std::list< ListStackEntry > _listStack
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
Custom deleters around Xerces resources with std::unique_ptr.
ListStackEntry(const char *anItemName, bool aSuppressScope)