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