CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
json_unbox_ref.h
1
4#pragma once
5
6#include <type_traits>
7
8#include <system/boxable_traits.h>
9#include <system/boxed_value.h>
10#include <system/exceptions.h>
11#include <system/object.h>
12
13namespace System
14{
15
16namespace Text
17{
18
19namespace Json
20{
21
22namespace Serialization
23{
24
25namespace Metadata
26{
27
35template<class T>
36inline typename std::enable_if<!std::is_enum<T>::value && IsBoxable<T>::value && std::is_base_of<Object, T>::value, T&>::type
38{
39 if (!obj)
40 throw NullReferenceException();
41
42 if (auto boxed = obj.template Cast<BoxedValue<T>>())
43 return const_cast<T&>(boxed->unbox());
44
45 return *obj.template Cast<T, std::true_type>();
46}
47
55template<class T>
56inline typename std::enable_if<!std::is_enum<T>::value && IsBoxable<T>::value && !std::is_base_of<Object, T>::value, T&>::type
58{
59 if (!obj)
60 throw NullReferenceException();
61
62 if (auto boxed = obj.template Cast<BoxedValue<T>>())
63 return const_cast<T&>(boxed->unbox());
64
65 throw InvalidCastException();
66}
67
68} // namespace Metadata
69
70} // namespace Serialization
71
72} // namespace Json
73
74} // namespace Text
75
76} // namespace System
Represents a boxed value. Objects of this class should only be allocated using System::MakeObject() f...
Definition: boxed_value.h:218
@ Text
Defines color adjustment information for text.
std::enable_if<!std::is_enum< T >::value &&IsBoxable< T >::value &&std::is_base_of< Object, T >::value, T & >::type UnboxRef(const SmartPtr< Object > &obj)
Unboxes a boxed value type to a mutable reference allowing in-place modification of the boxed value....
Definition: json_unbox_ref.h:37
Definition: db_command.h:9
std::enable_if<!IsExceptionWrapper< TTo >::value, typenameCastResult< TTo >::type >::type Cast(SmartPtr< TFrom > const &obj)
Performs cast on SmartPtr objects.
Definition: object.h:416
Template predicate that checks if boxing of the specified type is supported.
Definition: boxable_traits.h:16