MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / value

Function value

Source/Utils/json.hpp:20278–20294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20276 detail::is_getable<basic_json_t, ValueType>::value
20277 && !std::is_same<value_t, ValueType>::value, int >::type = 0 >
20278 ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
20279 {
20280 // at only works for objects
20281 if (JSON_HEDLEY_LIKELY(is_object()))
20282 {
20283 // if key is found, return value and given default value otherwise
20284 const auto it = find(key);
20285 if (it != end())
20286 {
20287 return it->template get<ValueType>();
20288 }
20289
20290 return default_value;
20291 }
20292
20293 JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
20294 }
20295
20296 /*!
20297 @brief overload for a default value of type const char*

Callers

nothing calls this directly

Calls 5

is_objectFunction · 0.85
findFunction · 0.85
createFunction · 0.85
type_nameFunction · 0.85
endFunction · 0.70

Tested by

no test coverage detected