MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / as_bool

Function as_bool

include/jsoncons/basic_json.hpp:3628–3645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3626 }
3627
3628 bool as_bool() const
3629 {
3630 switch (storage_kind())
3631 {
3632 case json_storage_kind::boolean:
3633 return cast<bool_storage>().value();
3634 case json_storage_kind::int64:
3635 return cast<int64_storage>().value() != 0;
3636 case json_storage_kind::uint64:
3637 return cast<uint64_storage>().value() != 0;
3638 case json_storage_kind::const_json_ref:
3639 return cast<const_json_ref_storage>().value().as_bool();
3640 case json_storage_kind::json_ref:
3641 return cast<json_ref_storage>().value().as_bool();
3642 default:
3643 JSONCONS_THROW(json_runtime_error<std::domain_error>("Not a bool"));
3644 }
3645 }
3646
3647 template <typename T>
3648 conversion_result<T> try_as_integer() const

Callers 1

get_Method · 0.85

Calls 3

storage_kindFunction · 0.85
as_boolMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected