rippled
Loading...
Searching...
No Matches
STObject.cpp
1#include <xrpl/basics/Blob.h>
2#include <xrpl/basics/Log.h>
3#include <xrpl/basics/Slice.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/beast/utility/instrumentation.h>
7#include <xrpl/json/json_value.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/Feature.h>
10#include <xrpl/protocol/HashPrefix.h>
11#include <xrpl/protocol/InnerObjectFormats.h>
12#include <xrpl/protocol/Rules.h>
13#include <xrpl/protocol/SField.h>
14#include <xrpl/protocol/SOTemplate.h>
15#include <xrpl/protocol/STAccount.h>
16#include <xrpl/protocol/STAmount.h>
17#include <xrpl/protocol/STArray.h>
18#include <xrpl/protocol/STBase.h>
19#include <xrpl/protocol/STBitString.h>
20#include <xrpl/protocol/STBlob.h>
21#include <xrpl/protocol/STCurrency.h>
22#include <xrpl/protocol/STInteger.h>
23#include <xrpl/protocol/STIssue.h>
24#include <xrpl/protocol/STNumber.h>
25#include <xrpl/protocol/STObject.h>
26#include <xrpl/protocol/STPathSet.h>
27#include <xrpl/protocol/STVector256.h>
28#include <xrpl/protocol/Serializer.h>
29#include <xrpl/protocol/detail/STVar.h>
30
31#include <algorithm>
32#include <cstddef>
33#include <cstdint>
34#include <memory>
35#include <optional>
36#include <sstream>
37#include <stdexcept>
38#include <string>
39#include <utility>
40#include <vector>
41
42namespace xrpl {
43
45 : STBase(other.getFName()), v_(std::move(other.v_)), mType(other.mType)
46{
47}
48
49STObject::STObject(SField const& name) : STBase(name), mType(nullptr)
50{
51}
52
53STObject::STObject(SOTemplate const& type, SField const& name) : STBase(name)
54{
55 set(type);
56}
57
58STObject::STObject(SOTemplate const& type, SerialIter& sit, SField const& name) : STBase(name)
59{
60 v_.reserve(type.size());
61 set(sit);
62 applyTemplate(type); // May throw
63}
64
65STObject::STObject(SerialIter& sit, SField const& name, int depth) noexcept(false)
66 : STBase(name), mType(nullptr)
67{
68 if (depth > 10)
69 Throw<std::runtime_error>("Maximum nesting depth of STObject exceeded");
70 set(sit, depth);
71}
72
75{
76 STObject obj{name};
77
78 // The if is complicated because inner object templates were added in
79 // two phases:
80 // 1. If there are no available Rules, then always apply the template.
81 // 2. fixInnerObjTemplate added templates to two AMM inner objects.
82 // 3. fixInnerObjTemplate2 added templates to all remaining inner objects.
84 bool const isAMMObj = name == sfAuctionSlot || name == sfVoteEntry;
85 if (!rules || (rules->enabled(fixInnerObjTemplate) && isAMMObj) ||
86 (rules->enabled(fixInnerObjTemplate2) && !isAMMObj))
87 {
88 if (SOTemplate const* elements =
89 InnerObjectFormats::getInstance().findSOTemplateBySField(name))
90 obj.set(*elements);
91 }
92 return obj;
93}
94
95STBase*
96STObject::copy(std::size_t n, void* buf) const
97{
98 return emplace(n, buf, *this);
99}
100
101STBase*
103{
104 return emplace(n, buf, std::move(*this));
105}
106
109{
110 return STI_OBJECT;
111}
112
113bool
115{
116 return v_.empty();
117}
118
119void
121{
122 add(s, withAllFields); // just inner elements
123}
124
127{
128 setFName(other.getFName());
129 mType = other.mType;
130 v_ = std::move(other.v_);
131 return *this;
132}
133
134void
136{
137 v_.clear();
138 v_.reserve(type.size());
139 mType = &type;
140
141 for (auto const& elem : type)
142 {
143 if (elem.style() != soeREQUIRED)
145 else
146 v_.emplace_back(detail::defaultObject, elem.sField());
147 }
148}
149
150void
152{
153 auto throwFieldErr = [](std::string const& field, char const* description) {
155 ss << "Field '" << field << "' " << description;
156 std::string text{ss.str()};
157 JLOG(debugLog().error()) << "STObject::applyTemplate failed: " << text;
158 Throw<FieldErr>(text);
159 };
160
161 mType = &type;
162 decltype(v_) v;
163 v.reserve(type.size());
164 for (auto const& e : type)
165 {
166 auto const iter = std::find_if(v_.begin(), v_.end(), [&](detail::STVar const& b) {
167 return b.get().getFName() == e.sField();
168 });
169 if (iter != v_.end())
170 {
171 if ((e.style() == soeDEFAULT) && iter->get().isDefault())
172 {
173 throwFieldErr(e.sField().fieldName, "may not be explicitly set to default.");
174 }
175 v.emplace_back(std::move(*iter));
176 v_.erase(iter);
177 }
178 else
179 {
180 if (e.style() == soeREQUIRED)
181 {
182 throwFieldErr(e.sField().fieldName, "is required but missing.");
183 }
184 v.emplace_back(detail::nonPresentObject, e.sField());
185 }
186 }
187 for (auto const& e : v_)
188 {
189 // Anything left over in the object must be discardable
190 if (!e->getFName().isDiscardable())
191 {
192 throwFieldErr(e->getFName().getName(), "found in disallowed location.");
193 }
194 }
195 // Swap the template matching data in for the old data,
196 // freeing any leftover junk
197 v_.swap(v);
198}
199
200void
202{
204 if (elements)
205 applyTemplate(*elements); // May throw
206}
207
208// return true = terminated with end-of-object
209bool
210STObject::set(SerialIter& sit, int depth)
211{
212 bool reachedEndOfObject = false;
213
214 v_.clear();
215
216 // Consume data in the pipe until we run out or reach the end
217 while (!sit.empty())
218 {
219 int type;
220 int field;
221
222 // Get the metadata for the next field
223 sit.getFieldID(type, field);
224
225 // The object termination marker has been found and the termination
226 // marker has been consumed. Done deserializing.
227 if (type == STI_OBJECT && field == 1)
228 {
229 reachedEndOfObject = true;
230 break;
231 }
232
233 if (type == STI_ARRAY && field == 1)
234 {
235 JLOG(debugLog().error()) << "Encountered object with embedded end-of-array marker";
236 Throw<std::runtime_error>("Illegal end-of-array marker in object");
237 }
238
239 auto const& fn = SField::getField(type, field);
240
241 if (fn.isInvalid())
242 {
243 JLOG(debugLog().error())
244 << "Unknown field: field_type=" << type << ", field_name=" << field;
245 Throw<std::runtime_error>("Unknown field");
246 }
247
248 // Unflatten the field
249 v_.emplace_back(sit, fn, depth + 1);
250
251 // If the object type has a known SOTemplate then set it.
252 if (auto const obj = dynamic_cast<STObject*>(&(v_.back().get())))
253 obj->applyTemplateFromSField(fn); // May throw
254 }
255
256 // We want to ensure that the deserialized object does not contain any
257 // duplicate fields. This is a key invariant:
258 auto const sf = getSortedFields(*this, withAllFields);
259
260 auto const dup =
261 std::adjacent_find(sf.cbegin(), sf.cend(), [](STBase const* lhs, STBase const* rhs) {
262 return lhs->getFName() == rhs->getFName();
263 });
264
265 if (dup != sf.cend())
266 Throw<std::runtime_error>("Duplicate field detected");
267
268 return reachedEndOfObject;
269}
270
271bool
273{
274 STBase const* o = peekAtPField(t.getFName());
275
276 if (!o)
277 return false;
278
279 return t == *o;
280}
281
284{
285 std::string ret;
286 bool first = true;
287
288 if (getFName().hasName())
289 {
290 ret = getFName().getName();
291 ret += " = {";
292 }
293 else
294 ret = "{";
295
296 for (auto const& elem : v_)
297 {
298 if (elem->getSType() != STI_NOTPRESENT)
299 {
300 if (!first)
301 ret += ", ";
302 else
303 first = false;
304
305 ret += elem->getFullText();
306 }
307 }
308
309 ret += "}";
310 return ret;
311}
312
315{
316 std::string ret = "{";
317 bool first = false;
318 for (auto const& elem : v_)
319 {
320 if (!first)
321 {
322 ret += ", ";
323 first = false;
324 }
325
326 ret += elem->getText();
327 }
328 ret += "}";
329 return ret;
330}
331
332bool
334{
335 STObject const* v = dynamic_cast<STObject const*>(&t);
336
337 if (!v)
338 return false;
339
340 if (mType != nullptr && v->mType == mType)
341 {
342 return std::equal(
343 begin(), end(), v->begin(), v->end(), [](STBase const& st1, STBase const& st2) {
344 return (st1.getSType() == st2.getSType()) && st1.isEquivalent(st2);
345 });
346 }
347
348 auto const sf1 = getSortedFields(*this, withAllFields);
349 auto const sf2 = getSortedFields(*v, withAllFields);
350
351 return std::equal(
352 sf1.begin(), sf1.end(), sf2.begin(), sf2.end(), [](STBase const* st1, STBase const* st2) {
353 return (st1->getSType() == st2->getSType()) && st1->isEquivalent(*st2);
354 });
355}
356
359{
360 Serializer s;
361 s.add32(prefix);
362 add(s, withAllFields);
363 return s.getSHA512Half();
364}
365
368{
369 Serializer s;
370 s.add32(prefix);
372 return s.getSHA512Half();
373}
374
375int
377{
378 if (mType != nullptr)
379 return mType->getIndex(field);
380
381 int i = 0;
382 for (auto const& elem : v_)
383 {
384 if (elem->getFName() == field)
385 return i;
386 ++i;
387 }
388 return -1;
389}
390
391STBase const&
392STObject::peekAtField(SField const& field) const
393{
394 int index = getFieldIndex(field);
395
396 if (index == -1)
397 throwFieldNotFound(field);
398
399 return peekAtIndex(index);
400}
401
402STBase&
404{
405 int index = getFieldIndex(field);
406
407 if (index == -1)
408 throwFieldNotFound(field);
409
410 return getIndex(index);
411}
412
413SField const&
415{
416 return v_[index]->getFName();
417}
418
419STBase const*
421{
422 int index = getFieldIndex(field);
423
424 if (index == -1)
425 return nullptr;
426
427 return peekAtPIndex(index);
428}
429
430STBase*
431STObject::getPField(SField const& field, bool createOkay)
432{
433 int index = getFieldIndex(field);
434
435 if (index == -1)
436 {
437 if (createOkay && isFree())
439
440 return nullptr;
441 }
442
443 return getPIndex(index);
444}
445
446bool
448{
449 int index = getFieldIndex(field);
450
451 if (index == -1)
452 return false;
453
454 return peekAtIndex(index).getSType() != STI_NOTPRESENT;
455}
456
459{
460 return peekField<STObject>(field);
461}
462
463STArray&
465{
466 return peekField<STArray>(field);
467}
468
469bool
471{
472 STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags, true));
473
474 if (!t)
475 return false;
476
477 t->setValue(t->value() | f);
478 return true;
479}
480
481bool
483{
484 STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags));
485
486 if (!t)
487 return false;
488
489 t->setValue(t->value() & ~f);
490 return true;
491}
492
493bool
495{
496 return (getFlags() & f) == f;
497}
498
501{
502 STUInt32 const* t = dynamic_cast<STUInt32 const*>(peekAtPField(sfFlags));
503
504 if (!t)
505 return 0;
506
507 return t->value();
508}
509
510STBase*
512{
513 int index = getFieldIndex(field);
514
515 if (index == -1)
516 {
517 if (!isFree())
518 throwFieldNotFound(field);
519
521 }
522
523 STBase* f = getPIndex(index);
524
525 if (f->getSType() != STI_NOTPRESENT)
526 return f;
527
529 return getPIndex(index);
530}
531
532void
534{
535 int index = getFieldIndex(field);
536
537 if (index == -1)
538 throwFieldNotFound(field);
539
540 STBase const& f = peekAtIndex(index);
541
542 if (f.getSType() == STI_NOTPRESENT)
543 return;
545}
546
547bool
549{
550 int index = getFieldIndex(field);
551
552 if (index == -1)
553 return false;
554
555 delField(index);
556 return true;
557}
558
559void
561{
562 v_.erase(v_.begin() + index);
563}
564
566STObject::getStyle(SField const& field) const
567{
568 return mType ? mType->style(field) : soeINVALID;
569}
570
571unsigned char
572STObject::getFieldU8(SField const& field) const
573{
574 return getFieldByValue<STUInt8>(field);
575}
576
578STObject::getFieldU16(SField const& field) const
579{
580 return getFieldByValue<STUInt16>(field);
581}
582
584STObject::getFieldU32(SField const& field) const
585{
586 return getFieldByValue<STUInt32>(field);
587}
588
590STObject::getFieldU64(SField const& field) const
591{
592 return getFieldByValue<STUInt64>(field);
593}
594
597{
598 return getFieldByValue<STUInt128>(field);
599}
600
603{
604 return getFieldByValue<STUInt160>(field);
605}
606
609{
610 return getFieldByValue<STUInt192>(field);
611}
612
615{
616 return getFieldByValue<STUInt256>(field);
617}
618
620STObject::getFieldI32(SField const& field) const
621{
622 return getFieldByValue<STInt32>(field);
623}
624
627{
628 return getFieldByValue<STAccount>(field);
629}
630
631Blob
632STObject::getFieldVL(SField const& field) const
633{
635 STBlob const& b = getFieldByConstRef<STBlob>(field, empty);
636 return Blob(b.data(), b.data() + b.size());
637}
638
639STAmount const&
641{
642 static STAmount const empty{};
643 return getFieldByConstRef<STAmount>(field, empty);
644}
645
646STPathSet const&
648{
649 static STPathSet const empty{};
650 return getFieldByConstRef<STPathSet>(field, empty);
651}
652
653STVector256 const&
655{
656 static STVector256 const empty{};
657 return getFieldByConstRef<STVector256>(field, empty);
658}
659
662{
663 STObject const empty{field};
664 auto ret = getFieldByConstRef<STObject>(field, empty);
665 if (ret != empty)
666 ret.applyTemplateFromSField(field);
667 return ret;
668}
669
670STArray const&
672{
673 static STArray const empty{};
674 return getFieldByConstRef<STArray>(field, empty);
675}
676
677STCurrency const&
679{
680 static STCurrency const empty{};
681 return getFieldByConstRef<STCurrency>(field, empty);
682}
683
684STNumber const&
686{
687 static STNumber const empty{};
688 return getFieldByConstRef<STNumber>(field, empty);
689}
690
691void
693{
694 set(std::move(*v.get()));
695}
696
697void
699{
700 auto const i = getFieldIndex(v.getFName());
701 if (i != -1)
702 {
703 v_[i] = std::move(v);
704 }
705 else
706 {
707 if (!isFree())
708 Throw<std::runtime_error>("missing field in templated STObject");
709 v_.emplace_back(std::move(v));
710 }
711}
712
713void
714STObject::setFieldU8(SField const& field, unsigned char v)
715{
716 setFieldUsingSetValue<STUInt8>(field, v);
717}
718
719void
721{
722 setFieldUsingSetValue<STUInt16>(field, v);
723}
724
725void
727{
728 setFieldUsingSetValue<STUInt32>(field, v);
729}
730
731void
733{
734 setFieldUsingSetValue<STUInt64>(field, v);
735}
736
737void
738STObject::setFieldH128(SField const& field, uint128 const& v)
739{
740 setFieldUsingSetValue<STUInt128>(field, v);
741}
742
743void
744STObject::setFieldH256(SField const& field, uint256 const& v)
745{
746 setFieldUsingSetValue<STUInt256>(field, v);
747}
748
749void
751{
752 setFieldUsingSetValue<STInt32>(field, v);
753}
754
755void
757{
758 setFieldUsingSetValue<STVector256>(field, v);
759}
760
761void
763{
764 setFieldUsingSetValue<STAccount>(field, v);
765}
766
767void
768STObject::setFieldVL(SField const& field, Blob const& v)
769{
770 setFieldUsingSetValue<STBlob>(field, Buffer(v.data(), v.size()));
771}
772
773void
774STObject::setFieldVL(SField const& field, Slice const& s)
775{
776 setFieldUsingSetValue<STBlob>(field, Buffer(s.data(), s.size()));
777}
778
779void
781{
782 setFieldUsingAssignment(field, v);
783}
784
785void
787{
788 setFieldUsingAssignment(field, v);
789}
790
791void
793{
794 setFieldUsingAssignment(field, v);
795}
796
797void
799{
800 setFieldUsingAssignment(field, v);
801}
802
803void
805{
806 setFieldUsingAssignment(field, v);
807}
808
809void
811{
812 setFieldUsingAssignment(field, v);
813}
814
815void
817{
818 setFieldUsingAssignment(field, v);
819}
820
823{
825
826 for (auto const& elem : v_)
827 {
828 if (elem->getSType() != STI_NOTPRESENT)
829 ret[elem->getFName().getJsonName()] = elem->getJson(options);
830 }
831 return ret;
832}
833
834bool
836{
837 // This is not particularly efficient, and only compares data elements
838 // with binary representations
839 int matches = 0;
840 for (auto const& t1 : v_)
841 {
842 if ((t1->getSType() != STI_NOTPRESENT) && t1->getFName().isBinary())
843 {
844 // each present field must have a matching field
845 bool match = false;
846 for (auto const& t2 : obj.v_)
847 {
848 if (t1->getFName() == t2->getFName())
849 {
850 if (t2 != t1)
851 return false;
852
853 match = true;
854 ++matches;
855 break;
856 }
857 }
858
859 if (!match)
860 return false;
861 }
862 }
863
864 int fields = 0;
865 for (auto const& t2 : obj.v_)
866 {
867 if ((t2->getSType() != STI_NOTPRESENT) && t2->getFName().isBinary())
868 ++fields;
869 }
870
871 if (fields != matches)
872 return false;
873
874 return true;
875}
876
877void
879{
880 // Depending on whichFields, signing fields are either serialized or
881 // not. Then fields are added to the Serializer sorted by fieldCode.
882 std::vector<STBase const*> const fields{getSortedFields(*this, whichFields)};
883
884 // insert sorted
885 for (STBase const* const field : fields)
886 {
887 // When we serialize an object inside another object,
888 // the type associated by rule with this field name
889 // must be OBJECT, or the object cannot be deserialized
890 SerializedTypeID const sType{field->getSType()};
891 XRPL_ASSERT(
892 (sType != STI_OBJECT) || (field->getFName().fieldType == STI_OBJECT),
893 "xrpl::STObject::add : valid field type");
894 field->addFieldID(s);
895 field->add(s);
896 if (sType == STI_ARRAY || sType == STI_OBJECT)
897 s.addFieldID(sType, 1);
898 }
899}
900
902STObject::getSortedFields(STObject const& objToSort, WhichFields whichFields)
903{
905 sf.reserve(objToSort.getCount());
906
907 // Choose the fields that we need to sort.
908 for (detail::STVar const& elem : objToSort.v_)
909 {
910 STBase const& base = elem.get();
911 if ((base.getSType() != STI_NOTPRESENT) && base.getFName().shouldInclude(whichFields))
912 {
913 sf.push_back(&base);
914 }
915 }
916
917 // Sort the fields by fieldCode.
918 std::sort(sf.begin(), sf.end(), [](STBase const* lhs, STBase const* rhs) {
919 return lhs->getFName().fieldCode < rhs->getFName().fieldCode;
920 });
921
922 return sf;
923}
924
925} // namespace xrpl
T adjacent_find(T... args)
T back(T... args)
T begin(T... args)
Represents a JSON value.
Definition json_value.h:130
Like std::vector<char> but better.
Definition Buffer.h:16
SOTemplate const * findSOTemplateBySField(SField const &sField) const
static InnerObjectFormats const & getInstance()
Identifies fields.
Definition SField.h:126
static SField const & getField(int fieldCode)
Definition SField.cpp:114
bool shouldInclude(bool withSigningField) const
Definition SField.h:266
std::string const & getName() const
Definition SField.h:193
Defines the fields and their attributes within a STObject.
Definition SOTemplate.h:91
int getIndex(SField const &) const
Retrieve the position of a named field.
SOEStyle style(SField const &sf) const
Definition SOTemplate.h:144
std::size_t size() const
The number of entries in this template.
Definition SOTemplate.h:134
A type which can be exported to a well known binary format.
Definition STBase.h:115
SField const & getFName() const
Definition STBase.cpp:122
static STBase * emplace(std::size_t n, void *buf, T &&val)
Definition STBase.h:213
virtual SerializedTypeID getSType() const
Definition STBase.cpp:56
void setFName(SField const &n)
A STBase is a field.
Definition STBase.cpp:115
std::size_t size() const
Definition STBlob.h:90
std::uint8_t const * data() const
Definition STBlob.h:96
value_type value() const noexcept
Definition STInteger.h:124
void setValue(Integer v)
Definition STInteger.h:131
A serializable number.
Definition STNumber.h:35
void setFieldU8(SField const &field, unsigned char)
Definition STObject.cpp:714
SField const & getFieldSType(int index) const
Definition STObject.cpp:414
uint192 getFieldH192(SField const &field) const
Definition STObject.cpp:608
bool isFree() const
Definition STObject.h:962
STBase const * peekAtPIndex(int offset) const
Definition STObject.h:1011
Json::Value getJson(JsonOptions=JsonOptions::none) const override
Definition STObject.cpp:822
STCurrency const & getFieldCurrency(SField const &field) const
Definition STObject.cpp:678
Blob getFieldVL(SField const &field) const
Definition STObject.cpp:632
void setFieldIssue(SField const &field, STIssue const &)
Definition STObject.cpp:792
uint128 getFieldH128(SField const &field) const
Definition STObject.cpp:596
iterator begin() const
Definition STObject.h:938
bool operator==(STObject const &o) const
Definition STObject.cpp:835
bool isEquivalent(STBase const &t) const override
Definition STObject.cpp:333
bool empty() const
Definition STObject.h:950
void setFieldNumber(SField const &field, STNumber const &)
Definition STObject.cpp:798
void setFieldV256(SField const &field, STVector256 const &v)
Definition STObject.cpp:756
void setFieldU64(SField const &field, std::uint64_t)
Definition STObject.cpp:732
unsigned char getFieldU8(SField const &field) const
Definition STObject.cpp:572
std::uint32_t getFieldU32(SField const &field) const
Definition STObject.cpp:584
STBase const & peekAtIndex(int offset) const
Definition STObject.h:999
bool hasMatchingEntry(STBase const &)
Definition STObject.cpp:272
STNumber const & getFieldNumber(SField const &field) const
Definition STObject.cpp:685
void setFieldVL(SField const &field, Blob const &)
Definition STObject.cpp:768
std::size_t emplace_back(Args &&... args)
Definition STObject.h:986
iterator end() const
Definition STObject.h:944
void applyTemplate(SOTemplate const &type)
Definition STObject.cpp:151
int getFieldIndex(SField const &field) const
Definition STObject.cpp:376
uint256 getHash(HashPrefix prefix) const
Definition STObject.cpp:358
void setFieldI32(SField const &field, std::int32_t)
Definition STObject.cpp:750
std::string getFullText() const override
Definition STObject.cpp:283
SOTemplate const * mType
Definition STObject.h:60
void setFieldU32(SField const &field, std::uint32_t)
Definition STObject.cpp:726
list_type v_
Definition STObject.h:59
STArray & peekFieldArray(SField const &field)
Definition STObject.cpp:464
std::string getText() const override
Definition STObject.cpp:314
STArray const & getFieldArray(SField const &field) const
Definition STObject.cpp:671
void setFieldArray(SField const &field, STArray const &v)
Definition STObject.cpp:810
STObject & peekFieldObject(SField const &field)
Definition STObject.cpp:458
SOEStyle getStyle(SField const &field) const
Definition STObject.cpp:566
STBase & getField(SField const &field)
Definition STObject.cpp:403
void setFieldAmount(SField const &field, STAmount const &)
Definition STObject.cpp:780
void add(Serializer &s) const override
Definition STObject.cpp:120
bool isFlag(std::uint32_t) const
Definition STObject.cpp:494
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:447
STObject & operator=(STObject const &)=default
STObject(STObject const &)=default
int getCount() const
Definition STObject.h:993
SerializedTypeID getSType() const override
Definition STObject.cpp:108
void setFieldU16(SField const &field, std::uint16_t)
Definition STObject.cpp:720
uint256 getFieldH256(SField const &field) const
Definition STObject.cpp:614
static STObject makeInnerObject(SField const &name)
Definition STObject.cpp:74
std::int32_t getFieldI32(SField const &field) const
Definition STObject.cpp:620
STBase const & peekAtField(SField const &field) const
Definition STObject.cpp:392
void set(SOTemplate const &)
Definition STObject.cpp:135
uint256 getSigningHash(HashPrefix prefix) const
Definition STObject.cpp:367
bool clearFlag(std::uint32_t)
Definition STObject.cpp:482
void setFieldCurrency(SField const &field, STCurrency const &)
Definition STObject.cpp:786
std::uint64_t getFieldU64(SField const &field) const
Definition STObject.cpp:590
void setFieldPathSet(SField const &field, STPathSet const &)
Definition STObject.cpp:804
STBase * move(std::size_t n, void *buf) override
Definition STObject.cpp:102
static std::vector< STBase const * > getSortedFields(STObject const &objToSort, WhichFields whichFields)
Definition STObject.cpp:902
STBase * getPField(SField const &field, bool createOkay=false)
Definition STObject.cpp:431
STBase * makeFieldPresent(SField const &field)
Definition STObject.cpp:511
STBase const * peekAtPField(SField const &field) const
Definition STObject.cpp:420
void applyTemplateFromSField(SField const &)
Definition STObject.cpp:201
bool setFlag(std::uint32_t)
Definition STObject.cpp:470
void setFieldObject(SField const &field, STObject const &v)
Definition STObject.cpp:816
void setFieldH128(SField const &field, uint128 const &)
Definition STObject.cpp:738
STObject getFieldObject(SField const &field) const
Definition STObject.cpp:661
void setAccountID(SField const &field, AccountID const &)
Definition STObject.cpp:762
void setFieldUsingAssignment(SField const &field, T const &value)
Definition STObject.h:1222
bool delField(SField const &field)
Definition STObject.cpp:548
STBase & getIndex(int offset)
Definition STObject.h:1005
uint160 getFieldH160(SField const &field) const
Definition STObject.cpp:602
AccountID getAccountID(SField const &field) const
Definition STObject.cpp:626
STBase * getPIndex(int offset)
Definition STObject.h:1017
STVector256 const & getFieldV256(SField const &field) const
Definition STObject.cpp:654
STPathSet const & getFieldPathSet(SField const &field) const
Definition STObject.cpp:647
bool isDefault() const override
Definition STObject.cpp:114
void makeFieldAbsent(SField const &field)
Definition STObject.cpp:533
void setFieldH256(SField const &field, uint256 const &)
Definition STObject.cpp:744
std::uint16_t getFieldU16(SField const &field) const
Definition STObject.cpp:578
STAmount const & getFieldAmount(SField const &field) const
Definition STObject.cpp:640
std::uint32_t getFlags() const
Definition STObject.cpp:500
STBase * copy(std::size_t n, void *buf) const override
Definition STObject.cpp:96
std::size_t empty() const noexcept
Definition Serializer.h:340
void getFieldID(int &type, int &name)
int addFieldID(int type, int name)
uint256 getSHA512Half() const
An immutable linear range of bytes.
Definition Slice.h:26
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Definition Slice.h:78
std::size_t size() const noexcept
Returns the number of bytes in the storage.
Definition Slice.h:61
T clear(T... args)
T data(T... args)
T emplace_back(T... args)
T empty(T... args)
T end(T... args)
T equal(T... args)
T erase(T... args)
T find_if(T... args)
T get(T... args)
@ objectValue
object value (collection of name/value pairs).
Definition json_value.h:26
STL namespace.
nonPresentObject_t nonPresentObject
Definition STVar.cpp:29
defaultObject_t defaultObject
Definition STVar.cpp:28
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool set(T &target, std::string const &name, Section const &section)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
void throwFieldNotFound(SField const &field)
Definition STObject.h:31
beast::Journal debugLog()
Returns a debug journal.
Definition Log.cpp:449
SOEStyle
Kind of element in each entry of an SOTemplate.
Definition SOTemplate.h:13
@ soeINVALID
Definition SOTemplate.h:14
@ soeDEFAULT
Definition SOTemplate.h:17
@ soeREQUIRED
Definition SOTemplate.h:15
bool matches(char const *string, char const *regex)
Return true if the string loosely matches the regex.
Definition STTx_test.cpp:22
std::optional< Rules > const & getCurrentTransactionRules()
Definition Rules.cpp:31
SerializedTypeID
Definition SField.h:90
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:10
HashPrefix
Prefix for hashing functions.
Definition HashPrefix.h:34
T push_back(T... args)
T reserve(T... args)
T size(T... args)
T sort(T... args)
T str(T... args)
Note, should be treated as flags that can be | and &.
Definition STBase.h:17
T swap(T... args)