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