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