3#include <system/object_ext.h>
4#include <system/tuple.h>
5#include <system/details/apply.h>
6#include <system/runtime/compiler_services/ituple.h>
20template<
typename ... Args>
24 using tuple_t = std::tuple<Args...>;
26 static constexpr std::size_t tuple_size =
sizeof...(Args);
29 template <
typename... OtherArgs>
friend class ValueTuple;
40 template <
typename = std::enable_if_t<(tuple_size > 0)>>
41 ValueTuple(Args... args) : m_tuple(std::forward<Args>(args)...)
48 return *static_holder<ThisTypeInfo>();
53 template <std::
size_t Index>
54 std::tuple_element_t<Index, tuple_t>&
Item()
56 static_assert(Index < tuple_size,
"Index out of ragnge.");
58 return std::get<Index>(m_tuple);
63 template <std::
size_t Index>
64 const std::tuple_element_t<Index, tuple_t>&
Item()
const
66 static_assert(Index < tuple_size,
"Index out of ragnge.");
68 return std::get<Index>(m_tuple);
76 return System::ObjectExt::Is<ValueTuple>(obj) &&
Equals<0, Args...>(m_tuple, ObjectExt::Unbox<ValueTuple>(obj).m_tuple);
101 return Equals<0, Args...>(m_tuple, other.m_tuple);
104 template<
typename ... OtherArgs>
107 m_tuple = otherTuple.m_tuple;
113 template <
typename T>
116 System::Details::apply([&](
auto&... args) { deconstructiblePtr->Deconstruct(args...); }, m_tuple);
121 const tuple_t&
tuple()
const {
return m_tuple;}
125 template<std::size_t Index = 0,
typename... Types>
126 static typename std::enable_if<Index ==
sizeof...(Types),
bool>::type
127 Equals(
const std::tuple<Types...>& a,
const std::tuple<Types...>& b)
135 template<std::size_t Index = 0,
typename... Types>
136 static typename std::enable_if<Index <
sizeof...(Types),
bool>::type
137 Equals(
const std::tuple<Types...>& a,
const std::tuple<Types...>& b)
144 return Equals<Index + 1, Types...>(a, b);
148 template<std::
size_t Index = 0>
150 template<std::
size_t Index = 0>
158 ToString<Index + 1>(
tuple, result);
162 template<std::
size_t Index = 0>
163 static typename std::enable_if<Index == tuple_size, void>::type
GetHashCode(
const tuple_t&
tuple, int32_t& result) {}
164 template<std::
size_t Index = 0>
165 static typename std::enable_if<Index < tuple_size, void>::type
GetHashCode(
const tuple_t&
tuple, int32_t& result)
168 GetHashCode<Index + 1>(
tuple, result);
178template <
typename... Args>
184 typedef System::BaseTypesInfo<System::Object, Runtime::CompilerServices::ITuple> baseTypes;
188 RTTI_INFO_BOXED_CUSTOM(
thisType, baseTypes);
200 return System::ObjectType::GetType<ValueT>();
209 if (!obj || !obj->
Is(
Type()))
213 return m_value == boxed->m_value;
219 return m_value.GetHashCode();
242 return typeid(V).hash_code() == m_type_hash;
251 if (index >= get_Length())
253 throw IndexOutOfRangeException(u
"ValueTuple");
256 Details::ReturnValueHolder return_value_holder;
257 Details::FindItem(index, m_value.m_tuple, return_value_holder);
259 return return_value_holder.value;
265 return m_value.tuple_size;
277template <
typename... Args>
287template <
typename... Args>
290 return ValueTuple<Args&&...>(std::forward<Args>(args)...);
298template <std::size_t N,
typename... Args>
301 return tuple.template Item<N>();
Boxed version of value tuple.
Definition: value_tuple.h:180
bool is() const
Determines if the type of the boxed value represented by the current object is V.
Definition: value_tuple.h:240
const System::TypeInfo & GetType() const override
Gets actual type of object.
Definition: value_tuple.h:198
int GetHashCode() const override
Returns a hash code for the current object.
Definition: value_tuple.h:217
const ValueT & unbox() const
Unboxes the boxed value.
Definition: value_tuple.h:230
bool Equals(ptr obj) override
Determines the equality of the boxed values represented by the current and specified objects.
Definition: value_tuple.h:207
String ToString() const override
Returns the string representation of the boxed value.
Definition: value_tuple.h:223
SharedPtr< Object > idx_get(int index) const override
Returns the element at position index.
Definition: value_tuple.h:249
BoxedValue(const ValueT &value)
Constructs a BoxedValue object that represents the specified value boxed.
Definition: value_tuple.h:193
int32_t get_Length() const override
Returns the number of elemens in this tuple.
Definition: value_tuple.h:263
Represents a boxed value. Objects of this class should only be allocated using System::MakeObject() f...
Definition: boxed_value.h:172
static String ToString(const char_t *obj)
Substitution for C# ToString method to work on any C++ type.
Definition: object_ext.h:96
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 Equals(const T &obj, const T2 &another)
Definition: object_ext.h:34
virtual bool Is(const TypeInfo &targetType) const
Check if object represents an instance of type described by targetType. Analog of C# 'is' operator.
static const TypeInfo & Type()
Implements C# typeof(System.Object) construct.
Definition: object.h:172
Defines a general-purpose Tuple implementation that allows access to Tuple instance members without k...
Definition: ituple.h:11
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
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
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
String ToString() const
Wrapper for handling String class in contexts where ToString() is being called on value type objects.
Definition: string.h:504
Represents a particular type and provides information about it.
Definition: type_info.h:109
Class that represents a ValueTuple data structure.
Definition: value_tuple.h:22
bool operator==(const ValueTuple &other) const
Definition: value_tuple.h:99
static const TypeInfo & Type()
Returns a reference to the TypeInfo object representing the ValueTuple class type information.
Definition: value_tuple.h:46
ValueTuple(Args... args)
Constructs a tuple object.
Definition: value_tuple.h:41
std::tuple_element_t< Index, tuple_t > & Item()
Gets the reference to value of the ValueTuple object's component.
Definition: value_tuple.h:54
bool Equals(SharedPtr< Object > obj)
Determines if the current and the specified objects are identical.
Definition: value_tuple.h:74
const std::tuple_element_t< Index, tuple_t > & Item() const
Gets the value of the ValueTuple object's component.
Definition: value_tuple.h:64
const tuple_t & tuple() const
Definition: value_tuple.h:121
System::String ToString() const
Definition: value_tuple.h:79
int32_t GetHashCode() const
Definition: value_tuple.h:87
ValueTuple()
Definition: value_tuple.h:34
ValueTuple & operator=(const ValueTuple< OtherArgs... > &otherTuple)
Definition: value_tuple.h:105
const TypeInfo & GetType() const
Definition: value_tuple.h:94
tuple_t & tuple()
Definition: value_tuple.h:120
Definition: db_command.h:9
ValueTuple< Args... > MakeTuple(Args... args)
Creates tuple on stack.
Definition: value_tuple.h:278
ValueTuple< Args... > TieTuple(Args &&... args)
Creates tuple bound to some values.
Definition: value_tuple.h:288
auto Get(const ValueTuple< Args... > &tuple)
Gets N-th element of value tuple.
Definition: value_tuple.h:299
TypeInfo structure for BoxedValue class.
Definition: type_info.h:367
Wrapper for a pointer to an instance of TypeInfo class. This type should be allocated on stack and pa...
Definition: type_info.h:72
Represents a pointer to TypeInfo object that contains information about ValueTuple class.
Definition: value_tuple.h:12
ValueTupleTypeInfo()
Constructs an instance of MulticastDelegateTypeInfo class.
Definition: value_tuple.h:14