8 #include "Arp/System/Core/Enum.hxx"     9 #include "Arp/System/Core/TypeName.hxx"    10 #include "Arp/System/Commons/Chrono/Duration.hpp"    11 #include "Arp/System/Commons/Exceptions/Exceptions.h"    12 #include "Arp/System/Commons/Xml/XmlErrorHandler.hpp"    13 #include "Arp/System/Commons/Xml/XmlNodeType.hpp"    16 #include "boost/lexical_cast.hpp"    18 namespace Arp { 
namespace System { 
namespace Commons { 
namespace Xml
   299         if (TryGetAttributeValue<T>(attributeName, returnValue))
   306                 "GetAttributeValue failed for mandatory attribute: {0} elementName: {1}",
   327         if (TryGetAttributeValueEnum<T>(attributeName, returnValue))
   334                 "GetAttributeValueEnum failed for mandatory attribute: {0} elementName: {1}",
   356         char* charValue = GetAttributeValueInternal(attributeName);
   357         if (charValue == 
nullptr)
   363         FreeInternalAttributeValue(charValue);
   387         value = defaultValue;
   388         return TryGetAttributeValueEnum<T>(attributeName, value);
   409         if (TryGetAttributeValueDuration<T>(attributeName, returnValue))
   416                 "GetAttributeValueDuration failed for mandatory attribute: {0} elementName: {1}",
   436         char* charValue = GetAttributeValueInternal(attributeName);
   439         if (charValue == 
nullptr)
   444         bool result = Chrono::Duration::TryParse(charValue, tempDurationValue);
   445         tempDurationValue.GetDuration(value);
   447         FreeInternalAttributeValue(charValue);
   471         value = defaultValue;
   472         return TryGetAttributeValueDuration<T>(attributeName, value);
   492         char* charValue = 
nullptr;
   495             charValue = GetAttributeValueInternal(attributeName);
   496             if (charValue == 
nullptr)
   505             value = boost::lexical_cast<T>(charValue);
   506             FreeInternalAttributeValue(charValue);
   509         catch (boost::bad_lexical_cast&)
   512             String strValue(charValue);
   513             FreeInternalAttributeValue(charValue);
   514             throw XmlException(
"Cast of attribute {0} to {1} failed value: {2}", attributeName,
   541         value = defaultValue;
   542         return TryGetAttributeValue<T>(attributeName, value);
   545     void EnableValidationException();
   546     void DisableValidationException();
   557     template<
typename... Args>
   564     char* GetAttributeValueInternal(
const char* attributeName);
   565     void FreeInternalAttributeValue(
char* attributeValue);
   569     XmlNodeType MoveToContent();
   570     void EnableValidation(
const String& xsdFile);
   571     void CheckForValidationException();
   577     bool validationEnabled;
   579     bool exceptionOnValidationError; 
   582     bool startElementRead;
   606 template<
typename... Args>
   614     return this->filename;
 bool TryGetAttributeValueEnum(const char *attributeName, Enum< T > &value)
trys reads an attribute value from the current element and converts the String to Enum<T> ...
Definition: XmlReader.hpp:354
 
T ReadElementContent()
reads the content of the current element if a CDATA section is found, the CDATA enclosure is removed ...
Definition: XmlReader.hpp:279
 
bool MoveToElement()
Moves the position of the current instance to the node that contains the current Attribute node...
 
XmlException CreateException(const char *message, const Args &... args)
Creates an exception by prefixing the given message with current doc name and line number ...
Definition: XmlReader.hpp:607
 
This (meta programming) class provides the C++ typename of the as template argument passed type...
Definition: TypeName.hxx:55
 
bool TryReadEndElement(void)
tries to read until the next end element is reached skips over an empty element 
 
bool Read()
Reads to the next element inside the xml file 
 
bool TryReadStartElement(const char *elementName=nullptr)
trys to read the next element and test if this is a start element with the given name ...
 
static Enum Parse(const char *input)
Parses the given input string.
Definition: Enum.hxx:190
 
bool ReadToDescendant(const String &name)
reads the xml file until an element with name is reached or the current element is closed reads to th...
 
T GetAttributeValueDuration(const char *attributeName)
reads an attribute value from the current element and converts the String to std::chrono::duration i...
Definition: XmlReader.hpp:405
 
const String & GetDocumentFileName()
Gets the current document filename of this XML reader 
Definition: XmlReader.hpp:612
 
bool TryGetAttributeValue(const char *attributeName, T &value)
tries to read an attribute value from the current element 
Definition: XmlReader.hpp:490
 
static XmlReader Create(const String &filename)
Creates a new Instance of the XmlReader 
 
long GetLineNumber()
Gets the actual line number of this XML reader 
 
bool TryGetAttributeValue(const char *attributeName, T defaultValue, T &value)
tries to read an attribute value from the current element if the attribute was not found or the conve...
Definition: XmlReader.hpp:538
 
Adapter class for enums to make them loggable and parsable from e.g. XML files.
Definition: Enum.hxx:23
 
internal base class to handle xml parsing errors in XmlReader
Definition: XmlErrorHandler.hpp:14
 
~XmlReader(void)
Destructs this instance and frees all resources.
 
static XmlException Create(void)
Creates an XmlException instance using a default message text.
Definition: XmlException.hpp:79
 
static bool TryCreate(const String &filename, XmlReader &reader)
Tries to creates a new Instance of the XmlReader 
 
static XmlReader CreateForString(const String &buffer)
Creates a new Instance of the XmlReader reading from an in memory buffer 
 
Definition: Duration.hpp:17
 
String ReadElementContent(void)
reads the content of the current element if a CDATA section is found, the CDATA enclosure is removed ...
 
bool IsEmptyElement()
test if the current element is an empty element 
 
bool SkipElement()
skips the current element with its whole subtree 
 
T GetAttributeValue(const char *attributeName)
reads an attribute value from the current element 
Definition: XmlReader.hpp:296
 
void ReadEndElement(void)
reads until the next end element is reached skips over an empty element 
 
bool Skip()
skips the current element with its whole subtree (use SkipElement() because naming is more clear) ...
 
std::uint8_t uint8
The Arp unsigned integer type of 1 byte size.
Definition: PrimitiveTypes.hpp:27
 
Root namespace for the PLCnext API
 
This exception is used for xml parsing errors.
Definition: XmlException.hpp:14
 
XmlNodeType GetCurrentNodeType()
gets the type of the current xml element 
 
Class to read an XML File. Non buffered reader, can only read forward
Definition: XmlReader.hpp:22
 
String GetElementLocalName(void)
Reads the local name of the current active element 
 
bool TryGetAttributeValueDuration(const char *attributeName, T &value)
trys reads an attribute value from the current element and converts the String to std::chrono::durati...
Definition: XmlReader.hpp:434
 
int GetCurrentDepth()
gets the current depth of the current element inside the xml document 
 
bool ReadToNextSibling(const String &name)
reads to the next element with name which is a sibling of the current element 
 
std::int8_t int8
The Arp integer type of 1 byte size.
Definition: PrimitiveTypes.hpp:29
 
void ReadStartElement(const char *elementName=nullptr)
reads to the next element and test if this is a start element with the given name ...
 
bool ReadToFollowing(const String &name)
reads the xml file until an element with name is reached or end of file is reached ...
 
System components used by the System, Device, Plc or Io domains.
 
XmlReader(void)
Default contructor.
 
bool TryGetAttributeValueDuration(const char *attributeName, T defaultValue, T &value)
tries to read an attribute value from the current element as std::crono::duration if the attribute wa...
Definition: XmlReader.hpp:469
 
Enum< T > GetAttributeValueEnum(const char *attributeName)
reads an attribute value from the current element and converts the String to Enum<T> ...
Definition: XmlReader.hpp:323
 
bool SkipElementContent()
skips the content of current element with its whole subtree but does not read end element tag ...
 
bool TryGetAttributeValueEnum(const char *attributeName, T defaultValue, Enum< T > &value)
tries to read an attribute value from the current element as enum if the attribute was not found or t...
Definition: XmlReader.hpp:385