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