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