12#include "azure/core/internal/json/json.hpp"
18namespace Azure {
namespace Core {
namespace Json {
namespace _internal {
24 struct JsonOptional final
37 static inline void SetIfExists(
39 Azure::Core::Json::_internal::json
const& jsonKey,
40 std::string
const& key)
noexcept
42 if (jsonKey.contains(key) && !jsonKey[key].is_null())
44 destination = jsonKey[key].get<T>();
62 template <
class V,
class T>
63 static inline void SetIfExists(
65 Azure::Core::Json::_internal::json
const& jsonKey,
66 std::string
const& key,
67 std::function<T(V value)> decorator)
noexcept
69 if (jsonKey.contains(key))
71 if (!jsonKey[key].is_null())
73 destination = decorator(jsonKey[key].get<V>());
90 template <
class T,
class V>
91 static inline void SetIfExists(
93 Azure::Core::Json::_internal::json
const& jsonKey,
94 std::string
const& key,
95 std::function<V(T value)> decorator)
noexcept
97 if (jsonKey.contains(key))
99 destination = decorator(jsonKey[key].get<T>());
104 static inline void SetFromIfPredicate(
106 std::function<
bool(T
const&)> predicate,
107 Azure::Core::Json::_internal::json& jsonKey,
108 std::string
const& keyName,
109 std::function<std::string(T
const&)> decorator)
111 if (predicate(source))
113 jsonKey[keyName] = decorator(source);
117 template <
class T,
class R>
118 static inline void SetFromNullable(
120 Azure::Core::Json::_internal::json& jsonKey,
121 std::string
const& keyName,
122 std::function<R(T
const&)> factory)
126 jsonKey[keyName] = factory(source.
Value());
131 static inline void SetFromNullable(
133 Azure::Core::Json::_internal::json& jsonKey,
134 std::string
const& keyName)
138 jsonKey[keyName] = source.
Value();
Manages an optional contained value, i.e. a value that may or may not be present.
Definition nullable.hpp:30
const T & Value() const &noexcept
Get the contained value.
Definition nullable.hpp:236
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
Manages an optional contained value, i.e. a value that may or may not be present.