3#include <xrpl/basics/Buffer.h>
4#include <xrpl/basics/StringUtilities.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/json/json_value.h>
7#include <xrpl/protocol/SField.h>
16 char const*
const key;
22 what() const noexcept
override
34 char const*
const key;
41 what() const noexcept
override
55 static_assert(
sizeof(T) == -1,
"This function must be specialized");
65 Throw<JsonMissingKeyError>(key);
69 Throw<JsonTypeMismatchError>(key,
"string");
81 Throw<JsonMissingKeyError>(key);
86 Throw<JsonTypeMismatchError>(key,
"bool");
88 return inner.
asInt() != 0;
98 Throw<JsonMissingKeyError>(key);
104 auto const r = inner.
asInt();
106 Throw<JsonTypeMismatchError>(key,
"uint64");
115 auto [p, ec] =
std::from_chars(s.data(), s.data() + s.size(), val, 16);
117 if (ec !=
std::errc() || (p != s.data() + s.size()))
118 Throw<JsonTypeMismatchError>(key,
"uint64");
121 Throw<JsonTypeMismatchError>(key,
"uint64");
128 using namespace xrpl;
129 std::string const hex = getOrThrow<std::string>(v, field);
130 if (
auto const r = strUnHex(hex))
135 Throw<JsonTypeMismatchError>(field.getJsonName(),
"Buffer");
145 return getOrThrow<T>(v, field);
Lightweight wrapper to tag static string.
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
Like std::vector<char> but better.
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
JSON (JavaScript Object Notation).
std::optional< T > getOptional(Json::Value const &v, xrpl::SField const &field)
xrpl::AccountID getOrThrow(Json::Value const &v, xrpl::SField const &field)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
char const * what() const noexcept override
JsonMissingKeyError(Json::StaticString const &k)
char const * what() const noexcept override
JsonTypeMismatchError(Json::StaticString const &k, std::string et)
std::string const expectedType