PLCnext API Documentation 23.6.0.37
XmlConfigDocument.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Xml/IXmlSerializable.hpp"
9#include "Arp/System/Commons/Xml/XmlSerializationContext.hpp"
10#include "Arp/System/Commons/Configuration/ConfigSettings.hpp"
11
12namespace Arp { namespace System { namespace Commons { namespace Xml
13{
14
15// forwards
16class MultiXmlConfigDocument;
17
18// TContent policy: implement IXmlSerializable and default contructable
21{
22 friend class XmlSerializationContext;
23
24public: // construction/destruction
28 XmlConfigDocument(const String& documentXmlElementName, IXmlSerializable& content);
32 virtual ~XmlConfigDocument(void) = default;
33
34public: // setter/getter operations
36 const String& GetPath(void)const;
42 Version GetRecentVersion(void)const;
43
44public: // operations
46 void Load(const String& documentPath);
49 bool TryLoad(const String& documentPath);
51 void Save(const String& documentPath);
54 void Save(const String& documentPath, bool syncFilesystem);
58 void Save(const String& documentPath, bool syncFilesystem, const Version& schemaVersion);
60 void Save(void);
63 void Save(bool syncFilesystem);
65 void LoadString(const String& xmlContent);
66
67protected: // virtual methods to override
68 virtual void ReadDocument(XmlReader& reader);
69
70private: // deleted methods
72 XmlConfigDocument(const XmlConfigDocument& arg) = delete;
74 XmlConfigDocument& operator=(const XmlConfigDocument& arg) = delete;
75
76protected: // fields
77 MultiXmlConfigDocument* pRootDoc;
78 IXmlSerializable& content;
79 String documentXmlElementName;
80 String path;
81 Version recentVersion;
82};
83
85// inline methods of class XmlConfigDocument
86
87inline const String& XmlConfigDocument::GetPath(void)const
88{
89 return this->path;
90}
91
93{
94 return this->content;
95}
96
98{
99 return this->pRootDoc;
100}
101
102inline Version XmlConfigDocument::GetRecentVersion()const
103{
104 return this->recentVersion;
105}
106
108{
109 this->Save(true);
110}
111
112}}}} // end of namespace Arp::System::Commons::Xml
This class represents the version of a special SDK or Arp build.
Definition: BasicVersion.hpp:36
Interface for all classes which should be serializable for xml
Definition: IXmlSerializable.hpp:18
special version of XmlConfigDocument to include xml configuration data from other xml files inside a ...
Definition: MultiXmlConfigDocument.hpp:26
Class handle xml configuration documents
Definition: XmlConfigDocument.hpp:21
virtual ~XmlConfigDocument(void)=default
Destructs this instance and frees all resouces.
XmlConfigDocument(const String &documentXmlElementName, IXmlSerializable &content)
Constructs an XmlConfigDocument instance.
MultiXmlConfigDocument * GetRootDocument(void)
summary>Returns the recend implemented schema version, used by XmlSerializationContext
Definition: XmlConfigDocument.hpp:97
const String & GetPath(void) const
Returns the path to the current file loaded by this document
Definition: XmlConfigDocument.hpp:87
void Load(const String &documentPath)
Loads the document from specified <paramref="documentPath"/>
bool TryLoad(const String &documentPath)
summary>saves the content xml encoded to documentPath with filesystem sync
void Save(const String &documentPath, bool syncFilesystem)
XmlConfigDocument(MultiXmlConfigDocument &rootDocument, IXmlSerializable &content)
Constructs an XmlConfigDocument instance.
void Save(void)
Definition: XmlConfigDocument.hpp:107
void Save(const String &documentPath, bool syncFilesystem, const Version &schemaVersion)
summary>saves the content xml encoded to the file the document was loaded from with filesystem sync
void Save(const String &documentPath)
void Save(bool syncFilesystem)
summary>Loads the document from a string
IXmlSerializable & GetContent(void)
summary>Returns a pointer to the root document for MultiXmlConfigDocument
Definition: XmlConfigDocument.hpp:92
Class to read an XML File. Non buffered reader, can only read forward
Definition: XmlReader.hpp:25
XML context used during XML reading and writing to hold the context information
Definition: XmlSerializationContext.hpp:26
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API