1#include <xrpl/protocol/STArray.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/contract.h>
5#include <xrpl/json/json_value.h>
6#include <xrpl/protocol/SField.h>
7#include <xrpl/protocol/STBase.h>
8#include <xrpl/protocol/Serializer.h>
26 v_ = std::move(other.v_);
48 int type = 0, field = 0;
49 sit.getFieldID(type, field);
51 if ((type == STI_ARRAY) && (field == 1))
54 if ((type == STI_OBJECT) && (field == 1))
56 JLOG(debugLog().error()) <<
"Encountered array with end of object marker";
57 Throw<std::runtime_error>(
"Illegal terminator in array");
64 JLOG(debugLog().error()) <<
"Unknown field: " << type <<
"/" << field;
65 Throw<std::runtime_error>(
"Unknown field");
68 if (fn.fieldType != STI_OBJECT)
70 JLOG(debugLog().error()) <<
"Array contains non-object";
71 Throw<std::runtime_error>(
"Non-object in array");
74 v_.emplace_back(sit, fn, depth + 1);
76 v_.back().applyTemplateFromSField(fn);
89 return emplace(n, buf, std::move(*
this));
98 for (
auto const& obj :
v_)
103 r += obj.getFullText();
134 for (
auto const&
object :
v_)
136 if (
object.
getSType() != STI_NOTPRESENT)
139 inner[
object.getFName().getJsonName()] =
object.getJson(p);
150 object.addFieldID(s);
165 auto v =
dynamic_cast<STArray const*
>(&t);
166 return v !=
nullptr &&
v_ == v->v_;
Value & append(Value const &value)
Append value to array at the end.
static SField const & getField(int fieldCode)
STArray & operator=(STArray const &)=default
std::string getFullText() const override
bool isEquivalent(STBase const &t) const override
STBase * copy(std::size_t n, void *buf) const override
std::string getText() const override
SerializedTypeID getSType() const override
void add(Serializer &s) const override
bool isDefault() const override
STBase * move(std::size_t n, void *buf) override
void sort(bool(*compare)(STObject const &o1, STObject const &o2))
json::Value getJson(JsonOptions index) const override
A type which can be exported to a well known binary format.
SField const & getFName() const
static STBase * emplace(std::size_t n, void *buf, T &&val)
void setFName(SField const &n)
A STBase is a field.
bool empty() const noexcept
int addFieldID(int type, int name)
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Note, should be treated as flags that can be | and &.