PLCnext API Documentation 23.6.0.37
XmlException.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Exceptions/CommonException.hpp"
9
10namespace Arp { namespace System { namespace Commons
11{
12
15{
16public: // construction/destruction
17 template<typename... Args>
18 XmlException(const char* message, const Args& ... args);
19 XmlException(const String& message);
20 XmlException(String&& message);
21 XmlException(const String& message, const Exception& innerException);
22 XmlException(String&& message, Exception&& innerException);
23 XmlException(const XmlException& arg) = default;
24 XmlException(XmlException&& arg) = default;
25 virtual ~XmlException(void) = default;
26
27public: // static factory methods
28 static XmlException Create(void);
29 static XmlException Create(const Exception& innerException);
30 template<typename... Args>
31 static XmlException Create(const char* filename, long lineNumber, const char* message, const Args& ... args);
32
33protected: // overridden operations
34 Exception::Ptr Clone(void)const override;
35
36private: // deleted methods
37 XmlException& operator=(const XmlException& arg) = delete;
38
39private:
40 static const char* const defaultMessage;
41 static const char* const fileLineMessage;
42};
43
45// inline methods of class XmlException
46
48template<typename... Args>
49inline XmlException::XmlException(const char* message, const Args& ... args)
50 : CommonException(ExceptionTypeId::Xml, String::Format(message, args...))
51{
52}
53
55inline XmlException::XmlException(const String& message)
56 : CommonException(ExceptionTypeId::Xml, message)
57{
58}
59
62 : CommonException(ExceptionTypeId::Xml, std::move(message))
63{
64}
65
67inline XmlException::XmlException(const String& message, const Exception& innerException)
68 : CommonException(ExceptionTypeId::Xml, message, innerException)
69{
70}
71
73inline XmlException::XmlException(String&& message, Exception&& innerException)
74 : CommonException(ExceptionTypeId::Xml, std::move(message), std::move(innerException))
75{
76}
77
80{
81 return XmlException(defaultMessage);
82}
83
85inline XmlException XmlException::Create(const Exception& innerException)
86{
87 return XmlException(String(defaultMessage), innerException);
88}
89
90template<typename... Args>
91inline XmlException XmlException::Create(const char* filename, long lineNumber, const char* message, const Args& ... args)
92{
93 return XmlException(String::Format(fileLineMessage, String::Format(message, args...), filename, lineNumber));
94}
95
96}}} // end of namesapce Arp::System::Commons
This is the base class of all Arp exception classes.
Definition: Exception.hpp:16
std::shared_ptr< Exception > Ptr
The smart pointer tpye of this class.
Definition: Exception.hpp:19
This is the base class of common exception classes.
Definition: CommonException.hpp:19
This exception is used for xml parsing errors.
Definition: XmlException.hpp:15
XmlException(const char *message, const Args &... args)
Constructs an XmlException instance.
Definition: XmlException.hpp:49
Exception::Ptr Clone(void) const override
Clones this instance.
static XmlException Create(void)
Creates an XmlException instance using a default message text.
Definition: XmlException.hpp:79
static SelfType Format(const SelfType &format, const Args &... args)
Formats the format string using the .NET/Python syntax with the given variadic arguments.
Definition: BasicString.hxx:1493
@ System
System components used by the System, Device, Plc or Io domains.
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:15
Root namespace for the PLCnext API
Namespace of the C++ standard library