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