3#include <xrpl/basics/Number.h>
4#include <xrpl/json/json_forwards.h>
51 operator char const*()
const
56 [[nodiscard]]
constexpr char const*
69 return strcmp(x.
cStr(), y.
cStr()) == 0;
164 [[nodiscard]]
char const*
197 Value(
char const* value);
230 [[nodiscard]]
char const*
286 operator bool()
const;
357 get(
char const* key,
Value const& defaultValue)
const;
526 [[nodiscard]]
char const*
637 explicit ValueIterator(Value::ObjectValues::iterator
const& current);
Lightweight wrapper to tag static string.
constexpr StaticString(char const *czString)
constexpr char const * cStr() const
Experimental do not use: Allocator to customize member name and string value memory management done b...
virtual ~ValueAllocator()=default
virtual void releaseMemberName(char *memberName)=0
virtual void releaseStringValue(char *value)=0
virtual char * makeMemberName(char const *memberName)=0
virtual char * duplicateStringValue(char const *value, unsigned int length=kUnknown)=0
static constexpr auto kUnknown
const iterator for object and array value.
SelfType & operator=(SelfType const &other)
ValueConstIterator SelfType
ValueConstIterator(ValueConstIterator const &other)=default
reference operator*() const
ValueConstIterator()=default
bool isEqual(SelfType const &other) const
ValueIteratorBase SelfType
Value::ObjectValues::iterator current_
bool operator==(SelfType const &other) const
void copy(SelfType const &other)
char const * memberName() const
Return the member name of the referenced Value.
difference_type computeDistance(SelfType const &other) const
UInt index() const
Return the index of the referenced Value. -1 if it is not an ValueType::Array.
bool operator!=(SelfType const &other) const
Value key() const
Return either the index or the member name of the referenced value as a Value.
Iterator for object and array value.
reference operator*() const
SelfType & operator=(SelfType const &other)
ValueIterator(ValueIterator const &other)
CZString & operator=(CZString const &other)=delete
bool isStaticString() const
bool operator<(CZString const &other) const
char const * cStr() const
bool operator==(CZString const &other) const
static constexpr Int kMaxInt
const_iterator begin() const
Value removeMember(char const *key)
Remove and return the named member.
bool isNull() const
isNull() tests to see if this field is null.
friend bool operator<(Value const &, Value const &)
Value get(UInt index, Value const &defaultValue) const
If the array contains at least index+1 elements, returns the element value, otherwise returns default...
ValueConstIterator const_iterator
std::vector< std::string > Members
union json::Value::ValueHolder value_
bool isValidIndex(UInt index) const
Return true if index < size().
Value & resolveReference(char const *key, bool isStatic)
std::string toStyledString() const
UInt asAbsUInt() const
Correct absolute value from int or unsigned int.
Value & append(Value const &value)
Append value to array at the end.
UInt size() const
Number of values in array or object.
Members getMemberNames() const
Return a list of the member names.
static constexpr Int kMinInt
bool isArrayOrNull() const
const_iterator end() const
Value & operator=(Value const &other)
friend bool operator==(Value const &, Value const &)
bool isConvertibleTo(ValueType other) const
std::string asString() const
Returns the unquoted string value.
void swap(Value &other) noexcept
Swap values.
static constexpr UInt kMaxUInt
Value & operator[](UInt index)
Access an array element (zero based index ).
friend class ValueIteratorBase
Value(ValueType type=ValueType::Null)
Create a default Value of the given type.
char const * asCString() const
std::map< CZString, Value > ObjectValues
bool isObjectOrNull() const
bool isMember(char const *key) const
Return true if the object has a member named key.
void clear()
Remove all object members and array elements.
Number is a floating point type that can represent a wide range of values.
JSON (JavaScript Object Notation).
bool operator!=(StaticString x, StaticString y)
bool operator>=(Value const &x, Value const &y)
Value toJson(xrpl::Number const &number)
bool operator>(Value const &x, Value const &y)
std::string to_string(Value const &)
Writes a json::Value to an std::string.
bool operator==(StaticString x, StaticString y)
bool operator<=(Value const &x, Value const &y)
ValueType
Type of the value held by a Value object.
@ String
UTF-8 string value.
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
bool operator<(Value const &, Value const &)