mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add operator[] field accessors to STObject:
New array index operators allow for concise reading and writing of fields in the STObject, with associated unit test.
This commit is contained in:
committed by
Edward Hennis
parent
3e342e4b71
commit
2ec40cb6f1
@@ -31,6 +31,8 @@ class STVector256
|
||||
: public STBase
|
||||
{
|
||||
public:
|
||||
using value_type = std::vector<uint256> const&;
|
||||
|
||||
STVector256 () = default;
|
||||
|
||||
explicit STVector256 (SField const& n)
|
||||
@@ -80,6 +82,20 @@ public:
|
||||
return mValue.empty ();
|
||||
}
|
||||
|
||||
STVector256&
|
||||
operator= (std::vector<uint256> const& v)
|
||||
{
|
||||
mValue = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
STVector256&
|
||||
operator= (std::vector<uint256>&& v)
|
||||
{
|
||||
mValue = std::move(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
setValue (const STVector256& v)
|
||||
{
|
||||
@@ -93,15 +109,14 @@ public:
|
||||
return mValue;
|
||||
}
|
||||
|
||||
// std::vector<uint256> interface:
|
||||
std::vector<uint256>::size_type
|
||||
std::size_t
|
||||
size () const
|
||||
{
|
||||
return mValue.size ();
|
||||
}
|
||||
|
||||
void
|
||||
resize (std::vector<uint256>::size_type n)
|
||||
resize (std::size_t n)
|
||||
{
|
||||
return mValue.resize (n);
|
||||
}
|
||||
@@ -124,6 +139,12 @@ public:
|
||||
return mValue[n];
|
||||
}
|
||||
|
||||
std::vector<uint256> const&
|
||||
value() const
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
|
||||
void
|
||||
push_back (uint256 const& v)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user