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