#ifndef XRPL_PROTOCOL_STINTEGER_H_INCLUDED #define XRPL_PROTOCOL_STINTEGER_H_INCLUDED #include #include namespace ripple { template class STInteger : public STBase, public CountedObject> { public: using value_type = Integer; private: Integer value_; public: explicit STInteger(Integer v); STInteger(SField const& n, Integer v = 0); STInteger(SerialIter& sit, SField const& name); SerializedTypeID getSType() const override; Json::Value getJson(JsonOptions) const override; std::string getText() const override; void add(Serializer& s) const override; bool isDefault() const override; bool isEquivalent(STBase const& t) const override; STInteger& operator=(value_type const& v); value_type value() const noexcept; void setValue(Integer v); operator Integer() const; private: STBase* copy(std::size_t n, void* buf) const override; STBase* move(std::size_t n, void* buf) override; friend class ripple::detail::STVar; }; using STUInt8 = STInteger; using STUInt16 = STInteger; using STUInt32 = STInteger; using STUInt64 = STInteger; using STInt32 = STInteger; template inline STInteger::STInteger(Integer v) : value_(v) { } template inline STInteger::STInteger(SField const& n, Integer v) : STBase(n), value_(v) { } template inline STBase* STInteger::copy(std::size_t n, void* buf) const { return emplace(n, buf, *this); } template inline STBase* STInteger::move(std::size_t n, void* buf) { return emplace(n, buf, std::move(*this)); } template inline void STInteger::add(Serializer& s) const { XRPL_ASSERT( getFName().isBinary(), "ripple::STInteger::add : field is binary"); XRPL_ASSERT( getFName().fieldType == getSType(), "ripple::STInteger::add : field type match"); s.addInteger(value_); } template inline bool STInteger::isDefault() const { return value_ == 0; } template inline bool STInteger::isEquivalent(STBase const& t) const { STInteger const* v = dynamic_cast(&t); return v && (value_ == v->value_); } template inline STInteger& STInteger::operator=(value_type const& v) { value_ = v; return *this; } template inline typename STInteger::value_type STInteger::value() const noexcept { return value_; } template inline void STInteger::setValue(Integer v) { value_ = v; } template inline STInteger::operator Integer() const { return value_; } } // namespace ripple #endif