20#include <xrpl/basics/Log.h>
21#include <xrpl/basics/contract.h>
22#include <xrpl/json/json_value.h>
23#include <xrpl/protocol/SField.h>
24#include <xrpl/protocol/STArray.h>
25#include <xrpl/protocol/STBase.h>
26#include <xrpl/protocol/Serializer.h>
37 :
STBase(other.getFName()), v_(
std::move(other.v_))
45 v_ = std::move(other.v_);
70 if ((type == STI_ARRAY) && (field == 1))
73 if ((type == STI_OBJECT) && (field == 1))
76 <<
"Encountered array with end of object marker";
77 Throw<std::runtime_error>(
"Illegal terminator in array");
85 <<
"Unknown field: " << type <<
"/" << field;
86 Throw<std::runtime_error>(
"Unknown field");
89 if (fn.fieldType != STI_OBJECT)
91 JLOG(
debugLog().error()) <<
"Array contains non-object";
92 Throw<std::runtime_error>(
"Non-object in array");
97 v_.
back().applyTemplateFromSField(fn);
110 return emplace(n, buf, std::move(*
this));
119 for (
auto const& obj :
v_)
124 r += obj.getFullText();
155 for (
auto const&
object :
v_)
157 if (
object.
getSType() != STI_NOTPRESENT)
160 inner[
object.getFName().getJsonName()] =
object.getJson(p);
171 object.addFieldID(s);
186 auto v =
dynamic_cast<const STArray*
>(&t);
187 return v !=
nullptr &&
v_ == v->v_;
Value & append(const Value &value)
Append value to array at the end.
static const SField & getField(int fieldCode)
std::string getFullText() const override
STBase * move(std::size_t n, void *buf) override
STBase * copy(std::size_t n, void *buf) const override
void add(Serializer &s) const override
void sort(bool(*compare)(const STObject &o1, const STObject &o2))
bool isEquivalent(const STBase &t) const override
SerializedTypeID getSType() const override
Json::Value getJson(JsonOptions index) const override
bool isDefault() const override
STArray & operator=(STArray const &)=default
std::string getText() const override
A type which can be exported to a well known binary format.
void setFName(SField const &n)
A STBase is a field.
static STBase * emplace(std::size_t n, void *buf, T &&val)
void getFieldID(int &type, int &name)
std::size_t empty() const noexcept
int addFieldID(int type, int name)
T emplace_back(T... args)
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::Journal debugLog()
Returns a debug journal.
Note, should be treated as flags that can be | and &.