3#ifndef _aspose_system_exception_h_
4#define _aspose_system_exception_h_
6#include <system/details/is_forwarding_of.h>
7#include <system/object.h>
8#include <system/string.h>
9#include <system/shared_ptr.h>
10#include <system/runtime/serialization/streaming_context.h>
18namespace Runtime {
namespace Serialization {
19class SerializationInfo;
34class ExceptionWrapperHelper
39 class BaseTypeProvider
42 static typename T::BaseType Dummy;
43 using BaseType =
decltype(ExceptionWrapperHelper::BaseTypeProvider<T>::Dummy);
51class ASPOSECPP_SHARED_CLASS ExceptionWrapperBase :
public ExceptionWrapperType,
public std::exception
55 ASPOSECPP_SHARED_API ExceptionWrapperBase(std::nullptr_t);
59 ASPOSECPP_SHARED_API ExceptionWrapperBase(
const ExceptionPtr& ptr);
63 virtual ASPOSECPP_SHARED_API
const char* what() const noexcept override;
71 ASPOSECPP_SHARED_API
bool IsNull()
const;
76 ASPOSECPP_SHARED_API
bool operator == (
const ExceptionWrapperBase &e)
const;
80 ASPOSECPP_SHARED_API
bool operator == (
const std::nullptr_t)
const;
84 ASPOSECPP_SHARED_API
bool operator != (
const std::nullptr_t)
const;
89 ASPOSECPP_SHARED_API
bool Equals(
const ExceptionWrapperBase &e)
const;
102 ASPOSECPP_SHARED_API String ToString()
const;
115 using ExceptionBaseType =
typename ExceptionWrapperHelper::BaseTypeProvider<T>::BaseType;
127 static void*
operator new(std::size_t) =
delete;
128 static void*
operator new[](std::size_t) =
delete;
174 template <
typename ...Args,
175 typename = std::enable_if_t<
176 !System::Details::IsForwardingOf<
ExceptionPtr, Args...>::value &&
177 !System::Details::IsForwardingOf<ExceptionWrapper<T>, Args...>::value>>
182 std::forward<Args>(args)...
204struct ASPOSECPP_SHARED_CLASS CastResult<ExceptionWrapper<T>>
207 typedef ExceptionWrapper<T> type;
214class ASPOSECPP_SHARED_CLASS ExceptionWrapper<Details_Exception> :
public ExceptionWrapperBase
218 ASPOSECPP_SHARED_API
operator SharedPtr<Object>();
224 static ASPOSECPP_SHARED_API ExceptionWrapper<Details_Exception> NullException;
226 static void*
operator new(std::size_t) =
delete;
227 static void*
operator new[](std::size_t) =
delete;
234 ASPOSECPP_SHARED_API ExceptionWrapper(std::nullptr_t);
237 ASPOSECPP_SHARED_API ExceptionWrapper();
241 ASPOSECPP_SHARED_API ExceptionWrapper(
const ExceptionPtr& ptr);
245 ASPOSECPP_SHARED_API ExceptionWrapper(
const String& message);
250 ASPOSECPP_SHARED_API ExceptionWrapper(
const String &message,
const ExceptionWrapper<Details_Exception>& innerException);
260 ASPOSECPP_SHARED_API Details_Exception* operator->()
const;
264 [[noreturn]] ASPOSECPP_SHARED_API
void Throw()
const;
269 ASPOSECPP_SHARED_API ExceptionWrapper(Details_Exception* ptr);
310 virtual ASPOSECPP_SHARED_API
const char*
what() const noexcept;
314 [[noreturn]] virtual ASPOSECPP_SHARED_API
void DoThrow(const
ExceptionPtr& self) const;
319 MEMBER_FUNCTION_MAKE_OBJECT(
Details_Exception, CODEPORTING_ARGS(), CODEPORTING_ARGS());
324 MEMBER_FUNCTION_MAKE_OBJECT(
Details_Exception, CODEPORTING_ARGS(const
String& message), CODEPORTING_ARGS(message));
337 CODEPORTING_ARGS(const
System::
SharedPtr<
System::Runtime::Serialization::SerializationInfo>& info,
System::Runtime::Serialization::StreamingContext context),
338 CODEPORTING_ARGS(info, context)
347 mutable std::
string m_std_message;
350 mutable int32_t m_HResult;
354 virtual ASPOSECPP_SHARED_API
String ExtraDescription() const;
362 virtual ASPOSECPP_SHARED_API
String FullMessage(const
String& message) const;
378 T* exception = exception_wrapper.operator->();
379 if (exception ==
nullptr)
380 *stream <<
"nullptr";
391 if (exception !=
nullptr)
392 stream << exception->ToString();
402 if (exception !=
nullptr)
403 stream << exception->ToString();
413ASPOSECPP_SHARED_API
bool operator != (
const System::ExceptionWrapperBase& e1,
const System::ExceptionWrapperBase& e2);
418ASPOSECPP_SHARED_API
bool operator == (std::nullptr_t,
const System::ExceptionWrapperBase &e);
423ASPOSECPP_SHARED_API
bool operator != (std::nullptr_t,
const System::ExceptionWrapperBase &e);
Represents an exception. Never create instances of this class manually. Use the Exception class inste...
Definition: exception.h:277
virtual ExceptionWrapper< Details_Exception > get_InnerException() const
Returns a reference to the object representing the inner exception.
int32_t get_HResult() const
Returns a 32-bit integer value which is a HRESULT code associated with the exception reprsented by th...
virtual String get_Message() const
Returns the string containing the error destcription.
virtual ExceptionWrapper< Details_Exception > GetBaseException() const
Returns the copy of Exception object representing the inner-most exception.
virtual String get_StackTrace() const
Returns the string containing the stack trace.
virtual const char * what() const noexcept
Implements what() method which is called by ExceptionWrapper class. Despite of the fact that this cla...
void set_HResult(int32_t value)
Sets HRESULT, a coded numerical value that is assigned to a specific exception.
virtual String ToString() const override
Returns the string representation of the current object.
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:113
ExceptionWrapper & operator=(ExceptionWrapper &&other) noexcept
Move assignment operator.
Definition: exception.h:164
ExceptionWrapper(Args &&...args)
Constructor that forwards parameters to the Exception class constructors and creates smart pointer th...
Definition: exception.h:178
static const System::TypeInfo & Type()
Shortcut to get System::TypeInfo object for the Exception type.
Definition: exception.h:132
ExceptionWrapper(const ExceptionPtr &ptr)
Constructs a instance of ExceptionWrapper class that contains passed pointer.
Definition: exception.h:139
T ExceptionType
Used for casting functions.
Definition: exception.h:125
ExceptionWrapper(std::nullptr_t)
Constructs a null-instance of ExceptionWrapper class that does not represent any exception.
Definition: exception.h:135
ExceptionWrapper(const ExceptionWrapper &other)
Copy constructor.
Definition: exception.h:143
T * operator->() const
Allows to access members of the Exception object.
Definition: exception.h:191
ExceptionWrapper(ExceptionWrapper &&other) noexcept
Move constructor.
Definition: exception.h:147
ExceptionWrapper & operator=(const ExceptionWrapper &other)
Assignment operator.
Definition: exception.h:153
ExceptionWrapper(T *ptr)
Constructs a instance of ExceptionWrapper class that contains passed instance.
Definition: exception.h:199
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Dummy class to make StreamingContext-using translated classes compile. Do not manage instances of thi...
Definition: streaming_context.h:12
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a particular type and provides information about it.
Definition: type_info.h:109
@ Type
Returns a socket type.
ExceptionType
Definition: xml_convert.h:133
Definition: db_command.h:9
void PrintTo(DateTime value, std::ostream *stream)
Prints value to ostream. Mostly used for debug.
bool operator!=(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:157
SmartPtr< Y > static_pointer_cast(SmartPtr< X > const &x)
Casts smart pointers using static_cast.
Definition: smart_ptr.h:1669
bool Equals(const TA &a, const TB &b)
Determines the equality of two values applying operator==() to them.
Definition: primitive_types.h:77
std::enable_if<!IsSmartPtr< T >::value, SmartPtr< T > >::type MakeObject(Args &&... args)
Creates object on heap and returns shared pointer to it.
Definition: smart_ptr.h:1506
System::SmartPtr< Details_Exception > ExceptionPtr
Type alias used by exception wrappers.
Definition: exception.h:25
std::ostream & operator<<(std::ostream &stream, DateTime date_time)
Insert data into the stream using UTF-8 encoding.
Definition: date_time.h:729
std::enable_if< std::is_scalar< T >::value, int >::type GetHashCode(const T &obj)
Returns a hash code for the specified scalar value.
Definition: get_hash_code.h:21
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:151