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)
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) : STBase(name)
66{
67 if (depth > 10)
68 Throw<std::runtime_error>("Maximum nesting depth of STObject exceeded");
69 set(sit, depth);
70}
71
74{
75 STObject obj{name};
76
77 // The if is complicated because inner object templates were added in
78 // two phases:
79 // 1. If there are no available Rules, then always apply the template.
80 // 2. fixInnerObjTemplate added templates to two AMM inner objects.
81 // 3. fixInnerObjTemplate2 added templates to all remaining inner objects.
83 bool const isAMMObj = name == sfAuctionSlot || name == sfVoteEntry;
84 if (!rules || (rules->enabled(fixInnerObjTemplate) && isAMMObj) ||
85 (rules->enabled(fixInnerObjTemplate2) && !isAMMObj))
86 {
87 if (SOTemplate const* elements =
88 InnerObjectFormats::getInstance().findSOTemplateBySField(name))
89 obj.set(*elements);
90 }
91 return obj;
92}
93
94STBase*
95STObject::copy(std::size_t n, void* buf) const
96{
97 return emplace(n, buf, *this);
98}
99
100STBase*
102{
103 return emplace(n, buf, std::move(*this));
104}
105
108{
109 return STI_OBJECT;
110}
111
112bool
114{
115 return v_.empty();
116}
117
118void
120{
121 add(s, withAllFields); // just inner elements
122}
123
126{
127 setFName(other.getFName());
128 mType = other.mType;
129 v_ = std::move(other.v_);
130 return *this;
131}
132
133void
135{
136 v_.clear();
137 v_.reserve(type.size());
138 mType = &type;
139
140 for (auto const& elem : type)
141 {
142 if (elem.style() != soeREQUIRED)
143 {
145 }
146 else
147 {
148 v_.emplace_back(detail::defaultObject, elem.sField());
149 }
150 }
151}
152
153void
155{
156 auto throwFieldErr = [](std::string const& field, char const* description) {
158 ss << "Field '" << field << "' " << description;
159 std::string const text{ss.str()};
160 JLOG(debugLog().error()) << "STObject::applyTemplate failed: " << text;
161 Throw<FieldErr>(text);
162 };
163
164 mType = &type;
165 decltype(v_) v;
166 v.reserve(type.size());
167 for (auto const& e : type)
168 {
169 auto const iter = std::find_if(v_.begin(), v_.end(), [&](detail::STVar const& b) {
170 return b.get().getFName() == e.sField();
171 });
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::nonPresentObject, 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, withAllFields);
262
263 auto const dup =
264 std::adjacent_find(sf.cbegin(), sf.cend(), [](STBase const* lhs, STBase const* rhs) {
265 return lhs->getFName() == rhs->getFName();
266 });
267
268 if (dup != sf.cend())
269 Throw<std::runtime_error>("Duplicate field detected");
270
271 return reachedEndOfObject;
272}
273
274bool
276{
277 STBase const* o = peekAtPField(t.getFName());
278
279 if (o == nullptr)
280 return false;
281
282 return t == *o;
283}
284
287{
288 std::string ret;
289 bool first = true;
290
291 if (getFName().hasName())
292 {
293 ret = getFName().getName();
294 ret += " = {";
295 }
296 else
297 {
298 ret = "{";
299 }
300
301 for (auto const& elem : v_)
302 {
303 if (elem->getSType() != STI_NOTPRESENT)
304 {
305 if (!first)
306 {
307 ret += ", ";
308 }
309 else
310 {
311 first = false;
312 }
313
314 ret += elem->getFullText();
315 }
316 }
317
318 ret += "}";
319 return ret;
320}
321
324{
325 std::string ret = "{";
326 bool first = false;
327 for (auto const& elem : v_)
328 {
329 if (!first)
330 {
331 ret += ", ";
332 first = false;
333 }
334
335 ret += elem->getText();
336 }
337 ret += "}";
338 return ret;
339}
340
341bool
343{
344 STObject const* v = dynamic_cast<STObject const*>(&t);
345
346 if (v == nullptr)
347 return false;
348
349 if (mType != nullptr && v->mType == mType)
350 {
351 return std::equal(
352 begin(), end(), v->begin(), v->end(), [](STBase const& st1, STBase const& st2) {
353 return (st1.getSType() == st2.getSType()) && st1.isEquivalent(st2);
354 });
355 }
356
357 auto const sf1 = getSortedFields(*this, withAllFields);
358 auto const sf2 = getSortedFields(*v, withAllFields);
359
360 return std::equal(
361 sf1.begin(), sf1.end(), sf2.begin(), sf2.end(), [](STBase const* st1, STBase const* st2) {
362 return (st1->getSType() == st2->getSType()) && st1->isEquivalent(*st2);
363 });
364}
365
368{
369 Serializer s;
370 s.add32(prefix);
371 add(s, withAllFields);
372 return s.getSHA512Half();
373}
374
377{
378 Serializer s;
379 s.add32(prefix);
381 return s.getSHA512Half();
382}
383
384int
386{
387 if (mType != nullptr)
388 return mType->getIndex(field);
389
390 int i = 0;
391 for (auto const& elem : v_)
392 {
393 if (elem->getFName() == field)
394 return i;
395 ++i;
396 }
397 return -1;
398}
399
400STBase const&
401STObject::peekAtField(SField const& field) const
402{
403 int const index = getFieldIndex(field);
404
405 if (index == -1)
406 throwFieldNotFound(field);
407
408 return peekAtIndex(index);
409}
410
411STBase&
413{
414 int const index = getFieldIndex(field);
415
416 if (index == -1)
417 throwFieldNotFound(field);
418
419 return getIndex(index);
420}
421
422SField const&
424{
425 return v_[index]->getFName();
426}
427
428STBase const*
430{
431 int const index = getFieldIndex(field);
432
433 if (index == -1)
434 return nullptr;
435
436 return peekAtPIndex(index);
437}
438
439STBase*
440STObject::getPField(SField const& field, bool createOkay)
441{
442 int const index = getFieldIndex(field);
443
444 if (index == -1)
445 {
446 if (createOkay && isFree())
448
449 return nullptr;
450 }
451
452 return getPIndex(index);
453}
454
455bool
457{
458 int const index = getFieldIndex(field);
459
460 if (index == -1)
461 return false;
462
463 return peekAtIndex(index).getSType() != STI_NOTPRESENT;
464}
465
468{
469 return peekField<STObject>(field);
470}
471
472STArray&
474{
475 return peekField<STArray>(field);
476}
477
478bool
480{
481 STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags, true));
482
483 if (t == nullptr)
484 return false;
485
486 t->setValue(t->value() | f);
487 return true;
488}
489
490bool
492{
493 STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags));
494
495 if (t == nullptr)
496 return false;
497
498 t->setValue(t->value() & ~f);
499 return true;
500}
501
502bool
504{
505 return (getFlags() & f) == f;
506}
507
510{
511 STUInt32 const* t = dynamic_cast<STUInt32 const*>(peekAtPField(sfFlags));
512
513 if (t == nullptr)
514 return 0;
515
516 return t->value();
517}
518
519STBase*
521{
522 int const index = getFieldIndex(field);
523
524 if (index == -1)
525 {
526 if (!isFree())
527 throwFieldNotFound(field);
528
530 }
531
532 STBase* f = getPIndex(index); // NOLINT(misc-const-correctness)
533
534 if (f->getSType() != STI_NOTPRESENT)
535 return f;
536
538 return getPIndex(index);
539}
540
541void
543{
544 int const index = getFieldIndex(field);
545
546 if (index == -1)
547 throwFieldNotFound(field);
548
549 STBase const& f = peekAtIndex(index);
550
551 if (f.getSType() == STI_NOTPRESENT)
552 return;
554}
555
556bool
558{
559 int const index = getFieldIndex(field);
560
561 if (index == -1)
562 return false;
563
564 delField(index);
565 return true;
566}
567
568void
570{
571 v_.erase(v_.begin() + index);
572}
573
575STObject::getStyle(SField const& field) const
576{
577 return (mType != nullptr) ? mType->style(field) : soeINVALID;
578}
579
580unsigned char
581STObject::getFieldU8(SField const& field) const
582{
583 return getFieldByValue<STUInt8>(field);
584}
585
587STObject::getFieldU16(SField const& field) const
588{
589 return getFieldByValue<STUInt16>(field);
590}
591
593STObject::getFieldU32(SField const& field) const
594{
595 return getFieldByValue<STUInt32>(field);
596}
597
599STObject::getFieldU64(SField const& field) const
600{
601 return getFieldByValue<STUInt64>(field);
602}
603
606{
607 return getFieldByValue<STUInt128>(field);
608}
609
612{
613 return getFieldByValue<STUInt160>(field);
614}
615
618{
619 return getFieldByValue<STUInt192>(field);
620}
621
624{
625 return getFieldByValue<STUInt256>(field);
626}
627
629STObject::getFieldI32(SField const& field) const
630{
631 return getFieldByValue<STInt32>(field);
632}
633
636{
637 return getFieldByValue<STAccount>(field);
638}
639
640Blob
641STObject::getFieldVL(SField const& field) const
642{
643 STBlob const empty;
644 STBlob const& b = getFieldByConstRef<STBlob>(field, empty);
645 return Blob(b.data(), b.data() + b.size());
646}
647
648STAmount const&
650{
651 static STAmount const empty{};
652 return getFieldByConstRef<STAmount>(field, empty);
653}
654
655STPathSet const&
657{
658 static STPathSet const empty{};
659 return getFieldByConstRef<STPathSet>(field, empty);
660}
661
662STVector256 const&
664{
665 static STVector256 const empty{};
666 return getFieldByConstRef<STVector256>(field, empty);
667}
668
671{
672 STObject const empty{field};
673 auto ret = getFieldByConstRef<STObject>(field, empty);
674 if (ret != empty)
675 ret.applyTemplateFromSField(field);
676 return ret;
677}
678
679STArray const&
681{
682 static STArray const empty{};
683 return getFieldByConstRef<STArray>(field, empty);
684}
685
686STCurrency const&
688{
689 static STCurrency const empty{};
690 return getFieldByConstRef<STCurrency>(field, empty);
691}
692
693STNumber const&
695{
696 static STNumber const empty{};
697 return getFieldByConstRef<STNumber>(field, empty);
698}
699
700void
702{
703 set(std::move(*v.get()));
704}
705
706void
708{
709 auto const i = getFieldIndex(v.getFName());
710 if (i != -1)
711 {
712 v_[i] = std::move(v);
713 }
714 else
715 {
716 if (!isFree())
717 Throw<std::runtime_error>("missing field in templated STObject");
718 v_.emplace_back(std::move(v));
719 }
720}
721
722void
723STObject::setFieldU8(SField const& field, unsigned char v)
724{
725 setFieldUsingSetValue<STUInt8>(field, v);
726}
727
728void
730{
731 setFieldUsingSetValue<STUInt16>(field, v);
732}
733
734void
736{
737 setFieldUsingSetValue<STUInt32>(field, v);
738}
739
740void
742{
743 setFieldUsingSetValue<STUInt64>(field, v);
744}
745
746void
747STObject::setFieldH128(SField const& field, uint128 const& v)
748{
749 setFieldUsingSetValue<STUInt128>(field, v);
750}
751
752void
753STObject::setFieldH256(SField const& field, uint256 const& v)
754{
755 setFieldUsingSetValue<STUInt256>(field, v);
756}
757
758void
760{
761 setFieldUsingSetValue<STInt32>(field, v);
762}
763
764void
766{
767 setFieldUsingSetValue<STVector256>(field, v);
768}
769
770void
772{
773 setFieldUsingSetValue<STAccount>(field, v);
774}
775
776void
777STObject::setFieldVL(SField const& field, Blob const& v)
778{
779 setFieldUsingSetValue<STBlob>(field, Buffer(v.data(), v.size()));
780}
781
782void
783STObject::setFieldVL(SField const& field, Slice const& s)
784{
785 setFieldUsingSetValue<STBlob>(field, Buffer(s.data(), s.size()));
786}
787
788void
790{
791 setFieldUsingAssignment(field, v);
792}
793
794void
796{
797 setFieldUsingAssignment(field, v);
798}
799
800void
802{
803 setFieldUsingAssignment(field, v);
804}
805
806void
808{
809 setFieldUsingAssignment(field, v);
810}
811
812void
814{
815 setFieldUsingAssignment(field, v);
816}
817
818void
820{
821 setFieldUsingAssignment(field, v);
822}
823
824void
826{
827 setFieldUsingAssignment(field, v);
828}
829
832{
834
835 for (auto const& elem : v_)
836 {
837 if (elem->getSType() != STI_NOTPRESENT)
838 ret[elem->getFName().getJsonName()] = elem->getJson(options);
839 }
840 return ret;
841}
842
843bool
845{
846 // This is not particularly efficient, and only compares data elements
847 // with binary representations
848 int matches = 0;
849 for (auto const& t1 : v_)
850 {
851 if ((t1->getSType() != STI_NOTPRESENT) && t1->getFName().isBinary())
852 {
853 // each present field must have a matching field
854 bool match = false;
855 for (auto const& t2 : obj.v_)
856 {
857 if (t1->getFName() == t2->getFName())
858 {
859 if (t2 != t1)
860 return false;
861
862 match = true;
863 ++matches;
864 break;
865 }
866 }
867
868 if (!match)
869 return false;
870 }
871 }
872
873 int fields = 0;
874 for (auto const& t2 : obj.v_)
875 {
876 if ((t2->getSType() != STI_NOTPRESENT) && t2->getFName().isBinary())
877 ++fields;
878 }
879
880 return fields == matches;
881}
882
883void
885{
886 // Depending on whichFields, signing fields are either serialized or
887 // not. Then fields are added to the Serializer sorted by fieldCode.
888 std::vector<STBase const*> const fields{getSortedFields(*this, whichFields)};
889
890 // insert sorted
891 for (STBase const* const field : fields)
892 {
893 // When we serialize an object inside another object,
894 // the type associated by rule with this field name
895 // must be OBJECT, or the object cannot be deserialized
896 SerializedTypeID const sType{field->getSType()};
897 XRPL_ASSERT(
898 (sType != STI_OBJECT) || (field->getFName().fieldType == STI_OBJECT),
899 "xrpl::STObject::add : valid field type");
900 field->addFieldID(s);
901 field->add(s);
902 if (sType == STI_ARRAY || sType == STI_OBJECT)
903 s.addFieldID(sType, 1);
904 }
905}
906
908STObject::getSortedFields(STObject const& objToSort, WhichFields whichFields)
909{
911 sf.reserve(objToSort.getCount());
912
913 // Choose the fields that we need to sort.
914 for (detail::STVar const& elem : objToSort.v_)
915 {
916 STBase const& base = elem.get();
917 if ((base.getSType() != STI_NOTPRESENT) &&
918 base.getFName().shouldInclude(static_cast<bool>(whichFields)))
919 {
920 sf.push_back(&base);
921 }
922 }
923
924 // Sort the fields by fieldCode.
925 std::sort(sf.begin(), sf.end(), [](STBase const* lhs, STBase const* rhs) {
926 return lhs->getFName().fieldCode < rhs->getFName().fieldCode;
927 });
928
929 return sf;
930}
931
932} // 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:92
int getIndex(SField const &) const
Retrieve the position of a named field.
SOEStyle style(SField const &sf) const
Definition SOTemplate.h:149
std::size_t size() const
The number of entries in this template.
Definition SOTemplate.h:139
A type which can be exported to a well known binary format.
Definition STBase.h:115
SField const & getFName() const
Definition STBase.cpp:125
static STBase * emplace(std::size_t n, void *buf, T &&val)
Definition STBase.h:213
virtual SerializedTypeID getSType() const
Definition STBase.cpp:59
void setFName(SField const &n)
A STBase is a field.
Definition STBase.cpp:118
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:723
SField const & getFieldSType(int index) const
Definition STObject.cpp:423
uint192 getFieldH192(SField const &field) const
Definition STObject.cpp:617
bool isFree() const
Definition STObject.h:965
STBase const * peekAtPIndex(int offset) const
Definition STObject.h:1014
Json::Value getJson(JsonOptions=JsonOptions::none) const override
Definition STObject.cpp:831
STCurrency const & getFieldCurrency(SField const &field) const
Definition STObject.cpp:687
Blob getFieldVL(SField const &field) const
Definition STObject.cpp:641
void setFieldIssue(SField const &field, STIssue const &)
Definition STObject.cpp:801
uint128 getFieldH128(SField const &field) const
Definition STObject.cpp:605
iterator begin() const
Definition STObject.h:941
bool operator==(STObject const &o) const
Definition STObject.cpp:844
bool isEquivalent(STBase const &t) const override
Definition STObject.cpp:342
bool empty() const
Definition STObject.h:953
void setFieldNumber(SField const &field, STNumber const &)
Definition STObject.cpp:807
void setFieldV256(SField const &field, STVector256 const &v)
Definition STObject.cpp:765
void setFieldU64(SField const &field, std::uint64_t)
Definition STObject.cpp:741
unsigned char getFieldU8(SField const &field) const
Definition STObject.cpp:581
std::uint32_t getFieldU32(SField const &field) const
Definition STObject.cpp:593
STBase const & peekAtIndex(int offset) const
Definition STObject.h:1002
STNumber const & getFieldNumber(SField const &field) const
Definition STObject.cpp:694
void setFieldVL(SField const &field, Blob const &)
Definition STObject.cpp:777
std::size_t emplace_back(Args &&... args)
Definition STObject.h:989
iterator end() const
Definition STObject.h:947
void applyTemplate(SOTemplate const &type)
Definition STObject.cpp:154
int getFieldIndex(SField const &field) const
Definition STObject.cpp:385
uint256 getHash(HashPrefix prefix) const
Definition STObject.cpp:367
void setFieldI32(SField const &field, std::int32_t)
Definition STObject.cpp:759
std::string getFullText() const override
Definition STObject.cpp:286
SOTemplate const * mType
Definition STObject.h:60
void setFieldU32(SField const &field, std::uint32_t)
Definition STObject.cpp:735
list_type v_
Definition STObject.h:59
STArray & peekFieldArray(SField const &field)
Definition STObject.cpp:473
std::string getText() const override
Definition STObject.cpp:323
STArray const & getFieldArray(SField const &field) const
Definition STObject.cpp:680
void setFieldArray(SField const &field, STArray const &v)
Definition STObject.cpp:819
STObject & peekFieldObject(SField const &field)
Definition STObject.cpp:467
SOEStyle getStyle(SField const &field) const
Definition STObject.cpp:575
STBase & getField(SField const &field)
Definition STObject.cpp:412
void setFieldAmount(SField const &field, STAmount const &)
Definition STObject.cpp:789
void add(Serializer &s) const override
Definition STObject.cpp:119
bool isFlag(std::uint32_t) const
Definition STObject.cpp:503
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:456
STObject & operator=(STObject const &)=default
STObject(STObject const &)=default
int getCount() const
Definition STObject.h:996
SerializedTypeID getSType() const override
Definition STObject.cpp:107
void setFieldU16(SField const &field, std::uint16_t)
Definition STObject.cpp:729
uint256 getFieldH256(SField const &field) const
Definition STObject.cpp:623
static STObject makeInnerObject(SField const &name)
Definition STObject.cpp:73
std::int32_t getFieldI32(SField const &field) const
Definition STObject.cpp:629
STBase const & peekAtField(SField const &field) const
Definition STObject.cpp:401
void set(SOTemplate const &)
Definition STObject.cpp:134
uint256 getSigningHash(HashPrefix prefix) const
Definition STObject.cpp:376
bool clearFlag(std::uint32_t)
Definition STObject.cpp:491
void setFieldCurrency(SField const &field, STCurrency const &)
Definition STObject.cpp:795
std::uint64_t getFieldU64(SField const &field) const
Definition STObject.cpp:599
void setFieldPathSet(SField const &field, STPathSet const &)
Definition STObject.cpp:813
STBase * move(std::size_t n, void *buf) override
Definition STObject.cpp:101
static std::vector< STBase const * > getSortedFields(STObject const &objToSort, WhichFields whichFields)
Definition STObject.cpp:908
STBase * getPField(SField const &field, bool createOkay=false)
Definition STObject.cpp:440
STBase * makeFieldPresent(SField const &field)
Definition STObject.cpp:520
STBase const * peekAtPField(SField const &field) const
Definition STObject.cpp:429
void applyTemplateFromSField(SField const &)
Definition STObject.cpp:204
bool setFlag(std::uint32_t)
Definition STObject.cpp:479
void setFieldObject(SField const &field, STObject const &v)
Definition STObject.cpp:825
void setFieldH128(SField const &field, uint128 const &)
Definition STObject.cpp:747
STObject getFieldObject(SField const &field) const
Definition STObject.cpp:670
void setAccountID(SField const &field, AccountID const &)
Definition STObject.cpp:771
void setFieldUsingAssignment(SField const &field, T const &value)
Definition STObject.h:1225
bool delField(SField const &field)
Definition STObject.cpp:557
STBase & getIndex(int offset)
Definition STObject.h:1008
uint160 getFieldH160(SField const &field) const
Definition STObject.cpp:611
AccountID getAccountID(SField const &field) const
Definition STObject.cpp:635
STBase * getPIndex(int offset)
Definition STObject.h:1020
STVector256 const & getFieldV256(SField const &field) const
Definition STObject.cpp:663
STPathSet const & getFieldPathSet(SField const &field) const
Definition STObject.cpp:656
bool isDefault() const override
Definition STObject.cpp:113
void makeFieldAbsent(SField const &field)
Definition STObject.cpp:542
bool hasMatchingEntry(STBase const &) const
Definition STObject.cpp:275
void setFieldH256(SField const &field, uint256 const &)
Definition STObject.cpp:753
std::uint16_t getFieldU16(SField const &field) const
Definition STObject.cpp:587
STAmount const & getFieldAmount(SField const &field) const
Definition STObject.cpp:649
std::uint32_t getFlags() const
Definition STObject.cpp:509
STBase * copy(std::size_t n, void *buf) const override
Definition STObject.cpp:95
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
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:453
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: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)