rippled
STObject.h
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 #ifndef RIPPLE_PROTOCOL_STOBJECT_H_INCLUDED
21 #define RIPPLE_PROTOCOL_STOBJECT_H_INCLUDED
22 
23 #include <ripple/basics/CountedObject.h>
24 #include <ripple/basics/FeeUnits.h>
25 #include <ripple/basics/Slice.h>
26 #include <ripple/basics/chrono.h>
27 #include <ripple/basics/contract.h>
28 #include <ripple/protocol/HashPrefix.h>
29 #include <ripple/protocol/SOTemplate.h>
30 #include <ripple/protocol/STAmount.h>
31 #include <ripple/protocol/STPathSet.h>
32 #include <ripple/protocol/STVector256.h>
33 #include <ripple/protocol/impl/STVar.h>
34 #include <boost/iterator/transform_iterator.hpp>
35 #include <boost/optional.hpp>
36 #include <cassert>
37 #include <stdexcept>
38 #include <type_traits>
39 #include <utility>
40 
41 namespace ripple {
42 
43 class STArray;
44 
45 inline void
47 {
48  Throw<std::runtime_error>("Field not found: " + field.getName());
49 }
50 
51 class STObject : public STBase, public CountedObject<STObject>
52 {
53 private:
54  // Proxy value for a STBase derived class
55  template <class T>
56  class Proxy
57  {
58  protected:
59  using value_type = typename T::value_type;
60 
63  TypedField<T> const* f_;
64 
65  Proxy(Proxy const&) = default;
66  Proxy(STObject* st, TypedField<T> const* f);
68  value() const;
69  T const*
70  find() const;
71 
72  template <class U>
73  void
74  assign(U&& u);
75  };
76 
77  template <class T>
78  class ValueProxy : private Proxy<T>
79  {
80  private:
81  using value_type = typename T::value_type;
82 
83  public:
84  ValueProxy(ValueProxy const&) = default;
85  ValueProxy&
86  operator=(ValueProxy const&) = delete;
87 
88  template <class U>
90  operator=(U&& u);
91 
92  operator value_type() const;
93 
94  private:
95  friend class STObject;
96 
97  ValueProxy(STObject* st, TypedField<T> const* f);
98  };
99 
100  template <class T>
101  class OptionalProxy : private Proxy<T>
102  {
103  private:
104  using value_type = typename T::value_type;
105 
106  using optional_type =
107  boost::optional<typename std::decay<value_type>::type>;
108 
109  public:
110  OptionalProxy(OptionalProxy const&) = default;
112  operator=(OptionalProxy const&) = delete;
113 
119  explicit operator bool() const noexcept;
120 
127  value_type
128  operator*() const;
129 
130  operator optional_type() const;
131 
134  operator~() const;
135 
136  friend bool
137  operator==(OptionalProxy const& lhs, boost::none_t) noexcept
138  {
139  return !lhs.engaged();
140  }
141 
142  friend bool
143  operator==(boost::none_t, OptionalProxy const& rhs) noexcept
144  {
145  return rhs == boost::none;
146  }
147 
148  friend bool
149  operator==(OptionalProxy const& lhs, optional_type const& rhs) noexcept
150  {
151  if (!lhs.engaged())
152  return !rhs;
153  if (!rhs)
154  return false;
155  return *lhs == *rhs;
156  }
157 
158  friend bool
159  operator==(optional_type const& lhs, OptionalProxy const& rhs) noexcept
160  {
161  return rhs == lhs;
162  }
163 
164  friend bool
165  operator==(OptionalProxy const& lhs, OptionalProxy const& rhs) noexcept
166  {
167  if (lhs.engaged() != rhs.engaged())
168  return false;
169  return !lhs.engaged() || *lhs == *rhs;
170  }
171 
172  friend bool
173  operator!=(OptionalProxy const& lhs, boost::none_t) noexcept
174  {
175  return !(lhs == boost::none);
176  }
177 
178  friend bool
179  operator!=(boost::none_t, OptionalProxy const& rhs) noexcept
180  {
181  return !(rhs == boost::none);
182  }
183 
184  friend bool
185  operator!=(OptionalProxy const& lhs, optional_type const& rhs) noexcept
186  {
187  return !(lhs == rhs);
188  }
189 
190  friend bool
191  operator!=(optional_type const& lhs, OptionalProxy const& rhs) noexcept
192  {
193  return !(lhs == rhs);
194  }
195 
196  friend bool
197  operator!=(OptionalProxy const& lhs, OptionalProxy const& rhs) noexcept
198  {
199  return !(lhs == rhs);
200  }
201 
203  operator=(boost::none_t const&);
207  operator=(optional_type const& v);
208 
209  template <class U>
211  operator=(U&& u);
212 
213  private:
214  friend class STObject;
215 
216  OptionalProxy(STObject* st, TypedField<T> const* f);
217 
218  bool
219  engaged() const noexcept;
220 
221  void
222  disengage();
223 
225  optional_value() const;
226  };
227 
228  struct Transform
229  {
230  explicit Transform() = default;
231 
234 
235  STBase const&
236  operator()(detail::STVar const& e) const
237  {
238  return e.get();
239  }
240  };
241 
242  enum { reserveSize = 20 };
243 
245 
248 
249 public:
250  using iterator = boost::
251  transform_iterator<Transform, STObject::list_type::const_iterator>;
252 
254  {
256  };
257 
258  static char const*
260  {
261  return "STObject";
262  }
263 
264  STObject(STObject&&);
265  STObject(STObject const&) = default;
266  STObject(const SOTemplate& type, SField const& name);
267  STObject(
268  const SOTemplate& type,
269  SerialIter& sit,
270  SField const& name) noexcept(false);
271  STObject(SerialIter& sit, SField const& name, int depth = 0) noexcept(
272  false);
273  STObject(SerialIter&& sit, SField const& name) noexcept(false)
274  : STObject(sit, name)
275  {
276  }
277  STObject&
278  operator=(STObject const&) = default;
279  STObject&
280  operator=(STObject&& other);
281 
282  explicit STObject(SField const& name);
283 
284  virtual ~STObject();
285 
286  STBase*
287  copy(std::size_t n, void* buf) const override
288  {
289  return emplace(n, buf, *this);
290  }
291 
292  STBase*
293  move(std::size_t n, void* buf) override
294  {
295  return emplace(n, buf, std::move(*this));
296  }
297 
298  iterator
299  begin() const
300  {
301  return iterator(v_.begin());
302  }
303 
304  iterator
305  end() const
306  {
307  return iterator(v_.end());
308  }
309 
310  bool
311  empty() const
312  {
313  return v_.empty();
314  }
315 
316  void
318  {
319  v_.reserve(n);
320  }
321 
322  void
323  applyTemplate(const SOTemplate& type) noexcept(false);
324 
325  void
326  applyTemplateFromSField(SField const&) noexcept(false);
327 
328  bool
329  isFree() const
330  {
331  return mType == nullptr;
332  }
333 
334  void
335  set(const SOTemplate&);
336  bool
337  set(SerialIter& u, int depth = 0);
338 
339  virtual SerializedTypeID
340  getSType() const override
341  {
342  return STI_OBJECT;
343  }
344  virtual bool
345  isEquivalent(const STBase& t) const override;
346  virtual bool
347  isDefault() const override
348  {
349  return v_.empty();
350  }
351 
352  virtual void
353  add(Serializer& s) const override
354  {
355  add(s, withAllFields); // just inner elements
356  }
357 
358  void
360  {
362  }
363 
364  // VFALCO NOTE does this return an expensive copy of an object with a
365  // dynamic buffer?
366  // VFALCO TODO Remove this function and fix the few callers.
367  Serializer
369  {
370  Serializer s;
371  add(s, withAllFields);
372  return s;
373  }
374 
375  virtual std::string
376  getFullText() const override;
377  virtual std::string
378  getText() const override;
379 
380  // TODO(tom): options should be an enum.
381  virtual Json::Value
382  getJson(JsonOptions options) const override;
383 
384  template <class... Args>
386  emplace_back(Args&&... args)
387  {
388  v_.emplace_back(std::forward<Args>(args)...);
389  return v_.size() - 1;
390  }
391 
392  int
393  getCount() const
394  {
395  return v_.size();
396  }
397 
398  bool setFlag(std::uint32_t);
399  bool clearFlag(std::uint32_t);
400  bool isFlag(std::uint32_t) const;
402  getFlags() const;
403 
404  uint256
405  getHash(HashPrefix prefix) const;
406  uint256
407  getSigningHash(HashPrefix prefix) const;
408 
409  const STBase&
410  peekAtIndex(int offset) const
411  {
412  return v_[offset].get();
413  }
414  STBase&
415  getIndex(int offset)
416  {
417  return v_[offset].get();
418  }
419  const STBase*
420  peekAtPIndex(int offset) const
421  {
422  return &v_[offset].get();
423  }
424  STBase*
425  getPIndex(int offset)
426  {
427  return &v_[offset].get();
428  }
429 
430  int
431  getFieldIndex(SField const& field) const;
432  SField const&
433  getFieldSType(int index) const;
434 
435  const STBase&
436  peekAtField(SField const& field) const;
437  STBase&
438  getField(SField const& field);
439  const STBase*
440  peekAtPField(SField const& field) const;
441  STBase*
442  getPField(SField const& field, bool createOkay = false);
443 
444  // these throw if the field type doesn't match, or return default values
445  // if the field is optional but not present
446  unsigned char
447  getFieldU8(SField const& field) const;
449  getFieldU16(SField const& field) const;
451  getFieldU32(SField const& field) const;
453  getFieldU64(SField const& field) const;
454  uint128
455  getFieldH128(SField const& field) const;
456 
457  uint160
458  getFieldH160(SField const& field) const;
459  uint256
460  getFieldH256(SField const& field) const;
461  AccountID
462  getAccountID(SField const& field) const;
463 
464  Blob
465  getFieldVL(SField const& field) const;
466  STAmount const&
467  getFieldAmount(SField const& field) const;
468  STPathSet const&
469  getFieldPathSet(SField const& field) const;
470  const STVector256&
471  getFieldV256(SField const& field) const;
472  const STArray&
473  getFieldArray(SField const& field) const;
474 
482  template <class T>
483  typename T::value_type
484  operator[](TypedField<T> const& f) const;
485 
490  template <class T>
491  boost::optional<std::decay_t<typename T::value_type>>
492  operator[](OptionaledField<T> const& of) const;
493 
501  template <class T>
502  ValueProxy<T>
503  operator[](TypedField<T> const& f);
504 
510  template <class T>
511  OptionalProxy<T>
512  operator[](OptionaledField<T> const& of);
513 
517  void
519 
520  void
521  setFieldU8(SField const& field, unsigned char);
522  void
523  setFieldU16(SField const& field, std::uint16_t);
524  void
525  setFieldU32(SField const& field, std::uint32_t);
526  void
527  setFieldU64(SField const& field, std::uint64_t);
528  void
529  setFieldH128(SField const& field, uint128 const&);
530  void
531  setFieldH256(SField const& field, uint256 const&);
532  void
533  setFieldVL(SField const& field, Blob const&);
534  void
535  setFieldVL(SField const& field, Slice const&);
536 
537  void
538  setAccountID(SField const& field, AccountID const&);
539 
540  void
541  setFieldAmount(SField const& field, STAmount const&);
542  void
543  setFieldPathSet(SField const& field, STPathSet const&);
544  void
545  setFieldV256(SField const& field, STVector256 const& v);
546  void
547  setFieldArray(SField const& field, STArray const& v);
548 
549  template <class Tag>
550  void
551  setFieldH160(SField const& field, base_uint<160, Tag> const& v)
552  {
553  STBase* rf = getPField(field, true);
554 
555  if (!rf)
556  throwFieldNotFound(field);
557 
558  if (rf->getSType() == STI_NOTPRESENT)
559  rf = makeFieldPresent(field);
560 
561  using Bits = STBitString<160>;
562  if (auto cf = dynamic_cast<Bits*>(rf))
563  cf->setValue(v);
564  else
565  Throw<std::runtime_error>("Wrong field type");
566  }
567 
568  STObject&
569  peekFieldObject(SField const& field);
570  STArray&
571  peekFieldArray(SField const& field);
572 
573  bool
574  isFieldPresent(SField const& field) const;
575  STBase*
576  makeFieldPresent(SField const& field);
577  void
578  makeFieldAbsent(SField const& field);
579  bool
580  delField(SField const& field);
581  void
582  delField(int index);
583 
584  bool
585  hasMatchingEntry(const STBase&);
586 
587  bool
588  operator==(const STObject& o) const;
589  bool
590  operator!=(const STObject& o) const
591  {
592  return !(*this == o);
593  }
594 
595 private:
596  enum WhichFields : bool {
597  // These values are carefully chosen to do the right thing if passed
598  // to SField::shouldInclude (bool)
601  };
602 
603  void
604  add(Serializer& s, WhichFields whichFields) const;
605 
606  // Sort the entries in an STObject into the order that they will be
607  // serialized. Note: they are not sorted into pointer value order, they
608  // are sorted by SField::fieldCode.
610  getSortedFields(STObject const& objToSort, WhichFields whichFields);
611 
612  // Implementation for getting (most) fields that return by value.
613  //
614  // The remove_cv and remove_reference are necessitated by the STBitString
615  // types. Their value() returns by const ref. We return those types
616  // by value.
617  template <
618  typename T,
619  typename V = typename std::remove_cv<typename std::remove_reference<
620  decltype(std::declval<T>().value())>::type>::type>
621  V
622  getFieldByValue(SField const& field) const
623  {
624  const STBase* rf = peekAtPField(field);
625 
626  if (!rf)
627  throwFieldNotFound(field);
628 
629  SerializedTypeID id = rf->getSType();
630 
631  if (id == STI_NOTPRESENT)
632  return V(); // optional field not present
633 
634  const T* cf = dynamic_cast<const T*>(rf);
635 
636  if (!cf)
637  Throw<std::runtime_error>("Wrong field type");
638 
639  return cf->value();
640  }
641 
642  // Implementations for getting (most) fields that return by const reference.
643  //
644  // If an absent optional field is deserialized we don't have anything
645  // obvious to return. So we insist on having the call provide an
646  // 'empty' value we return in that circumstance.
647  template <typename T, typename V>
648  V const&
649  getFieldByConstRef(SField const& field, V const& empty) const
650  {
651  const STBase* rf = peekAtPField(field);
652 
653  if (!rf)
654  throwFieldNotFound(field);
655 
656  SerializedTypeID id = rf->getSType();
657 
658  if (id == STI_NOTPRESENT)
659  return empty; // optional field not present
660 
661  const T* cf = dynamic_cast<const T*>(rf);
662 
663  if (!cf)
664  Throw<std::runtime_error>("Wrong field type");
665 
666  return *cf;
667  }
668 
669  // Implementation for setting most fields with a setValue() method.
670  template <typename T, typename V>
671  void
673  {
674  static_assert(!std::is_lvalue_reference<V>::value, "");
675 
676  STBase* rf = getPField(field, true);
677 
678  if (!rf)
679  throwFieldNotFound(field);
680 
681  if (rf->getSType() == STI_NOTPRESENT)
682  rf = makeFieldPresent(field);
683 
684  T* cf = dynamic_cast<T*>(rf);
685 
686  if (!cf)
687  Throw<std::runtime_error>("Wrong field type");
688 
689  cf->setValue(std::move(value));
690  }
691 
692  // Implementation for setting fields using assignment
693  template <typename T>
694  void
695  setFieldUsingAssignment(SField const& field, T const& value)
696  {
697  STBase* rf = getPField(field, true);
698 
699  if (!rf)
700  throwFieldNotFound(field);
701 
702  if (rf->getSType() == STI_NOTPRESENT)
703  rf = makeFieldPresent(field);
704 
705  T* cf = dynamic_cast<T*>(rf);
706 
707  if (!cf)
708  Throw<std::runtime_error>("Wrong field type");
709 
710  (*cf) = value;
711  }
712 
713  // Implementation for peeking STObjects and STArrays
714  template <typename T>
715  T&
716  peekField(SField const& field)
717  {
718  STBase* rf = getPField(field, true);
719 
720  if (!rf)
721  throwFieldNotFound(field);
722 
723  if (rf->getSType() == STI_NOTPRESENT)
724  rf = makeFieldPresent(field);
725 
726  T* cf = dynamic_cast<T*>(rf);
727 
728  if (!cf)
729  Throw<std::runtime_error>("Wrong field type");
730 
731  return *cf;
732  }
733 };
734 
735 //------------------------------------------------------------------------------
736 
737 template <class T>
738 STObject::Proxy<T>::Proxy(STObject* st, TypedField<T> const* f) : st_(st), f_(f)
739 {
740  if (st_->mType)
741  {
742  // STObject has associated template
743  if (!st_->peekAtPField(*f_))
744  Throw<STObject::FieldErr>(
745  "Template field error '" + this->f_->getName() + "'");
746  style_ = st_->mType->style(*f_);
747  }
748  else
749  {
750  style_ = soeINVALID;
751  }
752 }
753 
754 template <class T>
755 auto
757 {
758  auto const t = find();
759  if (t)
760  return t->value();
761  if (style_ != soeDEFAULT)
762  Throw<STObject::FieldErr>(
763  "Missing field '" + this->f_->getName() + "'");
764  return value_type{};
765 }
766 
767 template <class T>
768 inline T const*
770 {
771  return dynamic_cast<T const*>(st_->peekAtPField(*f_));
772 }
773 
774 template <class T>
775 template <class U>
776 void
778 {
779  if (style_ == soeDEFAULT && u == value_type{})
780  {
781  st_->makeFieldAbsent(*f_);
782  return;
783  }
784  T* t;
785  if (style_ == soeINVALID)
786  t = dynamic_cast<T*>(st_->getPField(*f_, true));
787  else
788  t = dynamic_cast<T*>(st_->makeFieldPresent(*f_));
789  assert(t);
790  *t = std::forward<U>(u);
791 }
792 
793 //------------------------------------------------------------------------------
794 
795 template <class T>
796 template <class U>
799 {
800  this->assign(std::forward<U>(u));
801  return *this;
802 }
803 
804 template <class T>
806 {
807  return this->value();
808 }
809 
810 template <class T>
812  : Proxy<T>(st, f)
813 {
814 }
815 
816 //------------------------------------------------------------------------------
817 
818 template <class T>
820 {
821  return engaged();
822 }
823 
824 template <class T>
825 auto
827 {
828  return this->value();
829 }
830 
831 template <class T>
833  T>::optional_type() const
834 {
835  return optional_value();
836 }
837 
838 template <class T>
841 {
842  return optional_value();
843 }
844 
845 template <class T>
846 auto
848 {
849  disengage();
850  return *this;
851 }
852 
853 template <class T>
854 auto
856 {
857  if (v)
858  this->assign(std::move(*v));
859  else
860  disengage();
861  return *this;
862 }
863 
864 template <class T>
865 auto
867 {
868  if (v)
869  this->assign(*v);
870  else
871  disengage();
872  return *this;
873 }
874 
875 template <class T>
876 template <class U>
879 {
880  this->assign(std::forward<U>(u));
881  return *this;
882 }
883 
884 template <class T>
886  : Proxy<T>(st, f)
887 {
888 }
889 
890 template <class T>
891 bool
893 {
894  return this->style_ == soeDEFAULT || this->find() != nullptr;
895 }
896 
897 template <class T>
898 void
900 {
901  if (this->style_ == soeREQUIRED || this->style_ == soeDEFAULT)
902  Throw<STObject::FieldErr>(
903  "Template field error '" + this->f_->getName() + "'");
904  if (this->style_ == soeINVALID)
905  this->st_->delField(*this->f_);
906  else
907  this->st_->makeFieldAbsent(*this->f_);
908 }
909 
910 template <class T>
911 auto
913 {
914  if (!engaged())
915  return boost::none;
916  return this->value();
917 }
918 
919 //------------------------------------------------------------------------------
920 
921 template <class T>
922 typename T::value_type
924 {
925  auto const b = peekAtPField(f);
926  if (!b)
927  // This is a free object (no constraints)
928  // with no template
929  Throw<STObject::FieldErr>("Missing field '" + f.getName() + "'");
930  auto const u = dynamic_cast<T const*>(b);
931  if (!u)
932  {
933  assert(mType);
934  assert(b->getSType() == STI_NOTPRESENT);
935  if (mType->style(f) == soeOPTIONAL)
936  Throw<STObject::FieldErr>("Missing field '" + f.getName() + "'");
937  assert(mType->style(f) == soeDEFAULT);
938  // Handle the case where value_type is a
939  // const reference, otherwise we return
940  // the address of a temporary.
941  static std::decay_t<typename T::value_type> const dv{};
942  return dv;
943  }
944  return u->value();
945 }
946 
947 template <class T>
948 boost::optional<std::decay_t<typename T::value_type>>
950 {
951  auto const b = peekAtPField(*of.f);
952  if (!b)
953  return boost::none;
954  auto const u = dynamic_cast<T const*>(b);
955  if (!u)
956  {
957  assert(mType);
958  assert(b->getSType() == STI_NOTPRESENT);
959  if (mType->style(*of.f) == soeOPTIONAL)
960  return boost::none;
961  assert(mType->style(*of.f) == soeDEFAULT);
962  return typename T::value_type{};
963  }
964  return u->value();
965 }
966 
967 template <class T>
968 inline auto
970 {
971  return ValueProxy<T>(this, &f);
972 }
973 
974 template <class T>
975 inline auto
977 {
978  return OptionalProxy<T>(this, of.f);
979 }
980 
981 } // namespace ripple
982 
983 #endif
ripple::STObject::getFieldSType
SField const & getFieldSType(int index) const
Definition: STObject.cpp:379
ripple::STObject::peekAtField
const STBase & peekAtField(SField const &field) const
Definition: STObject.cpp:357
ripple::STObject::OptionalProxy::operator==
friend bool operator==(OptionalProxy const &lhs, optional_type const &rhs) noexcept
Definition: STObject.h:149
ripple::STObject::getIndex
STBase & getIndex(int offset)
Definition: STObject.h:415
ripple::STObject::getSortedFields
static std::vector< STBase const * > getSortedFields(STObject const &objToSort, WhichFields whichFields)
Definition: STObject.cpp:790
ripple::STObject::setAccountID
void setAccountID(SField const &field, AccountID const &)
Definition: STObject.cpp:673
ripple::STBase::STBase
STBase()
Definition: STBase.cpp:27
ripple::STObject::OptionalProxy::engaged
bool engaged() const noexcept
Definition: STObject.h:892
ripple::STObject::getFieldArray
const STArray & getFieldArray(SField const &field) const
Definition: STObject.cpp:608
ripple::STBase::getSType
virtual SerializedTypeID getSType() const
Definition: STBase.cpp:67
ripple::SOTemplate::style
SOEStyle style(SField const &sf) const
Definition: SOTemplate.h:129
ripple::CountedObject
Tracks the number of instances of an object.
Definition: CountedObject.h:110
ripple::STObject::makeFieldAbsent
void makeFieldAbsent(SField const &field)
Definition: STObject.cpp:498
std::string
STL class.
ripple::STObject::hasMatchingEntry
bool hasMatchingEntry(const STBase &)
Definition: STObject.cpp:227
utility
ripple::TypedField
A field with a type known at compile time.
Definition: SField.h:281
std::is_lvalue_reference
ripple::STObject::setFieldH128
void setFieldH128(SField const &field, uint128 const &)
Definition: STObject.cpp:655
ripple::STObject::setFieldU16
void setFieldU16(SField const &field, std::uint16_t)
Definition: STObject.cpp:637
ripple::JsonOptions
JsonOptions
Definition: STBase.h:34
ripple::STObject::OptionalProxy::operator!=
friend bool operator!=(OptionalProxy const &lhs, boost::none_t) noexcept
Definition: STObject.h:173
ripple::STObject::setFieldV256
void setFieldV256(SField const &field, STVector256 const &v)
Definition: STObject.cpp:667
ripple::STObject::getFieldU64
std::uint64_t getFieldU64(SField const &field) const
Definition: STObject.cpp:549
ripple::Slice
An immutable linear range of bytes.
Definition: Slice.h:43
ripple::STObject::getFieldV256
const STVector256 & getFieldV256(SField const &field) const
Definition: STObject.cpp:601
ripple::STObject::v_
list_type v_
Definition: STObject.h:246
ripple::STObject::OptionalProxy::operator!=
friend bool operator!=(OptionalProxy const &lhs, optional_type const &rhs) noexcept
Definition: STObject.h:185
std::vector::reserve
T reserve(T... args)
ripple::STObject::Proxy::value_type
typename T::value_type value_type
Definition: STObject.h:59
std::vector< detail::STVar >
std::vector::size
T size(T... args)
ripple::STObject::getFieldU8
unsigned char getFieldU8(SField const &field) const
Definition: STObject.cpp:531
ripple::SerializedTypeID
SerializedTypeID
Definition: SField.h:52
ripple::STObject::withAllFields
@ withAllFields
Definition: STObject.h:600
ripple::STObject::copy
STBase * copy(std::size_t n, void *buf) const override
Definition: STObject.h:287
ripple::STObject::empty
bool empty() const
Definition: STObject.h:311
ripple::STObject::getSerializer
Serializer getSerializer() const
Definition: STObject.h:368
ripple::STObject::getFieldH128
uint128 getFieldH128(SField const &field) const
Definition: STObject.cpp:555
ripple::STObject::WhichFields
WhichFields
Definition: STObject.h:596
ripple::soeREQUIRED
@ soeREQUIRED
Definition: SOTemplate.h:34
ripple::OptionaledField
Indicate boost::optional field semantics.
Definition: SField.h:297
ripple::STObject::OptionalProxy::operator=
OptionalProxy & operator=(OptionalProxy const &)=delete
boost
Definition: IPAddress.h:117
ripple::STObject::setFieldVL
void setFieldVL(SField const &field, Blob const &)
Definition: STObject.cpp:679
ripple::STObject::getFieldVL
Blob getFieldVL(SField const &field) const
Definition: STObject.cpp:579
ripple::STObject::OptionalProxy::operator==
friend bool operator==(boost::none_t, OptionalProxy const &rhs) noexcept
Definition: STObject.h:143
ripple::STBitString::setValue
void setValue(base_uint< Bits, Tag > const &v)
Definition: STBitString.h:101
ripple::STObject::peekAtPIndex
const STBase * peekAtPIndex(int offset) const
Definition: STObject.h:420
ripple::STObject::getFieldH160
uint160 getFieldH160(SField const &field) const
Definition: STObject.cpp:561
ripple::STBitString
Definition: SField.h:47
ripple::STObject::peekAtIndex
const STBase & peekAtIndex(int offset) const
Definition: STObject.h:410
ripple::STPathSet
Definition: STPathSet.h:309
ripple::STObject::getFullText
virtual std::string getFullText() const override
Definition: STObject.cpp:238
ripple::STObject::isEquivalent
virtual bool isEquivalent(const STBase &t) const override
Definition: STObject.cpp:288
ripple::STBase::emplace
static STBase * emplace(std::size_t n, void *buf, T &&val)
Definition: STBase.h:149
ripple::STObject::Proxy::assign
void assign(U &&u)
Definition: STObject.h:777
stdexcept
ripple::base_uint< 256 >
ripple::STObject::setFieldH160
void setFieldH160(SField const &field, base_uint< 160, Tag > const &v)
Definition: STObject.h:551
ripple::STObject::OptionalProxy::operator!=
friend bool operator!=(optional_type const &lhs, OptionalProxy const &rhs) noexcept
Definition: STObject.h:191
ripple::STObject::getSType
virtual SerializedTypeID getSType() const override
Definition: STObject.h:340
ripple::STObject::FieldErr
Definition: STObject.h:253
ripple::STObject::OptionalProxy::OptionalProxy
OptionalProxy(OptionalProxy const &)=default
ripple::STObject::Proxy::st_
STObject * st_
Definition: STObject.h:61
ripple::STObject::delField
bool delField(SField const &field)
Definition: STObject.cpp:513
ripple::STObject::peekField
T & peekField(SField const &field)
Definition: STObject.h:716
ripple::STObject::ValueProxy::value_type
typename T::value_type value_type
Definition: STObject.h:81
ripple::STObject::ValueProxy
Definition: STObject.h:78
ripple::STObject::OptionalProxy::operator==
friend bool operator==(OptionalProxy const &lhs, boost::none_t) noexcept
Definition: STObject.h:137
ripple::SOTemplate
Defines the fields and their attributes within a STObject.
Definition: SOTemplate.h:75
ripple::STObject::OptionalProxy
Definition: STObject.h:101
ripple::STObject::begin
iterator begin() const
Definition: STObject.h:299
ripple::STObject::setFieldArray
void setFieldArray(SField const &field, STArray const &v)
Definition: STObject.cpp:703
ripple::STObject::iterator
boost::transform_iterator< Transform, STObject::list_type::const_iterator > iterator
Definition: STObject.h:251
ripple::STObject::applyTemplate
void applyTemplate(const SOTemplate &type) noexcept(false)
Definition: STObject.cpp:100
ripple::HashPrefix
HashPrefix
Prefix for hashing functions.
Definition: HashPrefix.h:54
ripple::STObject::Proxy::f_
TypedField< T > const * f_
Definition: STObject.h:63
ripple::STObject::setFieldU8
void setFieldU8(SField const &field, unsigned char)
Definition: STObject.cpp:631
std::enable_if_t
ripple::STObject::peekFieldArray
STArray & peekFieldArray(SField const &field)
Definition: STObject.cpp:429
ripple::STObject::setFieldAmount
void setFieldAmount(SField const &field, STAmount const &)
Definition: STObject.cpp:691
ripple::STObject::operator!=
bool operator!=(const STObject &o) const
Definition: STObject.h:590
ripple::STObject::getAccountID
AccountID getAccountID(SField const &field) const
Definition: STObject.cpp:573
ripple::STObject::setFieldH256
void setFieldH256(SField const &field, uint256 const &)
Definition: STObject.cpp:661
ripple::soeOPTIONAL
@ soeOPTIONAL
Definition: SOTemplate.h:35
ripple::SOEStyle
SOEStyle
Kind of element in each entry of an SOTemplate.
Definition: SOTemplate.h:32
ripple::throwFieldNotFound
void throwFieldNotFound(SField const &field)
Definition: STObject.h:46
ripple::STArray
Definition: STArray.h:28
ripple::STAmount
Definition: STAmount.h:42
ripple::STObject::clearFlag
bool clearFlag(std::uint32_t)
Definition: STObject.cpp:447
ripple::STObject::isDefault
virtual bool isDefault() const override
Definition: STObject.h:347
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:465
ripple::soeINVALID
@ soeINVALID
Definition: SOTemplate.h:33
std::runtime_error
STL class.
ripple::SerialIter
Definition: Serializer.h:368
std::uint32_t
ripple::STObject::OptionalProxy::operator!=
friend bool operator!=(OptionalProxy const &lhs, OptionalProxy const &rhs) noexcept
Definition: STObject.h:197
ripple::STObject::addWithoutSigningFields
void addWithoutSigningFields(Serializer &s) const
Definition: STObject.h:359
ripple::STObject::~STObject
virtual ~STObject()
Definition: STObject.cpp:29
ripple::STObject::OptionalProxy::optional_type
boost::optional< typename std::decay< value_type >::type > optional_type
Definition: STObject.h:107
ripple::STObject::reserve
void reserve(std::size_t n)
Definition: STObject.h:317
ripple::STObject::getFieldU16
std::uint16_t getFieldU16(SField const &field) const
Definition: STObject.cpp:537
ripple::STObject::setFieldUsingAssignment
void setFieldUsingAssignment(SField const &field, T const &value)
Definition: STObject.h:695
ripple::STObject::end
iterator end() const
Definition: STObject.h:305
ripple::STObject::getPField
STBase * getPField(SField const &field, bool createOkay=false)
Definition: STObject.cpp:396
ripple::STObject::setFieldPathSet
void setFieldPathSet(SField const &field, STPathSet const &)
Definition: STObject.cpp:697
ripple::STObject::getCountedObjectName
static char const * getCountedObjectName()
Definition: STObject.h:259
std::decay_t
ripple::Serializer
Definition: Serializer.h:43
ripple::STObject::mType
SOTemplate const * mType
Definition: STObject.h:247
ripple::STObject::getFieldIndex
int getFieldIndex(SField const &field) const
Definition: STObject.cpp:341
ripple::STObject::makeFieldPresent
STBase * makeFieldPresent(SField const &field)
Definition: STObject.cpp:476
ripple::STObject::emplace_back
std::size_t emplace_back(Args &&... args)
Definition: STObject.h:386
ripple::STObject::ValueProxy::ValueProxy
ValueProxy(ValueProxy const &)=default
ripple::STObject
Definition: STObject.h:51
ripple::STObject::Proxy
Definition: STObject.h:56
ripple::STObject::applyTemplateFromSField
void applyTemplateFromSField(SField const &) noexcept(false)
Definition: STObject.cpp:154
ripple::STObject::move
STBase * move(std::size_t n, void *buf) override
Definition: STObject.h:293
ripple::STObject::Proxy::find
T const * find() const
Definition: STObject.h:769
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::Proxy::style_
SOEStyle style_
Definition: STObject.h:62
std::remove_reference
ripple::STObject::peekFieldObject
STObject & peekFieldObject(SField const &field)
Definition: STObject.cpp:423
ripple::STObject::getSigningHash
uint256 getSigningHash(HashPrefix prefix) const
Definition: STObject.cpp:332
ripple::STObject::peekAtPField
const STBase * peekAtPField(SField const &field) const
Definition: STObject.cpp:385
ripple::STObject::add
virtual void add(Serializer &s) const override
Definition: STObject.h:353
ripple::SField
Identifies fields.
Definition: SField.h:109
ripple::STBase
A type which can be exported to a well known binary format.
Definition: STBase.h:62
ripple::STObject::getField
STBase & getField(SField const &field)
Definition: STObject.cpp:368
std::vector::begin
T begin(T... args)
ripple::SField::getName
std::string const & getName() const
Definition: SField.h:172
ripple::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition: STObject.cpp:412
ripple::STObject::getPIndex
STBase * getPIndex(int offset)
Definition: STObject.h:425
cassert
ripple::detail::STVar::get
STBase & get()
Definition: STVar.h:82
ripple::STObject::Transform
Definition: STObject.h:228
ripple::STObject::OptionalProxy::operator==
friend bool operator==(OptionalProxy const &lhs, OptionalProxy const &rhs) noexcept
Definition: STObject.h:165
ripple::STObject::OptionalProxy::operator~
optional_type operator~() const
Explicit conversion to boost::optional.
Definition: STObject.h:840
ripple::STObject::Proxy::Proxy
Proxy(Proxy const &)=default
ripple::STObject::getFieldByConstRef
V const & getFieldByConstRef(SField const &field, V const &empty) const
Definition: STObject.h:649
ripple::STObject::OptionalProxy::operator==
friend bool operator==(optional_type const &lhs, OptionalProxy const &rhs) noexcept
Definition: STObject.h:159
ripple::STObject::setFieldUsingSetValue
void setFieldUsingSetValue(SField const &field, V value)
Definition: STObject.h:672
ripple::STObject::setFlag
bool setFlag(std::uint32_t)
Definition: STObject.cpp:435
ripple::STVector256
Definition: STVector256.h:29
ripple::STObject::isFlag
bool isFlag(std::uint32_t) const
Definition: STObject.cpp:459
std::vector::empty
T empty(T... args)
ripple::STObject::OptionalProxy::operator*
value_type operator*() const
Return the contained value.
Definition: STObject.h:826
ripple::STObject::OptionalProxy::operator!=
friend bool operator!=(boost::none_t, OptionalProxy const &rhs) noexcept
Definition: STObject.h:179
std::remove_cv
ripple::STObject::Proxy::value
value_type value() const
Definition: STObject.h:756
ripple::STObject::getCount
int getCount() const
Definition: STObject.h:393
std::size_t
ripple::OptionaledField::f
TypedField< T > const * f
Definition: SField.h:299
std::vector::end
T end(T... args)
ripple::STObject::OptionalProxy::optional_value
optional_type optional_value() const
Definition: STObject.h:912
ripple::STI_OBJECT
@ STI_OBJECT
Definition: SField.h:68
ripple::STObject::operator[]
T::value_type operator[](TypedField< T > const &f) const
Return the value of a field.
Definition: STObject.h:923
ripple::STObject::getFieldU32
std::uint32_t getFieldU32(SField const &field) const
Definition: STObject.cpp:543
ripple::STObject::OptionalProxy::STObject
friend class STObject
Definition: STObject.h:214
ripple::STObject::getFieldByValue
V getFieldByValue(SField const &field) const
Definition: STObject.h:622
ripple::STObject::setFieldU64
void setFieldU64(SField const &field, std::uint64_t)
Definition: STObject.cpp:649
ripple::STObject::getJson
virtual Json::Value getJson(JsonOptions options) const override
Definition: STObject.cpp:709
ripple::STObject::Transform::operator()
STBase const & operator()(detail::STVar const &e) const
Definition: STObject.h:236
std::unique_ptr
STL class.
ripple::STObject::getFieldPathSet
STPathSet const & getFieldPathSet(SField const &field) const
Definition: STObject.cpp:594
ripple::STObject::omitSigningFields
@ omitSigningFields
Definition: STObject.h:599
ripple::STObject::set
void set(const SOTemplate &)
Definition: STObject.cpp:84
ripple::STObject::setFieldU32
void setFieldU32(SField const &field, std::uint32_t)
Definition: STObject.cpp:643
ripple::STObject::OptionalProxy::disengage
void disengage()
Definition: STObject.h:899
type_traits
ripple::STObject::getFieldAmount
STAmount const & getFieldAmount(SField const &field) const
Definition: STObject.cpp:587
ripple::soeDEFAULT
@ soeDEFAULT
Definition: SOTemplate.h:36
ripple::detail::STVar
Definition: STVar.h:49
ripple::STObject::isFree
bool isFree() const
Definition: STObject.h:329
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::STObject::ValueProxy::operator=
ValueProxy & operator=(ValueProxy const &)=delete
ripple::STObject::getHash
uint256 getHash(HashPrefix prefix) const
Definition: STObject.cpp:323
ripple::STI_NOTPRESENT
@ STI_NOTPRESENT
Definition: SField.h:56
ripple::STObject::reserveSize
@ reserveSize
Definition: STObject.h:242
ripple::STObject::getText
virtual std::string getText() const override
Definition: STObject.cpp:269
ripple::STObject::getFieldH256
uint256 getFieldH256(SField const &field) const
Definition: STObject.cpp:567