//------------------------------------------------------------------------------ /* This file is part of rippled: https://github.com/ripple/rippled Copyright (c) 2012, 2013 Ripple Labs Inc. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #ifndef RIPPLE_PROTOCOL_STVECTOR256_H_INCLUDED #define RIPPLE_PROTOCOL_STVECTOR256_H_INCLUDED #include #include #include #include namespace ripple { class STVector256 : public STBase, public CountedObject { std::vector mValue; public: using value_type = std::vector const&; STVector256() = default; explicit STVector256(SField const& n); explicit STVector256(std::vector const& vector); STVector256(SField const& n, std::vector const& vector); STVector256(SerialIter& sit, SField const& name); SerializedTypeID getSType() const override; void add(Serializer& s) const override; Json::Value getJson(JsonOptions) const override; bool isEquivalent(STBase const& t) const override; bool isDefault() const override; STVector256& operator=(std::vector const& v); STVector256& operator=(std::vector&& v); void setValue(STVector256 const& v); /** Retrieve a copy of the vector we contain */ explicit operator std::vector() const; std::size_t size() const; void resize(std::size_t n); bool empty() const; std::vector::reference operator[](std::vector::size_type n); std::vector::const_reference operator[](std::vector::size_type n) const; std::vector const& value() const; std::vector::iterator insert(std::vector::const_iterator pos, uint256 const& value); std::vector::iterator insert(std::vector::const_iterator pos, uint256&& value); void push_back(uint256 const& v); std::vector::iterator begin(); std::vector::const_iterator begin() const; std::vector::iterator end(); std::vector::const_iterator end() const; std::vector::iterator erase(std::vector::iterator position); void clear() noexcept; private: STBase* copy(std::size_t n, void* buf) const override; STBase* move(std::size_t n, void* buf) override; friend class detail::STVar; }; inline STVector256::STVector256(SField const& n) : STBase(n) { } inline STVector256::STVector256(std::vector const& vector) : mValue(vector) { } inline STVector256::STVector256( SField const& n, std::vector const& vector) : STBase(n), mValue(vector) { } inline STVector256& STVector256::operator=(std::vector const& v) { mValue = v; return *this; } inline STVector256& STVector256::operator=(std::vector&& v) { mValue = std::move(v); return *this; } inline void STVector256::setValue(STVector256 const& v) { mValue = v.mValue; } /** Retrieve a copy of the vector we contain */ inline STVector256::operator std::vector() const { return mValue; } inline std::size_t STVector256::size() const { return mValue.size(); } inline void STVector256::resize(std::size_t n) { return mValue.resize(n); } inline bool STVector256::empty() const { return mValue.empty(); } inline std::vector::reference STVector256::operator[](std::vector::size_type n) { return mValue[n]; } inline std::vector::const_reference STVector256::operator[](std::vector::size_type n) const { return mValue[n]; } inline std::vector const& STVector256::value() const { return mValue; } inline std::vector::iterator STVector256::insert( std::vector::const_iterator pos, uint256 const& value) { return mValue.insert(pos, value); } inline std::vector::iterator STVector256::insert(std::vector::const_iterator pos, uint256&& value) { return mValue.insert(pos, std::move(value)); } inline void STVector256::push_back(uint256 const& v) { mValue.push_back(v); } inline std::vector::iterator STVector256::begin() { return mValue.begin(); } inline std::vector::const_iterator STVector256::begin() const { return mValue.begin(); } inline std::vector::iterator STVector256::end() { return mValue.end(); } inline std::vector::const_iterator STVector256::end() const { return mValue.end(); } inline std::vector::iterator STVector256::erase(std::vector::iterator position) { return mValue.erase(position); } inline void STVector256::clear() noexcept { return mValue.clear(); } } // namespace ripple #endif