5#include <system/object_type.h>
6#include <system/enum.h>
7#include <system/boxed_enum.h>
8#include <system/text/string_builder.h>
9#include <system/details/pointer_collection_helpers.h>
10#include <system/get_hash_code.h>
12namespace System {
namespace Collections {
class IList; } }
30 return System::GetHashCode<T>(obj);
33 template<
typename T,
typename T2>
34 static typename std::enable_if<IsExceptionWrapper<T>::value,
bool>::type
Equals(
const T& obj,
const T2& another)
37 System::Detail::SmartPtrCounter::ThrowNullReferenceException();
38 return obj.Equals(another);
48 template<
typename T,
typename T2>
49 static typename std::enable_if<IsSmartPtr<T>::value,
bool>::type
Equals(
const T& obj,
const T2& another)
51 return obj->Equals(another);
61 template<
typename T,
typename T2>
62 static typename std::enable_if<!IsExceptionWrapper<T>::value && !
IsSmartPtr<T>::value && !std::is_scalar<T>::value,
bool>::type
Equals(T obj,
const T2& another)
64 return obj.Equals(another);
74 template<
typename T,
typename T2>
75 static typename std::enable_if<!IsSmartPtr<T>::value && std::is_scalar<T>::value,
bool>::type
Equals(
const T& obj,
const T2& another)
77 return (obj == another);
89 return another == obj;
116 static typename std::enable_if<std::is_enum<T>::value,
String>::type
ToString(
const T& obj)
127 static typename std::enable_if<IsSmartPtr<T>::value,
String>::type
ToString(
const T& obj)
129 return obj->ToString();
139 return obj->ToString();
147 static typename std::enable_if<!IsSmartPtr<T>::value && std::is_scalar<T>::value && !std::is_enum<T>::value,
String>::type
ToString(T& obj)
157 static typename std::enable_if<!IsSmartPtr<T>::value && std::is_scalar<T>::value && !std::is_enum<T>::value,
String>::type
ToString(T&& obj)
169 return obj.ToString();
176 template <
typename T>
179 return obj.ToString();
189 return obj.ToString();
200 return System::MakeObject<BoxedEnum<T>>(value);
211 return System::MakeObject<BoxedValue<T>>(value);
221 if (value ==
nullptr)
224 return System::MakeObject<BoxedValue<typename T::ValueType>>(value.get_Value());
235 using UT =
typename std::underlying_type<T>::type;
239 auto boxed = obj.template Cast<BoxedEnum<T>>();
240 return static_cast<T
>(boxed->unbox());
242 using UT =
typename std::underlying_type<T>::type;
243 if (obj && obj->
Is(ObjectExt::GetType<UT>()))
246 return static_cast<T
>(boxed->unbox());
250 throw InvalidCastException();
263 if (obj->
Is(ObjectExt::GetType<T>()))
265 auto boxed = obj.template Cast<BoxedValue<T>>();
266 return boxed->unbox();
269 throw InvalidCastException();
271 throw NullReferenceException();
285 auto boxed = obj.template Cast<BoxedValue<T>>();
286 return boxed->unbox();
289 throw InvalidCastException();
297 template<
class T,
class E>
298 static typename std::enable_if<std::is_enum<E>::value && std::numeric_limits<T>::is_integer, T>::type
Unbox(E e)
300 return static_cast<T
>(e);
308 template<
class T,
class E>
309 static typename std::enable_if<std::is_enum<E>::value && std::is_enum<T>::value, T>::type
Unbox(E e)
311 return static_cast<T
>(e);
330 if (obj->
Is(ObjectExt::GetType<T>()))
332 auto boxed = obj.template Cast<BoxedValue<T>>();
340 throw InvalidCastException();
349 template<
class T,
class U>
350 static typename std::enable_if<std::is_convertible<T, Object>::value && std::is_final<T>::value &&
352 bool>::type
Is(
const U& obj)
357 return typeid(*obj.get()) ==
typeid(T);
366 template<
class T,
class U>
367 static typename std::enable_if<std::is_convertible<T, Object>::value&& !std::is_final<T>::value &&
369 bool>::type
Is(
const U& obj)
374 return dynamic_cast<T*
>(obj.get()) !=
nullptr;
383 static typename std::enable_if<std::is_convertible<T, Object>::value,
386 return obj.
Is(T::Type());
395 static typename std::enable_if<!std::is_convertible<T, Object>::value,
406 template<
class T,
class U>
407 static typename std::enable_if<IsSmartPtr<T>::value,
bool>::type
Is(
const SmartPtr<U>& obj)
412 return dynamic_cast<typename T::Pointee_*
>(obj.
get()) !=
nullptr;
420 template<
class T,
class U>
426 return Is<SmartPtr<typename T::ExceptionType>>(obj.Get());
440 if (obj->
Is(System::ObjectExt::GetType<typename T::ValueType>()))
452 static typename std::enable_if<
460 if (obj->
Is(System::ObjectExt::GetType<T>()))
468 return !boxed->
unbox().IsNull();
480 static typename std::enable_if<
488 if (obj->
Is(TypeInfo::BoxedValueType<T>()))
502 template<
class T,
class U>
503 static typename std::enable_if<std::is_enum<T>::value,
bool>::type
Is(
const SmartPtr<U>& obj)
508 if (obj->
Is(TypeInfo::BoxedValueType<T>()))
520 template<
class T,
class U>
521 static typename std::enable_if<std::is_enum<T>::value,
bool>::type
Is(
const WeakPtr<U>& obj)
526 if (obj->
Is(TypeInfo::BoxedValueType<T>()))
537 template<
class T,
class U>
540 TypeInfo typeU = ObjectExt::GetType<U>();
541 TypeInfo typeT = ObjectExt::GetType<T>();
551 template<
class T,
class U>
554 if (value ==
nullptr)
557 return IsImpl<T, U>();
566 static bool Is(
const char16_t* str)
571 return IsImpl<T, System::String>();
580 static bool Is(int32_t value)
582 ASPOSE_UNUSED(value);
584 return IsImpl<T, System::Int32>();
599 return obj.template Cast<Object>();
619 return obj.template Cast<typename T::Pointee_>();
629 return System::ObjectExt::Unbox<T>(obj);
638 static typename std::enable_if<!std::is_scalar<T>::value,
bool>::type
UnknownIsNull(T obj)
640 return obj ==
nullptr;
649 static typename std::enable_if<std::is_scalar<T>::value,
bool>::type
UnknownIsNull(T obj)
661 template<
typename RT1,
typename RT2,
typename F>
662 static typename std::conditional<std::is_convertible<RT2, RT1>::value, RT1, RT2>::type
CoalesceInternal(RT1 value, F func)
664 return value !=
nullptr ? value : func();
674 template<
typename T0,
typename T1>
677 using retval_t = System::Details::ResultOf<T1>;
678 return CoalesceInternal<T0, retval_t,
typename std::function<retval_t()>>(value, func);
687 template<
typename T0,
typename T1>
708 template<
typename To,
typename ...From>
709 static typename std::enable_if<(std::is_fundamental<To>::value), std::array<To,
sizeof...(From)>>::type
ArrayInitializerCast(From ...args)
711 return std::array<To,
sizeof...(From)>({
static_cast<To
>(args)... });
735inline bool ObjectExt::Equals<float, float>(
const float& obj,
const float& another)
737 return (std::isnan(obj) && std::isnan(another)) ? true : obj == another;
746inline bool ObjectExt::Equals<double, double>(
const double& obj,
const double& another)
748 return (std::isnan(obj) && std::isnan(another)) ? true : obj == another;
757 return value.
IsNull() ? nullptr : MakeObject<BoxedValue<String>>(value);
769 if (obj && obj->
Is(String::Type()))
772 return boxed->
unbox();
775 throw InvalidCastException();
782struct IsObjectArray : std::false_type {};
784struct IsObjectArray<
System::
Array<SmartPtr<O>>> : std::is_base_of<System::Object, O> {};
786struct IsObjectArray<
System::
Array<String>> : std::true_type {};
788struct IsObjectArray<SmartPtr<
A>> : IsObjectArray<A> {};
794template <
typename Source,
typename Result>
798 static constexpr bool None = std::is_same<Source, Result>::value;
801 static constexpr bool StaticArithmetic =
802 (std::is_enum<Source>::value || std::is_arithmetic<Source>::value) &&
803 (std::is_enum<Result>::value || std::is_arithmetic<Result>::value);
805 static constexpr bool StaticIntPtr =
806 (std::is_same<Source, IntPtr>::value && (std::is_arithmetic<Result>::value || std::is_pointer<Result>::value)) ||
807 (std::is_same<Result, IntPtr>::value && (std::is_arithmetic<Source>::value || std::is_pointer<Source>::value));
809 static constexpr bool StaticString = std::is_same<Result, String>::value && std::is_constructible<String, Source>::value;
811 static constexpr bool Static = !
None && (StaticArithmetic || StaticIntPtr || StaticString);
815 IsExceptionWrapper<Source>::value && IsExceptionWrapper<Result>::value &&
816 (std::is_convertible<Result, Source>::value || std::is_base_of<Result, Source>::value);
818 static constexpr bool ObjectToException = !
None &&
819 std::is_same<SharedPtr<System::Object>, Source>::value && IsExceptionWrapper<Result>::value;
822 static constexpr bool Array = !
None && IsObjectArray<Result>::value && IsObjectArray<Source>::value;
825 static constexpr bool ToSmartPointer = std::is_base_of<System::Object, Result>::value &&
826 !IsExceptionWrapper<Result>::value && !IsBoxable<Result>::value;
828 static constexpr bool RawPointer = ToSmartPointer && std::is_pointer<Source>::value &&
829 std::is_base_of<Object, std::remove_pointer_t<Source>>::value;
831 static constexpr bool Pointer = !
None && !
Array && ToSmartPointer && IsSmartPtr<Source>::value;
833 static constexpr bool PointerToPointer = !
None && !
Array && IsSmartPtr<Source>::value && IsSmartPtr<Result>::value;
836 static constexpr bool UnboxingToNullable =
837 (std::is_same<Source, SmartPtr<Object>>::value || std::is_same<Source, std::nullptr_t>::value) &&
838 IsNullable<Result>::value;
841 static constexpr bool NullableBoxing = !UnboxingToNullable && (std::is_same<Result, Nullable<Source>>::value ||
842 (IsNullable<Result>::value && std::is_same<Source, std::nullptr_t>::value));
844 static constexpr bool NullableUnboxing = std::is_same<Source, Nullable<Result>>::value;
847 static constexpr bool BoxingCommon = std::is_base_of<Object, Result>::value || IsSmartPtr<Result>::value;
849 static constexpr bool EnumBoxing = BoxingCommon && std::is_enum<Source>::value;
851 static constexpr bool Boxing = BoxingCommon && !EnumBoxing && IsBoxable<Source>::value;
853 static constexpr bool StringBoxing = BoxingCommon && !Boxing && !Pointer && !std::is_same<Source, std::nullptr_t>::value &&
854 std::is_constructible<String, Source>::value;
857 static constexpr bool Unboxing = !UnboxingToNullable && IsSmartPtr<Source>::value && IsBoxable<Result>::value;
860 static constexpr bool UnboxingToString = std::is_same<Result, String>::value && std::is_same<Source, SmartPtr<Object>>::value;
863 static constexpr bool Null = !
Static && !UnboxingToNullable && !NullableBoxing &&
864 std::is_same<Source, std::nullptr_t>::value;
867 static constexpr bool InvalidUnboxing = Unboxing && !std::is_same<Source, SmartPtr<Object>>::value;
878template <
typename Result,
typename Source>
879std::enable_if_t<Details::CastType<Source, Result>::None, Result>
ExplicitCast(
const Source& value)
890template <
typename Result,
typename Source>
891std::enable_if_t<Details::CastType<Source, Result>::Static, Result>
ExplicitCast(
const Source& value)
893 return Result(value);
903template <
typename Result,
typename Source>
904std::enable_if_t<Details::CastType<Source, Result>::Exception, Result>
ExplicitCast(
const Source& value)
906 return value.Get().template Cast<typename Result::ExceptionType, std::true_type>() ? Result(value.Get())
917template <
typename Result,
typename Source>
918std::enable_if_t<Details::CastType<Source, Result>::ObjectToException, Result>
ExplicitCast(
const Source& value)
920 auto exception_ptr = value.template Cast<typename Result::ExceptionType, std::true_type>();
921 return exception_ptr ? Result(exception_ptr.template Cast<System::Details_Exception, std::true_type>())
932template <
typename Result,
typename Source>
936 return value.template Cast<Result, std::true_type>();
946template <
typename Result,
typename Source>
947std::enable_if_t<Details::CastType<Source, Result>::RawPointer,
typename CastResult<std::remove_pointer_t<Result>>::type>
950 return ExplicitCast<Result>(
SmartPtr<std::remove_pointer_t<Source>>(value));
960template <
typename Result,
typename Source>
961std::enable_if_t<Details::CastType<Source, Result>::PointerToPointer, Result>
964 return ExplicitCast<typename Result::Pointee_>(value);
974template <
typename Result,
typename Source>
975std::enable_if_t<Details::CastType<Source, Result>::UnboxingToNullable, Result>
978 return ObjectExt::UnboxToNullable<typename Result::ValueType>(value,
false);
987template <
typename Result,
typename Source>
988std::enable_if_t<Details::CastType<Source, Result>::NullableBoxing, Result>
ExplicitCast(
const Source& value)
990 return Result(value);
1000template <
typename Result,
typename Source>
1001std::enable_if_t<Details::CastType<Source, Result>::NullableUnboxing, Result>
ExplicitCast(
const Source& value)
1003 if (value ==
nullptr)
1004 throw NullReferenceException(u
"Can not unbox null value");
1006 return static_cast<Result
>(value);
1015template <
typename Result,
typename Source>
1016std::enable_if_t<Details::CastType<Source, Result>::EnumBoxing, SmartPtr<BoxedValueBase>>
1028template <
typename Result,
typename Source>
1041template <
typename Result,
typename Source>
1045 return ObjectExt::Box<String>(value);
1054template <
typename Result,
typename Source>
1055std::enable_if_t<Details::CastType<Source, Result>::Unboxing, Result>
ExplicitCast(
const Source& value)
1057 return ObjectExt::Unbox<Result>(value);
1066template <
typename Result,
typename Source>
1079template <
typename Result,
typename Source>
1085 auto result = MakeArray<typename Result::ValueType>(value->data().size());
1086 std::transform(value->data().begin(), value->data().end(), result->data().begin(),
1087 [](
const auto& value) {return ExplicitCast<typename Result::ValueType>(value);});
1098template <
typename Result,
typename Source>
1099std::enable_if_t<Details::CastType<Source, Result>::Static, Result>
AsCast(
const Source& value)
1101 return Result(value);
1110template <
typename Result,
typename Source>
1111std::enable_if_t<Details::CastType<Source, Result>::None, Result>
AsCast(
const Source& value)
1122template <
typename Result,
typename Source>
1123std::enable_if_t<Details::CastType<Source, Result>::Exception, Result>
AsCast(
const Source& value)
1125 return value.Get().template Cast<typename Result::ExceptionType, std::false_type>() ? Result(value.Get())
1135template <
typename Result,
typename Source>
1136std::enable_if_t<Details::CastType<Source, Result>::ObjectToException, Result>
AsCast(
const Source& value)
1138 auto exception_ptr = value.template Cast<typename Result::ExceptionType, std::false_type>();
1139 return exception_ptr ? Result(exception_ptr.template Cast<System::Details_Exception, std::false_type>())
1149template <
typename Result,
typename Source>
1153 return value.template Cast<Result, std::false_type>();
1162template <
typename Result,
typename Source>
1163std::enable_if_t<Details::CastType<Source, Result>::PointerToPointer, Result>
1166 return AsCast<typename Result::Pointee_>(value);
1175template <
typename Result,
typename Source>
1176std::enable_if_t<Details::CastType<Source, Result>::UnboxingToNullable, Result>
1179 return ObjectExt::UnboxToNullable<typename Result::ValueType>(value,
true);
1187template <
typename Result,
typename Source>
1188std::enable_if_t<Details::CastType<Source, Result>::InvalidUnboxing, Result>
AsCast(
const Source& value)
1190 return Default<Result>();
1199template <
typename Result,
typename Source>
1200std::enable_if_t<Details::CastType<Source, Result>::NullableBoxing, Result>
AsCast(
const Source& value)
1202 return Result(value);
1211template <
typename Result,
typename Source>
1215 return ObjectExt::Box(value).template Cast<typename Result::Pointee_, std::false_type>();
1224template <
typename Result,
typename Source>
1225std::enable_if_t<Details::CastType<Source, Result>::UnboxingToString, Result>
AsCast(
const Source& value)
1236template <
typename Result,
typename Source>
1248template <
typename Result,
typename Source>
1254 auto result = MakeArray<typename Result::ValueType>(value->data().size());
1255 auto d_it = result->data().begin();
1256 auto s_it = value->data().begin();
1257 while (s_it != value->data().end())
1259 auto& source_element = *(s_it++);
1260 auto& result_element = *(d_it++);
1262 result_element = AsCast<typename Result::ValueType>(source_element);
1265 if (source_element !=
nullptr && result_element ==
nullptr)
1278template <
typename T0,
typename T1>
1282 using retval_t = System::Details::ResultOf<T1, T0>;
1285 using result_t =
typename std::conditional<
1286 std::is_base_of<Details::BoxableObjectBase, retval_t>::value || std::is_arithmetic<retval_t>::value || std::is_enum<retval_t>::value,
1290 return expr !=
nullptr ? result_t(func(expr)) : result_t(
nullptr);
1300template <
class PatternT,
class ExpressionT,
class ResultT>
1303 if (ObjectExt::Is<PatternT>(left))
1305 result = ExplicitCast<PatternT>(left);
1320template <
class ExpressionT,
class ConstantT>
1321bool IsConstant(
const ExpressionT& left,
const ConstantT& constant)
1323 if (ObjectExt::Is<ConstantT>(left))
1325 return Equals(constant, ExplicitCast<ConstantT>(left));
Represents boxed enumeration value. Objects of this class should only be allocated using System::Make...
Definition: boxed_enum.h:27
Represents a boxed value. Objects of this class should only be allocated using System::MakeObject() f...
Definition: boxed_value.h:172
const T & unbox() const
Unboxes the value represented by the current object.
Definition: boxed_value.h:202
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:113
Forward declaration.
Definition: nullable.h:74
T get_Value() const
Returns a copy of the value represented by the current object.
Definition: nullable.h:143
bool IsNull() const
Determines if the current object represents a null-value.
Definition: nullable.h:171
Provides static methods that emulate C# Object methods called for non-Object C++ types (strings,...
Definition: object_ext.h:21
static bool Is(int32_t value)
Implements 'is' operator translation. Specialization for integer literal.
Definition: object_ext.h:580
static String ToString(const char_t *obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:96
static std::enable_if< System::IsBoxable< T >::value &&!IsNullable< T >::value &&!std::is_enum< T >::value &&detail::has_operator_equal< T >::value, bool >::type Is(const SmartPtr< Object > &obj)
Implements 'is' operator translation. Specialization for boxable types with == operator defined.
Definition: object_ext.h:455
static std::enable_if<(std::is_fundamental< To >::value), std::array< To, sizeof...(From)> >::type ArrayInitializerCast(From ...args)
Converts array fundamental values (which C# does implicitly but C++ apparently does not).
Definition: object_ext.h:709
static T0 Coalesce(System::Nullable< T0 > value, T1 func)
Implementation of '??' operator translation for nullable types.
Definition: object_ext.h:688
static std::enable_if<!std::is_enum< T >::value &&!IsNullable< T >::value, System::SmartPtr< System::Object > >::type Box(const T &value)
Boxes value types for converting to Object. Implementation for non-enum types.
Definition: object_ext.h:209
static std::enable_if< IsSmartPtr< T >::value, bool >::type Is(const SmartPtr< U > &obj)
Implements 'is' operator translation. Specialization for pointer types.
Definition: object_ext.h:407
static std::enable_if< IsSmartPtr< T >::value, String >::type ToString(const T &obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:127
static std::enable_if<!IsSmartPtr< T >::value &&!std::is_scalar< T >::value &&!IsNullable< T >::value &&!std::is_reference< T >::value, String >::type ToString(T &&obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:187
static std::enable_if<!std::is_convertible< T, Object >::value, bool >::type Is(const Object &obj)
Implements 'is' operator translation. Specialization for unconvertible types.
Definition: object_ext.h:396
static std::enable_if< std::is_enum< E >::value &&std::is_enum< T >::value, T >::type Unbox(E e)
Converts enum types.
Definition: object_ext.h:309
static bool Equals(const char_t(&obj)[N], String another)
Substitution for C# Object.Equals calls working for any type in C++. Overload for string literal with...
Definition: object_ext.h:87
static SmartPtr< System::BoxedValueBase > BoxEnum(T enumValue)
Boxes enum types for being propagated as Object.
Definition: object_ext.h:698
static SmartPtr< System::Collections::IList > CastToIList(const SmartPtr< Object > &obj)
static std::enable_if< std::is_enum< T >::value, bool >::type Is(const SmartPtr< U > &obj)
Implements 'is' operator translation. Specialization for enum types.
Definition: object_ext.h:503
static bool Is(const Nullable< U > &value)
Implements 'is' operator translation. Specialization for Nullable type.
Definition: object_ext.h:552
static std::enable_if<!IsSmartPtr< T >::value &&!std::is_scalar< T >::value &&!IsNullable< T >::value, String >::type ToString(const T &obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:177
static std::enable_if<!std::is_enum< T >::value &&!detail::has_operator_equal< T >::value, T >::type Unbox(const SmartPtr< Object > &obj)
Unboxes value types after converting to Object. Implementation for non-enum & non-nullable types.
Definition: object_ext.h:280
static std::enable_if< std::is_convertible< T, Object >::value &&std::is_final< T >::value &&!System::IsBoxable< T >::value &&System::IsSmartPtr< U >::value, bool >::type Is(const U &obj)
Implements 'is' operator translation. Specialization for pointer types optimized for 'final' classes.
Definition: object_ext.h:352
static std::enable_if< std::is_enum< T >::value, T >::type Unbox(const SmartPtr< Object > &obj)
Unboxes value types after converting to Object. Implementation for enum types.
Definition: object_ext.h:233
static std::enable_if< std::is_convertible< T, Object >::value &&!std::is_final< T >::value &&!System::IsBoxable< T >::value &&System::IsSmartPtr< U >::value, bool >::type Is(const U &obj)
Implements 'is' operator translation. Specialization for pointer types.
Definition: object_ext.h:369
static std::enable_if<!IsSmartPtr< T >::value, T >::type ObjectToUnknown(SmartPtr< Object > obj)
Converts Object to unknown type, handling both smart pointer type and boxed value situations.
Definition: object_ext.h:627
static std::enable_if<!IsSmartPtr< T >::value &&std::is_scalar< T >::value &&!std::is_enum< T >::value, String >::type ToString(T &obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:147
static auto Coalesce(T0 value, T1 func)
Implementation of '??' operator translation for non-nullable types.
Definition: object_ext.h:675
static std::enable_if< std::is_enum< E >::value &&std::numeric_limits< T >::is_integer, T >::type Unbox(E e)
Unboxes enum types to integer.
Definition: object_ext.h:298
static std::enable_if<!std::is_scalar< T >::value, bool >::type UnknownIsNull(T obj)
Checks whether unknown type object is nullptr. Overload for non-scalar types.
Definition: object_ext.h:638
static std::enable_if< std::is_scalar< T >::value, bool >::type UnknownIsNull(T obj)
Checks whether unknown type object is nullptr. Overload for scalar types.
Definition: object_ext.h:649
static std::enable_if< std::is_enum< T >::value, bool >::type Is(const WeakPtr< U > &obj)
Implements 'is' operator translation. Specialization for enum types vs weak pointers.
Definition: object_ext.h:521
static std::enable_if<!IsSmartPtr< T >::value, System::SmartPtr< Object > >::type UnknownToObject(const T &obj)
Converts unknown type to Object, handling both smart pointer type and value type situations.
Definition: object_ext.h:607
static std::enable_if< std::is_enum< T >::value, String >::type ToString(const T &obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:116
static bool Is(const char16_t *str)
Implements 'is' operator translation. Specialization for string literal.
Definition: object_ext.h:566
static std::enable_if<!IsExceptionWrapper< T >::value &&!IsSmartPtr< T >::value &&!std::is_scalar< T >::value &&!IsNullable< T >::value, String >::type ToString(T &obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:167
static std::enable_if<!IsSmartPtr< T >::value &&std::is_scalar< T >::value, bool >::type Equals(const T &obj, const T2 &another)
Substitution for C# Object.Equals calls working for any type in C++. Overload for scalar types.
Definition: object_ext.h:75
static int GetHashCode(const T &obj)
Implements GetHashCode() calls; works on both Object subclasses and unrelated types.
Definition: object_ext.h:28
static std::enable_if< IsExceptionWrapper< T >::value, bool >::type Is(const ExceptionWrapper< U > &obj)
Implements 'is' operator translation. Specialization for exception wrapper types.
Definition: object_ext.h:421
static std::enable_if< System::IsBoxable< T >::value &&!IsNullable< T >::value &&!std::is_enum< T >::value &&!detail::has_operator_equal< T >::value, bool >::type Is(const SmartPtr< Object > &obj)
Implements 'is' operator translation. Specialization for boxable types without defined ==.
Definition: object_ext.h:483
static std::conditional< std::is_convertible< RT2, RT1 >::value, RT1, RT2 >::type CoalesceInternal(RT1 value, F func)
Implementation of '??' operator translation for non-nullable types. Overload for case if RT2 is conve...
Definition: object_ext.h:662
static std::enable_if< System::IsBoxable< T >::value, System::SharedPtr< System::Object > >::type ExplicitCastToObject(const T &value)
Definition: object_ext.h:717
static std::enable_if< IsExceptionWrapper< T >::value, bool >::type Equals(const T &obj, const T2 &another)
Definition: object_ext.h:34
static std::enable_if<!IsSmartPtr< T >::value &&std::is_scalar< T >::value &&!std::is_enum< T >::value, String >::type ToString(T &&obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:157
static Nullable< T > UnboxToNullable(const SmartPtr< Object > &obj, bool safe=true)
Unboxes object to nullable type.
Definition: object_ext.h:326
static std::enable_if< IsSmartPtr< T >::value, System::SmartPtr< Object > >::type UnknownToObject(T obj)
Converts unknown type to Object, handling both smart pointer type and value type situations.
Definition: object_ext.h:597
static std::enable_if< IsNullable< T >::value, bool >::type Is(const SmartPtr< Object > &obj)
Implements 'is' operator translation. Specialization for nullable types.
Definition: object_ext.h:435
static std::enable_if< IsSmartPtr< T >::value, bool >::type Equals(const T &obj, const T2 &another)
Substitution for C# Object.Equals calls working for any type in C++. Overload for smart pointer types...
Definition: object_ext.h:49
static bool IsBoxedValue(const SmartPtr< Object > &obj)
Checks if object is a boxed value.
static String ToString(const Nullable< T > &obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:106
static std::enable_if<!std::is_enum< T >::value &&detail::has_operator_equal< T >::value, T >::type Unbox(const SmartPtr< Object > &obj)
Unboxes value types after converting to Object. Implementation for non-enum & non-nullable types.
Definition: object_ext.h:259
static std::enable_if< IsSmartPtr< T >::value, T >::type ObjectToUnknown(SmartPtr< Object > obj)
Converts Object to unknown type, handling both smart pointer type and bpxed value situations.
Definition: object_ext.h:617
static std::enable_if<!IsExceptionWrapper< T >::value &&!IsSmartPtr< T >::value &&!std::is_scalar< T >::value, bool >::type Equals(T obj, const T2 &another)
Substitution for C# Object.Equals calls working for any type in C++. Overload for structure types.
Definition: object_ext.h:62
static std::enable_if< std::is_convertible< T, Object >::value, bool >::type Is(const Object &obj)
Implements 'is' operator translation. Specialization for value types.
Definition: object_ext.h:384
static String UnboxStringSafe(const SmartPtr< Object > &obj)
Unboxes string from boxed value.
static std::enable_if< System::IsSmartPtr< T >::value, System::SharedPtr< System::Object > >::type ExplicitCastToObject(const T &value)
Definition: object_ext.h:723
static std::enable_if< std::is_enum< T >::value, System::SmartPtr< System::Object > >::type Box(const T &value)
Boxes value types for converting to Object. Implementation for enum types.
Definition: object_ext.h:198
static std::enable_if< IsNullable< T >::value, System::SmartPtr< System::Object > >::type Box(const T &value)
Boxes Nullable types for converting to Object.
Definition: object_ext.h:219
static std::enable_if< IsSmartPtr< T >::value||std::is_pointer< T >::value||IsExceptionWrapper< T >::value, String >::type ToString(T &obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:137
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
virtual bool Is(const TypeInfo &targetType) const
Check if object represents an instance of type described by targetType. Analog of C# 'is' operator.
Provides static methods that implement object type getters. This is a static type with no instance se...
Definition: object_type.h:26
Pointee_ * get() const
Gets pointed object.
Definition: smart_ptr.h:518
std::enable_if_t< std::is_same< Y, T >::value, SmartPtr< Y > > Cast() const
Casts pointer to its type itself.
Definition: smart_ptr.h:742
bool Is(const System::TypeInfo &target) const
Checks if pointed object is of specific type or its child type. Follows C# 'is' semantics.
Definition: object.h:847
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
bool IsNullOrEmpty() const
Checks if string is empty or is considered null.
bool IsNull() const
Checks if string is considered null. String is null and only if it is constructed via String() constr...
Definition: string.h:280
Represents a particular type and provides information about it.
Definition: type_info.h:109
bool IsSubclassOf(const TypeInfo &type) const
Determines whether the type represented by the current object is a subclass of the specified class.
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: weak_ptr.h:18
@ Static
Look through static members.
@ Null
No encryption algorithm is used with a 'Null' cipher algorithm.
Definition: db_command.h:9
bool IsDeclaration(const ExpressionT &left, ResultT &result)
Implements 'is' declaration pattern translation.
Definition: object_ext.h:1301
bool Equals(const TA &a, const TB &b)
Determines the equality of two values applying operator==() to them.
Definition: primitive_types.h:77
static auto SafeInvoke(T0 expr, T1 func)
Implementation of '?.' operator translation.
Definition: object_ext.h:1279
std::enable_if_t< Details::CastType< Source, Result >::Static, Result > AsCast(const Source &value)
Casts the source type to the result type using 'as' operator cast. Used when simple constructor-like ...
Definition: object_ext.h:1099
std::enable_if_t< Details::CastType< Source, Result >::None, Result > ExplicitCast(const Source &value)
Casts the source type to the result type using explicit cast. Used when the source and the result typ...
Definition: object_ext.h:879
class ASPOSECPP_SHARED_CLASS Array
Definition: smart_ptr.h:22
bool IsConstant(const ExpressionT &left, const ConstantT &constant)
Implements 'is' constant pattern translation.
Definition: object_ext.h:1321
ExceptionWrapper< Details_Exception > Exception
Alias to be used instead of Details::Exception.
Definition: exception.h:369
SmartPtr< TTo > type
An alias for a pointer to an instance of TTo.
Definition: object.h:387
static String ToString(int8_t value)
Converts the specified value to its string representation.
static std::enable_if< std::is_same< T, E >::value||std::is_convertible< T, UnderlyingType >::value, String >::type GetName(T value)
Returns the name of the enumeration constant that has the specified value.
Definition: enum.h:213
static bool IsDefined(E value)
Determines whether the specified value is a member of enumeration type E.
Definition: enum.h:180
Template predicate that checks if boxing of the specified type is supported.
Definition: boxable_traits.h:16
A template predicate that determines if the specified type is a Exception class or its descendant.
Definition: object.h:405
A template predicate that determines if its template argument T in Nullable or its subclass.
Definition: nullable.h:23
Trait class to check if a type is a specialization of SmartPtr class.
Definition: smart_ptr.h:1499
Checks whether operator == exists in specified type. If so, inherits std::true_type,...
Definition: detail.h:122