rippled
Loading...
Searching...
No Matches
STVector256.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_STVECTOR256_H_INCLUDED
21#define RIPPLE_PROTOCOL_STVECTOR256_H_INCLUDED
22
23#include <xrpl/basics/CountedObject.h>
24#include <xrpl/protocol/STBase.h>
25#include <xrpl/protocol/STBitString.h>
26#include <xrpl/protocol/STInteger.h>
27
28namespace ripple {
29
30class STVector256 : public STBase, public CountedObject<STVector256>
31{
33
34public:
36
37 STVector256() = default;
38
39 explicit STVector256(SField const& n);
40 explicit STVector256(std::vector<uint256> const& vector);
41 STVector256(SField const& n, std::vector<uint256> const& vector);
42 STVector256(SerialIter& sit, SField const& name);
43
45 getSType() const override;
46
47 void
48 add(Serializer& s) const override;
49
50 Json::Value getJson(JsonOptions) const override;
51
52 bool
53 isEquivalent(STBase const& t) const override;
54
55 bool
56 isDefault() const override;
57
60
63
64 void
65 setValue(STVector256 const& v);
66
68 explicit
69 operator std::vector<uint256>() const;
70
72 size() const;
73
74 void
76
77 bool
78 empty() const;
79
82
85
87 value() const;
88
91
94
95 void
96 push_back(uint256 const& v);
97
99 begin();
100
102 begin() const;
103
105 end();
106
108 end() const;
109
112
113 void
114 clear() noexcept;
115
116private:
117 STBase*
118 copy(std::size_t n, void* buf) const override;
119 STBase*
120 move(std::size_t n, void* buf) override;
121
122 friend class detail::STVar;
123};
124
125inline STVector256::STVector256(SField const& n) : STBase(n)
126{
127}
128
130 : mValue(vector)
131{
132}
133
135 SField const& n,
136 std::vector<uint256> const& vector)
137 : STBase(n), mValue(vector)
138{
139}
140
141inline STVector256&
143{
144 mValue = v;
145 return *this;
146}
147
148inline STVector256&
150{
151 mValue = std::move(v);
152 return *this;
153}
154
155inline void
157{
158 mValue = v.mValue;
159}
160
162inline STVector256::operator std::vector<uint256>() const
163{
164 return mValue;
165}
166
167inline std::size_t
169{
170 return mValue.size();
171}
172
173inline void
175{
176 return mValue.resize(n);
177}
178
179inline bool
181{
182 return mValue.empty();
183}
184
190
196
197inline std::vector<uint256> const&
199{
200 return mValue;
201}
202
206 uint256 const& value)
207{
208 return mValue.insert(pos, value);
209}
210
213{
214 return mValue.insert(pos, std::move(value));
215}
216
217inline void
219{
220 mValue.push_back(v);
221}
222
225{
226 return mValue.begin();
227}
228
231{
232 return mValue.begin();
233}
234
237{
238 return mValue.end();
239}
240
243{
244 return mValue.end();
245}
246
249{
250 return mValue.erase(position);
251}
252
253inline void
255{
256 return mValue.clear();
257}
258
259} // namespace ripple
260
261#endif
T begin(T... args)
Represents a JSON value.
Definition json_value.h:149
Tracks the number of instances of an object.
Identifies fields.
Definition SField.h:146
A type which can be exported to a well known binary format.
Definition STBase.h:135
void resize(std::size_t n)
std::vector< uint256 > const & value() const
std::vector< uint256 >::iterator begin()
STVector256 & operator=(std::vector< uint256 > const &v)
void add(Serializer &s) const override
SerializedTypeID getSType() const override
void clear() noexcept
std::vector< uint256 >::iterator erase(std::vector< uint256 >::iterator position)
Json::Value getJson(JsonOptions) const override
STBase * copy(std::size_t n, void *buf) const override
bool isDefault() const override
std::size_t size() const
friend class detail::STVar
bool isEquivalent(STBase const &t) const override
void push_back(uint256 const &v)
void setValue(STVector256 const &v)
STBase * move(std::size_t n, void *buf) override
std::vector< uint256 >::reference operator[](std::vector< uint256 >::size_type n)
std::vector< uint256 >::iterator insert(std::vector< uint256 >::const_iterator pos, uint256 const &value)
bool empty() const
std::vector< uint256 > mValue
Definition STVector256.h:32
std::vector< uint256 >::iterator end()
T end(T... args)
T erase(T... args)
T insert(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
SerializedTypeID
Definition SField.h:110
STL namespace.
Note, should be treated as flags that can be | and &.
Definition STBase.h:37