15 BEGIN_NAMESPACE_SERIALIZATION
18 using LibXmlNodePtr = std::shared_ptr<LibXmlNode>;
28 using DxNodePtr = Dewesoft::Utils::Serialization::DxNodePtr;
43 LibXmlNode(
const std::string& name,
const std::string& value);
48 LibXmlNode(
const std::string& name,
const std::string& value,
bool write);
65 NodePtr
updateChild(
const std::string& childName)
override;
72 NodePtr
readChild(
const std::string& childName)
override;
80 NodePtr
createNode(std::string name, std::string value)
override;
99 void setValue(std::string value)
override;
106 NodePtr
addChild(std::string name)
override;
113 NodePtr
addChild(
const NodePtr& childNode)
override;
119 NodePtr
clone()
override;
157 NodePtr
getAttribute(
const size_t attributeIndex)
override;
164 NodePtr
getChild(
const size_t childIndex)
override;
200 void removeChild(
const std::string& childName)
override;
206 void removeChild(
const size_t childIndex)
override;
218 std::string
getName()
override;
266 void saveToFile(
const std::string& fileName)
override;
272 void readFromFile(
const std::string& fileName)
override;
286 LibXmlNode(
const DxNodePtr& node,
bool xmlUpdateType);
287 LibXmlNode(
const DxNodePtr& node,
bool xmlUpdateType,
bool isDummyNode);
290 DxNodePtr node =
nullptr;
291 bool isWriteUpdateType =
true;
293 DxNodePtr getInternalNode()
const;
295 void internalWrite(
const std::string& name,
const std::string& value,
const std::string& defaultValue)
override;
296 void internalRead(
const std::string& name, std::string& value,
const std::string& defaultValue)
override;
297 void internalAddAttribute(
const std::string& name,
const std::string& value)
override;
299 DxNodePtr convertNodeToDxNode(
const NodePtr& inputNode);
300 void buildDxNodeTreeFromInputNode(
const NodePtr& inputNode,
const DxNodePtr& outputNode);
301 void copyInputNodeAttributesToDxNode(
const NodePtr& inputNode,
const DxNodePtr& outputNode);
303 NodePtr addUniqueChild(
const std::string& name)
override;
306 END_NAMESPACE_SERIALIZATION
NodePtr findChildNode(const std::string &name) override
findChildNode finds a child node with a given name and returns a pointer to it or nullptr if not foun...
NodePtr readChild(const std::string &childName) override
readChild function finds a node child with a given name
SerializableNode is an abstract class that defines functions for writing/reading to/from a custom fil...
Definition: serializable_node.h:19
std::string getName() override
getName returns a name of a node.
bool isEmpty() override
isEmpty returns true if node does not have any children, attributes and if it does not have any value...
bool isInitialized() override
isInitialized returns true if node is initialized or false otherwise.
void clearChildNodes() override
clearChildNodes clears all child nodes.
std::string getValue() override
getValue returns a value of a node.
void updateOperation(bool write) override
updateOperation sets a node update operation (node can be used either for writing or reading)...
NodePtr getNextSibling() override
getNextSibling returns a sibling of a node or nullptr if it does not exist.
void removeAttribute(const std::string &attributeName) override
removeAttribute removes all attributes with a given name from a node.
NodePtr clone() override
clone function creates a clone of a node.
LibXmlNode is a class that inherits from Node and SerializableNode.
Definition: libxml_node.h:25
LibXmlNode()
LibXmlNode constructor that initializes a node with a 'RootNode' default name.
NodePtr addChild(std::string name) override
addChild function creates and adds a child with a given name to a node and returns a pointer to it...
SerializableNode is an abstract class that defines functions for writing/reading to/from a custom fil...
NodePtr getChild(const size_t childIndex) override
getChild returns a child with a given index or nullptr if index is invalid.
void write(const std::string &name, const T &value)
write function creates a new child with a given name and adds a given value to it.
Definition: node.h:393
NodePtr getAttribute(const size_t attributeIndex) override
getAttribute returns an attribute with a given index or nullptr if index is invalid.
void destroy() override
destroy function releases internal node and sets it value to nullptr.
void setValue(std::string value) override
setValue function sets a given value to a node.
void saveToStream(std::ostream &outStream) override
saveToStream saves an internal node to a given ostream.
void readFromFile(const std::string &fileName) override
readFromFile reads and builds an internal node from a given file.
NodePtr addAttributeNode(const NodePtr &attributeNode) override
addAttributeNode adds a given attribute node to a node and returns a pointer to it.
void removeChild(const std::string &childName) override
removeChild removes all children with a given name from a node.
size_t getAttributeCount() override
getAttributeCount returns a number of attributes of a node.
size_t getChildCount() override
getChildCount returns a number of children of a node.
void initializeNode(std::string name, std::string value) override
initializeNode function initializes a Node with a given name and given value.
void readFromStream(std::istream &inStream) override
readFromStream reads and builds an internal node from a given istream.
bool isWrite() override
isWrite returns true if node should be used for writing or false otherwise.
NodePtr createNode(std::string name, std::string value) override
createNode function creates a new Node and returns a pointer to it.
void clearAttributeNodes() override
clearAttributeNodes clears all attribute nodes.
DxNode class defines an internal xml node and implements functions for creating, modifying and removi...
void saveToFile(const std::string &fileName) override
saveToFile saves an internal node to a given file.
NodePtr findAttributeNode(const std::string &name) override
findAttributeNode finds an attribute node with a given name and returns a pointer to it or nullptr if...
NodePtr updateChild(const std::string &childName) override
updateChild function creates or finds a node child with a given name based on update type ...