PLCnext API Documentation 25.0.2.69
InvalidCastException.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Core/PimplPtr.hxx"
9#include "Arp/Base/Commons/Exceptions/CommonExceptionBase.hpp"
10
11namespace Arp::Base::Commons::Exceptions
12{
13
16class ARP_BASE_COMMONS_EXPORT InvalidCastException : public CommonExceptionBase
17{
18public: // Impl forward declaration
19 class Impl;
20
21public: // construction/destruction/assignment
22 template<typename... Args>
23 explicit InvalidCastException(const char* message, const Args& ... args);
25 InvalidCastException(const String& message);
26 InvalidCastException(String&& message, const Exception& innerException);
27 InvalidCastException(const String& message, const Exception& innerException);
28 // canonical construction/destruction/assignment
33 ~InvalidCastException(void)override;
34
35protected: // construction
36 InvalidCastException(ExceptionTypeId typeId, String&& message, StackCounter stackCounter);
37
38public: // static factory operations
39 static InvalidCastException Create(const String& message);
40
41public: // internal operations
42 Impl& GetImpl(void);
43 const Impl& GetImpl(void)const;
44
45protected: // overridden operations
46 Exception::Ptr Clone(void)const override;
47
48private: // static factory methods
49 static InvalidCastException CreateImpl(const String& message, StackCounter stackCounter);
50
51private: // Impl usings
53
54private: // Impl fields
55 Pimpl pimpl;
56};
57
59// inline methods of class ArgumentException
60
67template<typename... Args>
68inline InvalidCastException::InvalidCastException(const char* message, const Args& ... args)
69 : InvalidCastException(ExceptionTypeId::InvalidCast, String::Format(message, args...), StackCounter())
70{
71}
72
73} // end of namespace Arp::Base::Commons::Exceptions
74
75namespace Arp {
76// Import exception into Arp namespace as Arp::System::Commons library does
78} // end of namespace Arp
80// template specialization of InvalidCastException formatter
81template<> struct fmt::formatter<Arp::Base::Commons::Exceptions::InvalidCastException> : public fmt::ostream_formatter {};
This class serves as base class for all Arp commons exceptions.
Definition: CommonExceptionBase.hpp:24
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
InvalidCastException(InvalidCastException &&arg) noexcept
Default move constructor.
InvalidCastException & operator=(InvalidCastException &&arg) noexcept
Default move-assignment operator.
InvalidCastException & operator=(const InvalidCastException &arg)
Default copy-assignment operator.
~InvalidCastException(void) override
Default destructor.
InvalidCastException(const InvalidCastException &arg)
Default copy constructor.
This class is used to count sequenced operation calls, which are e.g. invoked during an exception thr...
Definition: StackCounter.hpp:20
This is the base class of all Arp exception classes.
Definition: Exception.hpp:21
std::unique_ptr< Exception > Ptr
The smart pointer type of this class.
Definition: Exception.hpp:27
Adapter class to implement PImpl idiom.
Definition: PimplPtr.hxx:15
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
@ Create
Creates a new file. If the file already exists, it is overwritten.
ExceptionTypeId
Specifies the type id of any exception derived by <see cref="CommonException".
Definition: ExceptionTypeId.hpp:15
Root namespace for the PLCnext API