Skip to content

Commit

Permalink
[JSON] Assign from OptionalType (#1631)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Wielders <[email protected]>
  • Loading branch information
sebaszm and pwielders authored Jun 7, 2024
1 parent e0d062d commit ac3238a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Source/core/JSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,15 @@ namespace Core {
return (*this);
}

NumberType<TYPE, SIGNED, BASETYPE>& operator=(const Core::OptionalType<TYPE>& RHS)
{
if (RHS.IsSet() == true) {
operator=(RHS.Value());
}

return (*this);
}

inline TYPE Default() const
{
return _default;
Expand Down Expand Up @@ -1054,6 +1063,15 @@ namespace Core {
return (*this);
}

FloatType<TYPE>& operator=(const Core::OptionalType<TYPE>& RHS)
{
if (RHS.IsSet() == true) {
operator=(RHS.Value());
}

return (*this);
}

inline TYPE Default() const
{
return _default;
Expand Down Expand Up @@ -1347,6 +1365,15 @@ namespace Core {
return (*this);
}

Boolean& operator=(const Core::OptionalType<bool>& RHS)
{
if (RHS.IsSet() == true) {
operator=(RHS.Value());
}

return (*this);
}

inline bool Value() const
{
return ((_value & SetBit) != 0 ? (_value & ValueBit) != 0 : (_value & DefaultBit) != 0);
Expand Down Expand Up @@ -1582,6 +1609,15 @@ namespace Core {
return (*this);
}

String& operator=(const Core::OptionalType<string>& RHS)
{
if (RHS.IsSet() == true) {
operator=(RHS.Value());
}

return (*this);
}

String& operator=(const char RHS[])
{
Core::ToString(RHS, _value);
Expand Down Expand Up @@ -2630,6 +2666,15 @@ namespace Core {
return (*this);
}

EnumType<ENUMERATE>& operator=(const Core::OptionalType<ENUMERATE>& RHS)
{
if (RHS.IsSet() == true) {
operator=(RHS.Value());
}

return (*this);
}

inline const ENUMERATE Default() const
{
return (_default);
Expand Down Expand Up @@ -3243,6 +3288,16 @@ namespace Core {
return (*this);
}

template<typename ENUM>
ArrayType<ELEMENT>& operator=(const Core::OptionalType<ENUM>& RHS)
{
if (RHS.IsSet() == true) {
operator=(RHS.Value());
}

return (*this);
}

template<typename ENUM, typename std::enable_if<std::is_same<ELEMENT, EnumType<ENUM>>::value, int>::type = 0>
inline operator const ENUM() const
{
Expand Down

0 comments on commit ac3238a

Please sign in to comment.