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