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