PLCnext API Documentation 25.0.2.69
InvalidCastException.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7#ifndef ARP_USE_ARP_SYSTEM_COMMONS_EXCEPTIONS
8#include "Arp/Base/Commons/Exceptions/InvalidCastException.hpp"
9namespace Arp
10{
12}
13#else
14#include "Arp/System/Core/Arp.h"
15#include "Arp/System/Commons/Exceptions/CommonException.hpp"
16
17namespace Arp { namespace System { namespace Commons
18{
19
21class InvalidCastException : public CommonException
22{
23public: // construction/destruction
24 template<typename... Args>
25 InvalidCastException(const char* message, const Args& ... args);
26 InvalidCastException(const String& message);
27 InvalidCastException(String&& message);
28 InvalidCastException(const String& message, const Exception& innerException);
29 InvalidCastException(String&& message, Exception&& innerException);
30 InvalidCastException(const InvalidCastException& arg) = default;
31 InvalidCastException(InvalidCastException&& arg) = default;
32 virtual ~InvalidCastException(void) = default;
33
34protected: // overridden operations
35 Exception::Ptr Clone(void)const override;
36
37private: // deleted methods
38 InvalidCastException& operator=(const InvalidCastException& arg) = delete;
39};
40
42// inline methods of class InvalidCastException
43
45template<typename... Args>
46inline InvalidCastException::InvalidCastException(const char* message, const Args& ... args)
47 : CommonException(ExceptionTypeId::InvalidCast, String::Format(message, args...))
48{
49}
50
52inline InvalidCastException::InvalidCastException(const String& message)
53 : CommonException(ExceptionTypeId::InvalidCast, message)
54{
55}
56
58inline InvalidCastException::InvalidCastException(String&& message)
59 : CommonException(ExceptionTypeId::InvalidCast, std::move(message))
60{
61}
62
64inline InvalidCastException::InvalidCastException(const String& message, const Exception& innerException)
65 : CommonException(ExceptionTypeId::InvalidCast, message, innerException)
66{
67}
68
70inline InvalidCastException::InvalidCastException(String&& message, Exception&& innerException)
71 : CommonException(ExceptionTypeId::InvalidCast, std::move(message), std::move(innerException))
72{
73}
74
75}}} // end of namesapce Arp::System::Commons
76
78// template specialization of InvalidCastException formatter
79template<> struct fmt::formatter<Arp::System::Commons::InvalidCastException> : public fmt::ostream_formatter {};
80
81#endif // ndef ARP_USE_ARP_SYSTEM_COMMONS_EXCEPTIONS
This exception is thrown when an invalid cast occurs.
Definition: InvalidCastException.hpp:17
InvalidCastException(const char *message, const Args &... args)
Creates an InvalidCastException with message.
Definition: InvalidCastException.hpp:68
std::unique_ptr< Exception > Ptr
The smart pointer type of this class.
Definition: Exception.hpp:27
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