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 
243 
246 
247 public:
248  using iterator = boost::
249  transform_iterator<Transform, STObject::list_type::const_iterator>;
250 
252  {
254  };
255 
256  static char const*
258  {
259  return "STObject";
260  }
261 
262  STObject(STObject&&);
263  STObject(STObject const&) = default;
264  STObject(const SOTemplate& type, SField const& name);
265  STObject(
266  const SOTemplate& type,
267  SerialIter& sit,
268  SField const& name) noexcept(false);
269  STObject(SerialIter& sit, SField const& name, int depth = 0) noexcept(
270  false);
271  STObject(SerialIter&& sit, SField const& name) noexcept(false)
272  : STObject(sit, name)
273  {
274  }
275  STObject&
276  operator=(STObject const&) = default;
277  STObject&
278  operator=(STObject&& other);
279 
280  explicit STObject(SField const& name);
281 
282  virtual ~STObject() = default;
283 
284  STBase*
285  copy(std::size_t n, void* buf) const override
286  {
287  return emplace(n, buf, *this);
288  }
289 
290  STBase*
291  move(std::size_t n, void* buf) override
292  {
293  return emplace(n, buf, std::move(*this));
294  }
295 
296  iterator
297  begin() const
298  {
299  return iterator(v_.begin());
300  }
301 
302  iterator
303  end() const
304  {
305  return iterator(v_.end());
306  }
307 
308  bool
309  empty() const
310  {
311  return v_.empty();
312  }
313 
314  void
316  {
317  v_.reserve(n);
318  }
319 
320  void
321  applyTemplate(const SOTemplate& type) noexcept(false);
322 
323  void
324  applyTemplateFromSField(SField const&) noexcept(false);
325 
326  bool
327  isFree() const
328  {
329  return mType == nullptr;
330  }
331 
332  void
333  set(const SOTemplate&);
334  bool
335  set(SerialIter& u, int depth = 0);
336 
337  virtual SerializedTypeID
338  getSType() const override
339  {
340  return STI_OBJECT;
341  }
342  virtual bool
343  isEquivalent(const STBase& t) const override;
344  virtual bool
345  isDefault() const override
346  {
347  return v_.empty();
348  }
349 
350  virtual void
351  add(Serializer& s) const override
352  {
353  add(s, withAllFields); // just inner elements
354  }
355 
356  void
358  {
360  }
361 
362  // VFALCO NOTE does this return an expensive copy of an object with a
363  // dynamic buffer?
364  // VFALCO TODO Remove this function and fix the few callers.
365  Serializer
367  {
368  Serializer s;
369  add(s, withAllFields);
370  return s;
371  }
372 
373  virtual std::string
374  getFullText() const override;
375  virtual std::string
376  getText() const override;
377 
378  // TODO(tom): options should be an enum.
379  virtual Json::Value
380  getJson(JsonOptions options) const override;
381 
382  template <class... Args>
384  emplace_back(Args&&... args)
385  {
386  v_.emplace_back(std::forward<Args>(args)...);
387  return v_.size() - 1;
388  }
389 
390  int
391  getCount() const
392  {
393  return v_.size();
394  }
395 
396  bool setFlag(std::uint32_t);
397  bool clearFlag(std::uint32_t);
398  bool isFlag(std::uint32_t) const;
400  getFlags() const;
401 
402  uint256
403  getHash(HashPrefix prefix) const;
404  uint256
405  getSigningHash(HashPrefix prefix) const;
406 
407  const STBase&
408  peekAtIndex(int offset) const
409  {
410  return v_[offset].get();
411  }
412  STBase&
413  getIndex(int offset)
414  {
415  return v_[offset].get();
416  }
417  const STBase*
418  peekAtPIndex(int offset) const
419  {
420  return &v_[offset].get();
421  }
422  STBase*
423  getPIndex(int offset)
424  {
425  return &v_[offset].get();
426  }
427 
428  int
429  getFieldIndex(SField const& field) const;
430  SField const&
431  getFieldSType(int index) const;
432 
433  const STBase&
434  peekAtField(SField const& field) const;
435  STBase&
436  getField(SField const& field);
437  const STBase*
438  peekAtPField(SField const& field) const;
439  STBase*
440  getPField(SField const& field, bool createOkay = false);
441 
442  // these throw if the field type doesn't match, or return default values
443  // if the field is optional but not present
444  unsigned char
445  getFieldU8(SField const& field) const;
447  getFieldU16(SField const& field) const;
449  getFieldU32(SField const& field) const;
451  getFieldU64(SField const& field) const;
452  uint128
453  getFieldH128(SField const& field) const;
454 
455  uint160
456  getFieldH160(SField const& field) const;
457  uint256
458  getFieldH256(SField const& field) const;
459  AccountID
460  getAccountID(SField const& field) const;
461 
462  Blob
463  getFieldVL(SField const& field) const;
464  STAmount const&
465  getFieldAmount(SField const& field) const;
466  STPathSet const&
467  getFieldPathSet(SField const& field) const;
468  const STVector256&
469  getFieldV256(SField const& field) const;
470  const STArray&
471  getFieldArray(SField const& field) const;
472 
480  template <class T>
481  typename T::value_type
482  operator[](TypedField<T> const& f) const;
483 
488  template <class T>
489  boost::optional<std::decay_t<typename T::value_type>>
490  operator[](OptionaledField<T> const& of) const;
491 
499  template <class T>
500  ValueProxy<T>
501  operator[](TypedField<T> const& f);
502 
508  template <class T>
509  OptionalProxy<T>
510  operator[](OptionaledField<T> const& of);
511 
515  void
517 
518  void
519  setFieldU8(SField const& field, unsigned char);
520  void
521  setFieldU16(SField const& field, std::uint16_t);
522  void
523  setFieldU32(SField const& field, std::uint32_t);
524  void
525  setFieldU64(SField const& field, std::uint64_t);
526  void
527  setFieldH128(SField const& field, uint128 const&);
528  void
529  setFieldH256(SField const& field, uint256 const&);
530  void
531  setFieldVL(SField const& field, Blob const&);
532  void
533  setFieldVL(SField const& field, Slice const&);
534 
535  void
536  setAccountID(SField const& field, AccountID const&);
537 
538  void
539  setFieldAmount(SField const& field, STAmount const&);
540  void
541  setFieldPathSet(SField const& field, STPathSet const&);
542  void
543  setFieldV256(SField const& field, STVector256 const& v);
544  void
545  setFieldArray(SField const& field, STArray const& v);
546 
547  template <class Tag>
548  void
549  setFieldH160(SField const& field, base_uint<160, Tag> const& v)
550  {
551  STBase* rf = getPField(field, true);
552 
553  if (!rf)
554  throwFieldNotFound(field);
555 
556  if (rf->getSType() == STI_NOTPRESENT)
557  rf = makeFieldPresent(field);
558 
559  using Bits = STBitString<160>;
560  if (auto cf = dynamic_cast<Bits*>(rf))
561  cf->setValue(v);
562  else
563  Throw<std::runtime_error>("Wrong field type");
564  }
565 
566  STObject&
567  peekFieldObject(SField const& field);
568  STArray&
569  peekFieldArray(SField const& field);
570 
571  bool
572  isFieldPresent(SField const& field) const;
573  STBase*
574  makeFieldPresent(SField const& field);
575  void
576  makeFieldAbsent(SField const& field);
577  bool
578  delField(SField const& field);
579  void
580  delField(int index);
581 
582  bool
583  hasMatchingEntry(const STBase&);
584 
585  bool
586  operator==(const STObject& o) const;
587  bool
588  operator!=(const STObject& o) const
589  {
590  return !(*this == o);
591  }
592 
593 private:
594  enum WhichFields : bool {
595  // These values are carefully chosen to do the right thing if passed
596  // to SField::shouldInclude (bool)
599  };
600 
601  void
602  add(Serializer& s, WhichFields whichFields) const;
603 
604  // Sort the entries in an STObject into the order that they will be
605  // serialized. Note: they are not sorted into pointer value order, they
606  // are sorted by SField::fieldCode.
608  getSortedFields(STObject const& objToSort, WhichFields whichFields);
609 
610  // Implementation for getting (most) fields that return by value.
611  //
612  // The remove_cv and remove_reference are necessitated by the STBitString
613  // types. Their value() returns by const ref. We return those types
614  // by value.
615  template <
616  typename T,
617  typename V = typename std::remove_cv<typename std::remove_reference<
618  decltype(std::declval<T>().value())>::type>::type>
619  V
620  getFieldByValue(SField const& field) const
621  {
622  const STBase* rf = peekAtPField(field);
623 
624  if (!rf)
625  throwFieldNotFound(field);
626 
627  SerializedTypeID id = rf->getSType();
628 
629  if (id == STI_NOTPRESENT)
630  return V(); // optional field not present
631 
632  const T* cf = dynamic_cast<const T*>(rf);
633 
634  if (!cf)
635  Throw<std::runtime_error>("Wrong field type");
636 
637  return cf->value();
638  }
639 
640  // Implementations for getting (most) fields that return by const reference.
641  //
642  // If an absent optional field is deserialized we don't have anything
643  // obvious to return. So we insist on having the call provide an
644  // 'empty' value we return in that circumstance.
645  template <typename T, typename V>
646  V const&
647  getFieldByConstRef(SField const& field, V const& empty) const
648  {
649  const STBase* rf = peekAtPField(field);
650 
651  if (!rf)
652  throwFieldNotFound(field);
653 
654  SerializedTypeID id = rf->getSType();
655 
656  if (id == STI_NOTPRESENT)
657  return empty; // optional field not present
658 
659  const T* cf = dynamic_cast<const T*>(rf);
660 
661  if (!cf)
662  Throw<std::runtime_error>("Wrong field type");
663 
664  return *cf;
665  }
666 
667  // Implementation for setting most fields with a setValue() method.
668  template <typename T, typename V>
669  void
671  {
672  static_assert(!std::is_lvalue_reference<V>::value, "");
673 
674  STBase* rf = getPField(field, true);
675 
676  if (!rf)
677  throwFieldNotFound(field);
678 
679  if (rf->getSType() == STI_NOTPRESENT)
680  rf = makeFieldPresent(field);
681 
682  T* cf = dynamic_cast<T*>(rf);
683 
684  if (!cf)
685  Throw<std::runtime_error>("Wrong field type");
686 
687  cf->setValue(std::move(value));
688  }
689 
690  // Implementation for setting fields using assignment
691  template <typename T>
692  void
693  setFieldUsingAssignment(SField const& field, T const& value)
694  {
695  STBase* rf = getPField(field, true);
696 
697  if (!rf)
698  throwFieldNotFound(field);
699 
700  if (rf->getSType() == STI_NOTPRESENT)
701  rf = makeFieldPresent(field);
702 
703  T* cf = dynamic_cast<T*>(rf);
704 
705  if (!cf)
706  Throw<std::runtime_error>("Wrong field type");
707 
708  (*cf) = value;
709  }
710 
711  // Implementation for peeking STObjects and STArrays
712  template <typename T>
713  T&
714  peekField(SField const& field)
715  {
716  STBase* rf = getPField(field, true);
717 
718  if (!rf)
719  throwFieldNotFound(field);
720 
721  if (rf->getSType() == STI_NOTPRESENT)
722  rf = makeFieldPresent(field);
723 
724  T* cf = dynamic_cast<T*>(rf);
725 
726  if (!cf)
727  Throw<std::runtime_error>("Wrong field type");
728 
729  return *cf;
730  }
731 };
732 
733 //------------------------------------------------------------------------------
734 
735 template <class T>
736 STObject::Proxy<T>::Proxy(STObject* st, TypedField<T> const* f) : st_(st), f_(f)
737 {
738  if (st_->mType)
739  {
740  // STObject has associated template
741  if (!st_->peekAtPField(*f_))
742  Throw<STObject::FieldErr>(
743  "Template field error '" + this->f_->getName() + "'");
744  style_ = st_->mType->style(*f_);
745  }
746  else
747  {
748  style_ = soeINVALID;
749  }
750 }
751 
752 template <class T>
753 auto
755 {
756  auto const t = find();
757  if (t)
758  return t->value();
759  if (style_ != soeDEFAULT)
760  Throw<STObject::FieldErr>(
761  "Missing field '" + this->f_->getName() + "'");
762  return value_type{};
763 }
764 
765 template <class T>
766 inline T const*
768 {
769  return dynamic_cast<T const*>(st_->peekAtPField(*f_));
770 }
771 
772 template <class T>
773 template <class U>
774 void
776 {
777  if (style_ == soeDEFAULT && u == value_type{})
778  {
779  st_->makeFieldAbsent(*f_);
780  return;
781  }
782  T* t;
783  if (style_ == soeINVALID)
784  t = dynamic_cast<T*>(st_->getPField(*f_, true));
785  else
786  t = dynamic_cast<T*>(st_->makeFieldPresent(*f_));
787  assert(t);
788  *t = std::forward<U>(u);
789 }
790 
791 //------------------------------------------------------------------------------
792 
793 template <class T>
794 template <class U>
797 {
798  this->assign(std::forward<U>(u));
799  return *this;
800 }
801 
802 template <class T>
804 {
805  return this->value();
806 }
807 
808 template <class T>
810  : Proxy<T>(st, f)
811 {
812 }
813 
814 //------------------------------------------------------------------------------
815 
816 template <class T>
818 {
819  return engaged();
820 }
821 
822 template <class T>
823 auto
825 {
826  return this->value();
827 }
828 
829 template <class T>
831  T>::optional_type() const
832 {
833  return optional_value();
834 }
835 
836 template <class T>
839 {
840  return optional_value();
841 }
842 
843 template <class T>
844 auto
846 {
847  disengage();
848  return *this;
849 }
850 
851 template <class T>
852 auto
854 {
855  if (v)
856  this->assign(std::move(*v));
857  else
858  disengage();
859  return *this;
860 }
861 
862 template <class T>
863 auto
865 {
866  if (v)
867  this->assign(*v);
868  else
869  disengage();
870  return *this;
871 }
872 
873 template <class T>
874 template <class U>
877 {
878  this->assign(std::forward<U>(u));
879  return *this;
880 }
881 
882 template <class T>
884  : Proxy<T>(st, f)
885 {
886 }
887 
888 template <class T>
889 bool
891 {
892  return this->style_ == soeDEFAULT || this->find() != nullptr;
893 }
894 
895 template <class T>
896 void
898 {
899  if (this->style_ == soeREQUIRED || this->style_ == soeDEFAULT)
900  Throw<STObject::FieldErr>(
901  "Template field error '" + this->f_->getName() + "'");
902  if (this->style_ == soeINVALID)
903  this->st_->delField(*this->f_);
904  else
905  this->st_->makeFieldAbsent(*this->f_);
906 }
907 
908 template <class T>
909 auto
911 {
912  if (!engaged())
913  return boost::none;
914  return this->value();
915 }
916 
917 //------------------------------------------------------------------------------
918 
919 template <class T>
920 typename T::value_type
922 {
923  auto const b = peekAtPField(f);
924  if (!b)
925  // This is a free object (no constraints)
926  // with no template
927  Throw<STObject::FieldErr>("Missing field '" + f.getName() + "'");
928  auto const u = dynamic_cast<T const*>(b);
929  if (!u)
930  {
931  assert(mType);
932  assert(b->getSType() == STI_NOTPRESENT);
933  if (mType->style(f) == soeOPTIONAL)
934  Throw<STObject::FieldErr>("Missing field '" + f.getName() + "'");
935  assert(mType->style(f) == soeDEFAULT);
936  // Handle the case where value_type is a
937  // const reference, otherwise we return
938  // the address of a temporary.
939  static std::decay_t<typename T::value_type> const dv{};
940  return dv;
941  }
942  return u->value();
943 }
944 
945 template <class T>
946 boost::optional<std::decay_t<typename T::value_type>>
948 {
949  auto const b = peekAtPField(*of.f);
950  if (!b)
951  return boost::none;
952  auto const u = dynamic_cast<T const*>(b);
953  if (!u)
954  {
955  assert(mType);
956  assert(b->getSType() == STI_NOTPRESENT);
957  if (mType->style(*of.f) == soeOPTIONAL)
958  return boost::none;
959  assert(mType->style(*of.f) == soeDEFAULT);
960  return typename T::value_type{};
961  }
962  return u->value();
963 }
964 
965 template <class T>
966 inline auto
968 {
969  return ValueProxy<T>(this, &f);
970 }
971 
972 template <class T>
973 inline auto
975 {
976  return OptionalProxy<T>(this, of.f);
977 }
978 
979 } // namespace ripple
980 
981 #endif
ripple::STObject::getFieldSType
SField const & getFieldSType(int index) const
Definition: STObject.cpp:368
ripple::STObject::peekAtField
const STBase & peekAtField(SField const &field) const
Definition: STObject.cpp:346
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:413
ripple::STObject::getSortedFields
static std::vector< STBase const * > getSortedFields(STObject const &objToSort, WhichFields whichFields)
Definition: STObject.cpp:779
ripple::STObject::setAccountID
void setAccountID(SField const &field, AccountID const &)
Definition: STObject.cpp:662
ripple::STBase::STBase
STBase()
Definition: STBase.cpp:27
ripple::STObject::OptionalProxy::engaged
bool engaged() const noexcept
Definition: STObject.h:890
ripple::STObject::getFieldArray
const STArray & getFieldArray(SField const &field) const
Definition: STObject.cpp:597
ripple::STBase::getSType
virtual SerializedTypeID getSType() const
Definition: STBase.cpp:67
ripple::SOTemplate::style
SOEStyle style(SField const &sf) const
Definition: SOTemplate.h:135
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:487
std::string
STL class.
ripple::STObject::hasMatchingEntry
bool hasMatchingEntry(const STBase &)
Definition: STObject.cpp:216
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:644
ripple::STObject::setFieldU16
void setFieldU16(SField const &field, std::uint16_t)
Definition: STObject.cpp:626
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:656
ripple::STObject::getFieldU64
std::uint64_t getFieldU64(SField const &field) const
Definition: STObject.cpp:538
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:590
ripple::STObject::v_
list_type v_
Definition: STObject.h:244
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:520
ripple::SerializedTypeID
SerializedTypeID
Definition: SField.h:52
ripple::STObject::withAllFields
@ withAllFields
Definition: STObject.h:598
ripple::STObject::copy
STBase * copy(std::size_t n, void *buf) const override
Definition: STObject.h:285
ripple::STObject::empty
bool empty() const
Definition: STObject.h:309
ripple::STObject::getSerializer
Serializer getSerializer() const
Definition: STObject.h:366
ripple::STObject::getFieldH128
uint128 getFieldH128(SField const &field) const
Definition: STObject.cpp:544
ripple::STObject::WhichFields
WhichFields
Definition: STObject.h:594
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:668
ripple::STObject::getFieldVL
Blob getFieldVL(SField const &field) const
Definition: STObject.cpp:568
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::~STObject
virtual ~STObject()=default
ripple::STObject::peekAtPIndex
const STBase * peekAtPIndex(int offset) const
Definition: STObject.h:418
ripple::STObject::getFieldH160
uint160 getFieldH160(SField const &field) const
Definition: STObject.cpp:550
ripple::STBitString
Definition: SField.h:47
ripple::STObject::peekAtIndex
const STBase & peekAtIndex(int offset) const
Definition: STObject.h:408
ripple::STPathSet
Definition: STPathSet.h:309
ripple::STObject::getFullText
virtual std::string getFullText() const override
Definition: STObject.cpp:227
ripple::STObject::isEquivalent
virtual bool isEquivalent(const STBase &t) const override
Definition: STObject.cpp:277
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:775
stdexcept
ripple::base_uint< 256 >
ripple::STObject::setFieldH160
void setFieldH160(SField const &field, base_uint< 160, Tag > const &v)
Definition: STObject.h:549
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:338
ripple::STObject::FieldErr
Definition: STObject.h:251
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:502
ripple::STObject::peekField
T & peekField(SField const &field)
Definition: STObject.h:714
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:81
ripple::STObject::OptionalProxy
Definition: STObject.h:101
ripple::STObject::begin
iterator begin() const
Definition: STObject.h:297
ripple::STObject::setFieldArray
void setFieldArray(SField const &field, STArray const &v)
Definition: STObject.cpp:692
ripple::STObject::iterator
boost::transform_iterator< Transform, STObject::list_type::const_iterator > iterator
Definition: STObject.h:249
ripple::STObject::applyTemplate
void applyTemplate(const SOTemplate &type) noexcept(false)
Definition: STObject.cpp:89
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:620
std::enable_if_t
ripple::STObject::peekFieldArray
STArray & peekFieldArray(SField const &field)
Definition: STObject.cpp:418
ripple::STObject::setFieldAmount
void setFieldAmount(SField const &field, STAmount const &)
Definition: STObject.cpp:680
ripple::STObject::operator!=
bool operator!=(const STObject &o) const
Definition: STObject.h:588
ripple::STObject::getAccountID
AccountID getAccountID(SField const &field) const
Definition: STObject.cpp:562
ripple::STObject::setFieldH256
void setFieldH256(SField const &field, uint256 const &)
Definition: STObject.cpp:650
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:436
ripple::STObject::isDefault
virtual bool isDefault() const override
Definition: STObject.h:345
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:454
ripple::soeINVALID
@ soeINVALID
Definition: SOTemplate.h:33
std::runtime_error
STL class.
ripple::SerialIter
Definition: Serializer.h:308
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:357
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:315
ripple::STObject::getFieldU16
std::uint16_t getFieldU16(SField const &field) const
Definition: STObject.cpp:526
ripple::STObject::setFieldUsingAssignment
void setFieldUsingAssignment(SField const &field, T const &value)
Definition: STObject.h:693
ripple::STObject::end
iterator end() const
Definition: STObject.h:303
ripple::STObject::getPField
STBase * getPField(SField const &field, bool createOkay=false)
Definition: STObject.cpp:385
ripple::STObject::setFieldPathSet
void setFieldPathSet(SField const &field, STPathSet const &)
Definition: STObject.cpp:686
ripple::STObject::getCountedObjectName
static char const * getCountedObjectName()
Definition: STObject.h:257
std::decay_t
ripple::Serializer
Definition: Serializer.h:39
ripple::STObject::mType
SOTemplate const * mType
Definition: STObject.h:245
ripple::STObject::getFieldIndex
int getFieldIndex(SField const &field) const
Definition: STObject.cpp:330
ripple::STObject::makeFieldPresent
STBase * makeFieldPresent(SField const &field)
Definition: STObject.cpp:465
ripple::STObject::emplace_back
std::size_t emplace_back(Args &&... args)
Definition: STObject.h:384
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:143
ripple::STObject::move
STBase * move(std::size_t n, void *buf) override
Definition: STObject.h:291
ripple::STObject::Proxy::find
T const * find() const
Definition: STObject.h:767
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:412
ripple::STObject::getSigningHash
uint256 getSigningHash(HashPrefix prefix) const
Definition: STObject.cpp:321
ripple::STObject::peekAtPField
const STBase * peekAtPField(SField const &field) const
Definition: STObject.cpp:374
ripple::STObject::add
virtual void add(Serializer &s) const override
Definition: STObject.h:351
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:357
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:401
ripple::STObject::getPIndex
STBase * getPIndex(int offset)
Definition: STObject.h:423
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:838
ripple::STObject::Proxy::Proxy
Proxy(Proxy const &)=default
ripple::STObject::getFieldByConstRef
V const & getFieldByConstRef(SField const &field, V const &empty) const
Definition: STObject.h:647
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:670
ripple::STObject::setFlag
bool setFlag(std::uint32_t)
Definition: STObject.cpp:424
ripple::STVector256
Definition: STVector256.h:29
ripple::STObject::isFlag
bool isFlag(std::uint32_t) const
Definition: STObject.cpp:448
std::vector::empty
T empty(T... args)
ripple::STObject::OptionalProxy::operator*
value_type operator*() const
Return the contained value.
Definition: STObject.h:824
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:754
ripple::STObject::getCount
int getCount() const
Definition: STObject.h:391
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:910
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:921
ripple::STObject::getFieldU32
std::uint32_t getFieldU32(SField const &field) const
Definition: STObject.cpp:532
ripple::STObject::OptionalProxy::STObject
friend class STObject
Definition: STObject.h:214
ripple::STObject::getFieldByValue
V getFieldByValue(SField const &field) const
Definition: STObject.h:620
ripple::STObject::setFieldU64
void setFieldU64(SField const &field, std::uint64_t)
Definition: STObject.cpp:638
ripple::STObject::getJson
virtual Json::Value getJson(JsonOptions options) const override
Definition: STObject.cpp:698
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:583
ripple::STObject::omitSigningFields
@ omitSigningFields
Definition: STObject.h:597
ripple::STObject::set
void set(const SOTemplate &)
Definition: STObject.cpp:73
ripple::STObject::setFieldU32
void setFieldU32(SField const &field, std::uint32_t)
Definition: STObject.cpp:632
ripple::STObject::OptionalProxy::disengage
void disengage()
Definition: STObject.h:897
type_traits
ripple::STObject::getFieldAmount
STAmount const & getFieldAmount(SField const &field) const
Definition: STObject.cpp:576
ripple::soeDEFAULT
@ soeDEFAULT
Definition: SOTemplate.h:36
ripple::detail::STVar
Definition: STVar.h:49
ripple::STObject::isFree
bool isFree() const
Definition: STObject.h:327
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:312
ripple::STI_NOTPRESENT
@ STI_NOTPRESENT
Definition: SField.h:56
ripple::STObject::getText
virtual std::string getText() const override
Definition: STObject.cpp:258
ripple::STObject::getFieldH256
uint256 getFieldH256(SField const &field) const
Definition: STObject.cpp:556