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