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