CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
object_type.h
1
2#pragma once
3
4#include <system/object.h>
5#include <system/smart_ptr.h>
6#include <system/weak_ptr.h>
7#include <system/convert.h>
8#include <system/decimal.h>
9#include <system/nullable.h>
10#include <system/int32.h>
11#include <system/int64.h>
12#include <system/void.h>
13
14#include <initializer_list>
15#include <array>
16#include <utility>
17#include <type_traits>
18
19namespace System
20{
21
26{
27public:
33 template<typename T>
34 static inline typename std::enable_if<IsSmartPtr<T>::value, const System::TypeInfo&>::type GetType(const T& obj)
35 {
36 return obj->GetType();
37 }
38
44 template<typename T>
45 static inline typename std::enable_if<!IsExceptionWrapper<T>::value && !IsSmartPtr<T>::value && !std::is_fundamental<T>::value && !std::is_enum<T>::value && !IsNullable<T>::value, const System::TypeInfo&>::type GetType(const T& obj)
46 {
47 return obj.GetType();
48 }
49
55 template<typename T>
56 static inline typename std::enable_if<IsExceptionWrapper<T>::value, const System::TypeInfo&>::type GetType(const T& obj)
57 {
58 return obj.Get()->GetType();
59 }
60
66 template<typename T>
67 static inline typename std::enable_if<std::is_fundamental<T>::value || std::is_enum<T>::value, const System::TypeInfo&>::type GetType(const T obj)
68 {
69 return GetType<T>();
70 }
71
77 template<typename T>
78 static inline typename std::enable_if<IsNullable<T>::value, const System::TypeInfo&>::type GetType(const T obj)
79 {
80 return GetType<typename T::ValueType>();
81 }
82
83
84
89 template <typename T>
90 static inline typename std::enable_if<std::is_fundamental<T>::value && !std::is_enum<T>::value, const System::TypeInfo&>::type GetType()
91 {
92 return TypeInfo::BoxedValueType<T>();
93 }
94
99 template <typename T>
100 static inline typename std::enable_if<std::is_enum<T>::value, const System::TypeInfo&>::type GetType()
101 {
102 return TypeInfo::BoxedValueType<T>();
103 }
104
109 template <typename T>
110 static inline typename std::enable_if<(!std::is_fundamental<T>::value && !std::is_enum<T>::value && !IsBoxable<T>::value) || IsExceptionWrapper<T>::value, const System::TypeInfo&>::type GetType()
111 {
112 return T::Type(); // Works for pointers as well - they redirect Type() call to Pointee_::Type()
113 }
114
119 template <typename T>
120 static inline typename std::enable_if<IsNullable<T>::value, const System::TypeInfo&>::type GetType()
121 {
122 return T::Type(); // Works for pointers as well - they redirect Type() call to Pointee_::Type()
123 }
124
129 template <typename T>
130 static inline typename std::enable_if<detail::is_a<T, MulticastDelegate>::value, const System::TypeInfo&>::type GetType()
131 {
132 return T::Type(); // Works for pointers as well - they redirect Type() call to Pointee_::Type()
133 }
134
139 template <typename T>
140 static inline typename std::enable_if<
141 !std::is_fundamental<T>::value &&
142 !std::is_enum<T>::value &&
146 const System::TypeInfo&>::type GetType()
147 {
148 return TypeInfo::BoxedValueType<T>(); // Works for pointers as well - they redirect Type() call to Pointee_::Type()
149 }
150
155 static inline const System::TypeInfo& GetType(const String& obj)
156 {
157 ASPOSE_UNUSED(obj);
158 return System::String::Type();
159 }
160};
161
164template <>
165inline const System::TypeInfo& ObjectType::GetType<uint8_t>()
166{
167 return System::Byte::Type();
168}
169
172template <>
173inline const System::TypeInfo& ObjectType::GetType<char16_t>()
174{
175 return System::Char::Type();
176}
177
180template <>
181inline const System::TypeInfo& ObjectType::GetType<int32_t>()
182{
183 return System::Int32::Type();
184}
185
188template <>
189inline const System::TypeInfo& ObjectType::GetType<int64_t>()
190{
191 return System::Int64::Type();
192}
193
196template <>
197inline const System::TypeInfo& ObjectType::GetType<bool>()
198{
199 return System::Boolean::Type();
200}
201
204template <>
205inline const System::TypeInfo& ObjectType::GetType<System::String>()
206{
207 return System::String::Type();
208}
209
212template <>
213inline const System::TypeInfo& ObjectType::GetType<System::DateTime>()
214{
215 return System::DateTime::Type();
216}
217
220template <>
221inline const System::TypeInfo& ObjectType::GetType<void>()
222{
223 return System::Void::Type();
224}
225
226} // namespace System
static const TypeInfo & Type()
Returns a TypeInfo object that contains information about this class.
Definition: date_time.h:654
Provides static methods that implement object type getters. This is a static type with no instance se...
Definition: object_type.h:26
static std::enable_if< std::is_enum< T >::value, constSystem::TypeInfo & >::type GetType()
Implements typeof() translation. Overload for enum types.
Definition: object_type.h:100
static std::enable_if< detail::is_a< T, MulticastDelegate >::value, constSystem::TypeInfo & >::type GetType()
Implements typeof() translation. Overload for MutlicastDelegate.
Definition: object_type.h:130
static std::enable_if< std::is_fundamental< T >::value||std::is_enum< T >::value, constSystem::TypeInfo & >::type GetType(const T obj)
Implements typeof() translation. Overload for primitive types.
Definition: object_type.h:67
static std::enable_if<!std::is_fundamental< T >::value &&!std::is_enum< T >::value &&IsBoxable< T >::value &&!detail::is_a< T, MulticastDelegate >::value &&!IsNullable< T >::value, constSystem::TypeInfo & >::type GetType()
Implements typeof() translation. Overload for structures and pointers.
Definition: object_type.h:146
static std::enable_if< IsNullable< T >::value, constSystem::TypeInfo & >::type GetType(const T obj)
Implements typeof() translation. Overload for Nullable types.
Definition: object_type.h:78
static const System::TypeInfo & GetType(const String &obj)
Implements typeof() translation. Overload for string type.
Definition: object_type.h:155
static std::enable_if< std::is_fundamental< T >::value &&!std::is_enum< T >::value, constSystem::TypeInfo & >::type GetType()
Implements typeof() translation. Overload for primitive types.
Definition: object_type.h:90
static std::enable_if<(!std::is_fundamental< T >::value &&!std::is_enum< T >::value &&!IsBoxable< T >::value)||IsExceptionWrapper< T >::value, constSystem::TypeInfo & >::type GetType()
Implements typeof() translation. Overload for structures and pointers.
Definition: object_type.h:110
static std::enable_if< IsNullable< T >::value, constSystem::TypeInfo & >::type GetType()
Implements typeof() translation. Overload for Nullable.
Definition: object_type.h:120
static std::enable_if<!IsExceptionWrapper< T >::value &&!IsSmartPtr< T >::value &&!std::is_fundamental< T >::value &&!std::is_enum< T >::value &&!IsNullable< T >::value, constSystem::TypeInfo & >::type GetType(const T &obj)
Implements typeof() translation. Overload for structures.
Definition: object_type.h:45
static std::enable_if< IsExceptionWrapper< T >::value, constSystem::TypeInfo & >::type GetType(const T &obj)
Implements typeof() translation. Overload for exceptions.
Definition: object_type.h:56
static std::enable_if< IsSmartPtr< T >::value, constSystem::TypeInfo & >::type GetType(const T &obj)
Implements typeof() translation. Overload for smart pointers.
Definition: object_type.h:34
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
Definition: db_command.h:9
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
Tests if specific type is a specialization of specific template. If it is, inherits std::true_type,...
Definition: detail.h:80