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