CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
special_casts.h
1
3#ifndef _aspose_system_casts_h_
4#define _aspose_system_casts_h_
5
6#include <system/collections/ienumerable.h>
7#include <system/collections/list.h>
8#include <system/object_ext.h>
9#include <system/shared_ptr.h>
10#include <system/weak_ptr.h>
11#include <system/array.h>
12
13namespace System {
14
20template<class To, class From>
21typename std::enable_if<!System::detail::has_method_get_Count<From>::value,
23{
24 auto result = MakeObject<Collections::Generic::List<To>>();
25
26 auto enumerator = enumerable->GetEnumerator();
27 while (enumerator->MoveNext())
28 {
29 const auto& item = ExplicitCast<To>(enumerator->get_Current());
30 result->Add(item);
31 }
32
33 return result;
34}
35
41template<class To, class From>
42typename std::enable_if<System::detail::has_method_get_Count<From>::value,
44{
45 auto result = MakeObject<Collections::Generic::List<To>>(enumerable->get_Count());
46
47 auto enumerator = enumerable->GetEnumerator();
48 while (enumerator->MoveNext())
49 {
50 const auto& item = ExplicitCast<To>(enumerator->get_Current());
51 result->Add(item);
52 }
53
54 return result;
55}
56
57
65template<typename To, typename From>
66std::enable_if_t<System::IsSmartPtr<From>::value, System::SharedPtr<System::Array<To>>>
68{
69 return ExplicitCast<System::ArrayPtr<To>>(from);
70}
71
79template<typename To, typename From>
80std::enable_if_t<!System::IsSmartPtr<From>::value && System::IsBoxable<From>::value && std::is_same<To, System::SharedPtr<Object>>::value, System::SharedPtr<System::Array<To>>>
82{
83 return ExplicitCast<System::ArrayPtr<To>>(from);
84}
85
92template<class To, class From>
94{
95 return ExplicitCast<System::ArrayPtr<To>>(from);
96}
97
98} // namespace System
99
100#endif // _aspose_system_casts_h_
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:259
List pointer with access operators. This type is a pointer to manage other object's deletion....
Definition: list.h:38
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9
std::enable_if<!System::detail::has_method_get_Count< From >::value, Collections::Generic::ListPtr< To > >::type CastEnumerableTo(const From &enumerable)
Performs the explicit casting of elements of the specified enumerable object to different type.
Definition: special_casts.h:22
std::enable_if_t< System::IsSmartPtr< From >::value, System::SharedPtr< System::Array< To > > > StaticCastArray(const System::SharedPtr< System::Array< From > > &from)
Performs casting of elements of the specified array to different type. Override for cases then From i...
Definition: special_casts.h:67
SharedPtr< Array< To > > DynamicCastArray(const SharedPtr< Array< From > > &from)
Performs casting of elements of the specified array to different type.
Definition: special_casts.h:93
Template predicate that checks if boxing of the specified type is supported.
Definition: boxable_traits.h:16