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