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:
Vinnie Falco
2015-07-24 21:06:16 -07:00
committed by Edward Hennis
parent 3e342e4b71
commit 2ec40cb6f1
14 changed files with 1230 additions and 249 deletions

View File

@@ -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)
{