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
652{
653 return getFieldByValue<STAccount>(field);
654}
655
656Blob
657STObject::getFieldVL(SField const& field) const
658{
660 STBlob const& b = getFieldByConstRef<STBlob>(field, empty);
661 return Blob(b.data(), b.data() + b.size());
662}
663
664STAmount const&
666{
667 static STAmount const empty{};
668 return getFieldByConstRef<STAmount>(field, empty);
669}
670
671STPathSet const&
673{
674 static STPathSet const empty{};
675 return getFieldByConstRef<STPathSet>(field, empty);
676}
677
678STVector256 const&
680{
681 static STVector256 const empty{};
682 return getFieldByConstRef<STVector256>(field, empty);
683}
684
685STArray const&
687{
688 static STArray const empty{};
689 return getFieldByConstRef<STArray>(field, empty);
690}
691
692STCurrency const&
694{
695 static STCurrency const empty{};
696 return getFieldByConstRef<STCurrency>(field, empty);
697}
698
699STNumber const&
701{
702 static STNumber const empty{};
703 return getFieldByConstRef<STNumber>(field, empty);
704}
705
706void
708{
709 set(std::move(*v.get()));
710}
711
712void
714{
715 auto const i = getFieldIndex(v.getFName());
716 if (i != -1)
717 {
718 v_[i] = std::move(v);
719 }
720 else
721 {
722 if (!isFree())
723 Throw<std::runtime_error>("missing field in templated STObject");
724 v_.emplace_back(std::move(v));
725 }
726}
727
728void
729STObject::setFieldU8(SField const& field, unsigned char v)
730{
731 setFieldUsingSetValue<STUInt8>(field, v);
732}
733
734void
736{
737 setFieldUsingSetValue<STUInt16>(field, v);
738}
739
740void
742{
743 setFieldUsingSetValue<STUInt32>(field, v);
744}
745
746void
748{
749 setFieldUsingSetValue<STUInt64>(field, v);
750}
751
752void
753STObject::setFieldH128(SField const& field, uint128 const& v)
754{
755 setFieldUsingSetValue<STUInt128>(field, v);
756}
757
758void
759STObject::setFieldH256(SField const& field, uint256 const& v)
760{
761 setFieldUsingSetValue<STUInt256>(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
826{
828
829 for (auto const& elem : v_)
830 {
831 if (elem->getSType() != STI_NOTPRESENT)
832 ret[elem->getFName().getJsonName()] = elem->getJson(options);
833 }
834 return ret;
835}
836
837bool
839{
840 // This is not particularly efficient, and only compares data elements
841 // with binary representations
842 int matches = 0;
843 for (auto const& t1 : v_)
844 {
845 if ((t1->getSType() != STI_NOTPRESENT) && t1->getFName().isBinary())
846 {
847 // each present field must have a matching field
848 bool match = false;
849 for (auto const& t2 : obj.v_)
850 {
851 if (t1->getFName() == t2->getFName())
852 {
853 if (t2 != t1)
854 return false;
855
856 match = true;
857 ++matches;
858 break;
859 }
860 }
861
862 if (!match)
863 return false;
864 }
865 }
866
867 int fields = 0;
868 for (auto const& t2 : obj.v_)
869 {
870 if ((t2->getSType() != STI_NOTPRESENT) && t2->getFName().isBinary())
871 ++fields;
872 }
873
874 if (fields != matches)
875 return false;
876
877 return true;
878}
879
880void
882{
883 // Depending on whichFields, signing fields are either serialized or
884 // not. Then fields are added to the Serializer sorted by fieldCode.
885 std::vector<STBase const*> const fields{
886 getSortedFields(*this, whichFields)};
887
888 // insert sorted
889 for (STBase const* const field : fields)
890 {
891 // When we serialize an object inside another object,
892 // the type associated by rule with this field name
893 // must be OBJECT, or the object cannot be deserialized
894 SerializedTypeID const sType{field->getSType()};
895 XRPL_ASSERT(
896 (sType != STI_OBJECT) ||
897 (field->getFName().fieldType == STI_OBJECT),
898 "ripple::STObject::add : valid field type");
899 field->addFieldID(s);
900 field->add(s);
901 if (sType == STI_ARRAY || sType == STI_OBJECT)
902 s.addFieldID(sType, 1);
903 }
904}
905
907STObject::getSortedFields(STObject const& objToSort, WhichFields whichFields)
908{
910 sf.reserve(objToSort.getCount());
911
912 // Choose the fields that we need to sort.
913 for (detail::STVar const& elem : objToSort.v_)
914 {
915 STBase const& base = elem.get();
916 if ((base.getSType() != STI_NOTPRESENT) &&
917 base.getFName().shouldInclude(whichFields))
918 {
919 sf.push_back(&base);
920 }
921 }
922
923 // Sort the fields by fieldCode.
924 std::sort(sf.begin(), sf.end(), [](STBase const* lhs, STBase const* rhs) {
925 return lhs->getFName().fieldCode < rhs->getFName().fieldCode;
926 });
927
928 return sf;
929}
930
931} // 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:144
std::string const & getName() const
Definition SField.h:209
bool shouldInclude(bool withSigningField) const
Definition SField.h:282
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:134
virtual SerializedTypeID getSType() const
Definition STBase.cpp:75
SField const & getFName() const
Definition STBase.cpp:141
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:146
void setValue(Integer v)
Definition STInteger.h:153
A serializable number.
Definition STNumber.h:43
STPathSet const & getFieldPathSet(SField const &field) const
Definition STObject.cpp:672
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:801
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:657
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:651
static std::vector< STBase const * > getSortedFields(STObject const &objToSort, WhichFields whichFields)
Definition STObject.cpp:907
STArray const & getFieldArray(SField const &field) const
Definition STObject.cpp:686
uint160 getFieldH160(SField const &field) const
Definition STObject.cpp:633
void setFieldCurrency(SField const &field, STCurrency const &)
Definition STObject.cpp:795
STBase const * peekAtPField(SField const &field) const
Definition STObject.cpp:457
STBase const * peekAtPIndex(int offset) const
Definition STObject.h:997
void setFieldArray(SField const &field, STArray const &v)
Definition STObject.cpp:819
void setFieldPathSet(SField const &field, STPathSet const &)
Definition STObject.cpp:813
iterator end() const
Definition STObject.h:930
SField const & getFieldSType(int index) const
Definition STObject.cpp:451
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:759
void setFieldNumber(SField const &field, STNumber const &)
Definition STObject.cpp:807
bool setFlag(std::uint32_t)
Definition STObject.cpp:507
std::uint32_t getFieldU32(SField const &field) const
Definition STObject.cpp:615
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:979
void setFieldU16(SField const &field, std::uint16_t)
Definition STObject.cpp:735
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:729
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:789
bool delField(SField const &field)
Definition STObject.cpp:585
STBase const & peekAtIndex(int offset) const
Definition STObject.h:985
STBase & getField(SField const &field)
Definition STObject.cpp:440
STAmount const & getFieldAmount(SField const &field) const
Definition STObject.cpp:665
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:991
bool isFree() const
Definition STObject.h:948
void setFieldUsingAssignment(SField const &field, T const &value)
Definition STObject.h:1211
list_type v_
Definition STObject.h:79
bool empty() const
Definition STObject.h:936
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:924
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:693
bool operator==(STObject const &o) const
Definition STObject.cpp:838
void setAccountID(SField const &field, AccountID const &)
Definition STObject.cpp:771
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:765
Json::Value getJson(JsonOptions=JsonOptions::none) const override
Definition STObject.cpp:825
void setFieldH128(SField const &field, uint128 const &)
Definition STObject.cpp:753
void setFieldU64(SField const &field, std::uint64_t)
Definition STObject.cpp:747
bool isEquivalent(STBase const &t) const override
Definition STObject.cpp:360
void setFieldU32(SField const &field, std::uint32_t)
Definition STObject.cpp:741
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:972
STBase * getPIndex(int offset)
Definition STObject.h:1003
STArray & peekFieldArray(SField const &field)
Definition STObject.cpp:501
STNumber const & getFieldNumber(SField const &field) const
Definition STObject.cpp:700
STObject & operator=(STObject const &)=default
void setFieldVL(SField const &field, Blob const &)
Definition STObject.cpp:777
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:679
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:108
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:468
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)