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);
81 return *
this == other;
106 return Equals<0, Args...>(m_tuple, other.m_tuple);
109 template<
typename ... OtherArgs>
112 m_tuple = otherTuple.m_tuple;
118 template <
typename T>
121 System::Details::apply([&](
auto&... args) { deconstructiblePtr->Deconstruct(args...); }, m_tuple);
126 const tuple_t&
tuple()
const {
return m_tuple;}
130 template<std::size_t Index = 0,
typename... Types>
131 static typename std::enable_if<Index ==
sizeof...(Types),
bool>::type
132 Equals(
const std::tuple<Types...>& a,
const std::tuple<Types...>& b)
140 template<std::size_t Index = 0,
typename... Types>
141 static typename std::enable_if<Index <
sizeof...(Types),
bool>::type
142 Equals(
const std::tuple<Types...>& a,
const std::tuple<Types...>& b)
149 return Equals<Index + 1, Types...>(a, b);
153 template<std::
size_t Index = 0>
155 template<std::
size_t Index = 0>
163 ToString<Index + 1>(
tuple, result);
167 template<std::
size_t Index = 0>
168 static typename std::enable_if<Index == tuple_size, void>::type
GetHashCode(
const tuple_t&
tuple, int32_t& result) {}
169 template<std::
size_t Index = 0>
170 static typename std::enable_if<Index < tuple_size, void>::type
GetHashCode(
const tuple_t&
tuple, int32_t& result)
173 GetHashCode<Index + 1>(
tuple, result);
183template <
typename... Args>
189 typedef System::BaseTypesInfo<System::Object, Runtime::CompilerServices::ITuple> baseTypes;
193 RTTI_INFO_BOXED_CUSTOM(
thisType, baseTypes);
205 return System::ObjectType::GetType<ValueT>();
214 if (!obj || !obj->
Is(
Type()))
218 return m_value == boxed->m_value;
224 return m_value.GetHashCode();
247 return typeid(V).hash_code() == m_type_hash;
256 if (index >= get_Length())
258 throw IndexOutOfRangeException(u
"ValueTuple");
261 Details::ReturnValueHolder return_value_holder;
262 Details::FindItem(index, m_value.m_tuple, return_value_holder);
264 return return_value_holder.value;
270 return m_value.tuple_size;
282template <
typename... Args>
292template <
typename... Args>
295 return ValueTuple<Args&&...>(std::forward<Args>(args)...);
303template <std::size_t N,
typename... Args>
306 return tuple.template Item<N>();
Boxed version of value tuple.
Definition: value_tuple.h:185
bool is() const
Determines if the type of the boxed value represented by the current object is V.
Definition: value_tuple.h:245
const System::TypeInfo & GetType() const override
Gets actual type of object.
Definition: value_tuple.h:203
int GetHashCode() const override
Returns a hash code for the current object.
Definition: value_tuple.h:222
const ValueT & unbox() const
Unboxes the boxed value.
Definition: value_tuple.h:235
bool Equals(ptr obj) override
Determines the equality of the boxed values represented by the current and specified objects.
Definition: value_tuple.h:212
String ToString() const override
Returns the string representation of the boxed value.
Definition: value_tuple.h:228
SharedPtr< Object > idx_get(int index) const override
Returns the element at position index.
Definition: value_tuple.h:254
BoxedValue(const ValueT &value)
Constructs a BoxedValue object that represents the specified value boxed.
Definition: value_tuple.h:198
int32_t get_Length() const override
Returns the number of elemens in this tuple.
Definition: value_tuple.h:268
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:104
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:126
System::String ToString() const
Definition: value_tuple.h:84
int32_t GetHashCode() const
Definition: value_tuple.h:92
ValueTuple()
Definition: value_tuple.h:34
ValueTuple & operator=(const ValueTuple< OtherArgs... > &otherTuple)
Definition: value_tuple.h:110
const TypeInfo & GetType() const
Definition: value_tuple.h:99
bool Equals(const ValueTuple &other)
Definition: value_tuple.h:79
tuple_t & tuple()
Definition: value_tuple.h:125
Definition: db_command.h:9
ValueTuple< Args... > MakeTuple(Args... args)
Creates tuple on stack.
Definition: value_tuple.h:283
ValueTuple< Args... > TieTuple(Args &&... args)
Creates tuple bound to some values.
Definition: value_tuple.h:293
auto Get(const ValueTuple< Args... > &tuple)
Gets N-th element of value tuple.
Definition: value_tuple.h:304
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