Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::eth::owning_bytes_ref Class Reference

#include <ExtVMFace.h>

Inheritance diagram for dev::eth::owning_bytes_ref:
dev::vector_ref< byte const >

Public Member Functions

 owning_bytes_ref ()=default
 
 owning_bytes_ref (bytes &&_bytes, size_t _begin, size_t _size)
 
 owning_bytes_ref (owning_bytes_ref const &)=delete
 
 owning_bytes_ref (owning_bytes_ref &&)=default
 
owning_bytes_refoperator= (owning_bytes_ref const &)=delete
 
owning_bytes_refoperator= (owning_bytes_ref &&)=default
 
bytes && takeBytes ()
 Moves the bytes vector out of here. The object cannot be used any more. More...
 
- Public Member Functions inherited from dev::vector_ref< byte const >
 vector_ref ()
 
 vector_ref (byte const *_data, size_t _count)
 Creates a new vector_ref to point to _count elements starting at _data. More...
 
 vector_ref (typename std::conditional< std::is_const< byte const >::value, std::string const *, std::string * >::type _data)
 Creates a new vector_ref pointing to the data part of a string (given as pointer). More...
 
 vector_ref (typename std::conditional< std::is_const< byte const >::value, std::vector< typename std::remove_const< byte const >::type > const *, std::vector< byte const > * >::type _data)
 Creates a new vector_ref pointing to the data part of a vector (given as pointer). More...
 
 vector_ref (typename std::conditional< std::is_const< byte const >::value, std::string const &, std::string & >::type _data)
 Creates a new vector_ref pointing to the data part of a string (given as reference). More...
 
 operator bool () const
 
bool contentsEqual (std::vector< mutable_value_type > const &_c) const
 
std::vector< mutable_value_typetoVector () const
 
std::vector< unsigned char > toBytes () const
 
std::string toString () const
 
 operator vector_ref< _T2 > () const
 
 operator vector_ref< byte const const > () const
 
byte const * data () const
 
size_t count () const
 
size_t size () const
 
bool empty () const
 
vector_ref< byte const > next () const
 
vector_ref< byte const > cropped (size_t _begin, size_t _count) const
 
vector_ref< byte const > cropped (size_t _begin) const
 
void retarget (byte const *_d, size_t _s)
 
void retarget (std::vector< byte const > const &_t)
 
bool overlapsWith (vector_ref< T > _t) const
 
void copyTo (vector_ref< typename std::remove_const< byte const >::type > _t) const
 Copies the contents of this vector_ref to the contents of _t, up to the max size of _t. More...
 
void populate (vector_ref< typename std::remove_const< byte const >::type > _t) const
 Copies the contents of this vector_ref to the contents of _t, and zeros further trailing elements in _t. More...
 
void cleanse ()
 
byte const * begin ()
 
byte const const * begin () const
 
byte const * end ()
 
byte const const * end () const
 
byte const & operator[] (size_t _i)
 
byte const const & operator[] (size_t _i) const
 
bool operator== (vector_ref< byte const > const &_cmp) const
 
bool operator!= (vector_ref< byte const > const &_cmp) const
 
void reset ()
 

Additional Inherited Members

- Public Types inherited from dev::vector_ref< byte const >
using value_type = byte const
 
using element_type = byte const
 
using mutable_value_type = typename std::conditional< std::is_const< byte const >::value, typename std::remove_const< byte const >::type, byte const >::type
 

Detailed Description

Reference to a slice of buffer that also owns the buffer.

This is extension to the concept C++ STL library names as array_view (also known as gsl::span, array_ref, here vector_ref) – reference to continuous non-modifiable memory. The extension makes the object also owning the referenced buffer.

This type is used by VMs to return output coming from RETURN instruction. To avoid memory copy, a VM returns its whole memory + the information what part of this memory is actually the output. This simplifies the VM design, because there are multiple options how the output will be used (can be ignored, part of it copied, or all of it copied). The decision what to do with it was moved out of VM interface making VMs "stateless".

The type is movable, but not copyable. Default constructor available.

Definition at line 57 of file ExtVMFace.h.

Constructor & Destructor Documentation

◆ owning_bytes_ref() [1/4]

dev::eth::owning_bytes_ref::owning_bytes_ref ( )
default

◆ owning_bytes_ref() [2/4]

dev::eth::owning_bytes_ref::owning_bytes_ref ( bytes &&  _bytes,
size_t  _begin,
size_t  _size 
)
inline
Parameters
_bytesThe buffer.
_beginThe index of the first referenced byte.
_sizeThe number of referenced bytes.

Definition at line 65 of file ExtVMFace.h.

◆ owning_bytes_ref() [3/4]

dev::eth::owning_bytes_ref::owning_bytes_ref ( owning_bytes_ref const &  )
delete

◆ owning_bytes_ref() [4/4]

dev::eth::owning_bytes_ref::owning_bytes_ref ( owning_bytes_ref &&  )
default

Member Function Documentation

◆ operator=() [1/2]

owning_bytes_ref& dev::eth::owning_bytes_ref::operator= ( owning_bytes_ref &&  )
default

◆ operator=() [2/2]

owning_bytes_ref& dev::eth::owning_bytes_ref::operator= ( owning_bytes_ref const &  )
delete

◆ takeBytes()

bytes&& dev::eth::owning_bytes_ref::takeBytes ( )
inline

Moves the bytes vector out of here. The object cannot be used any more.

Definition at line 79 of file ExtVMFace.h.


The documentation for this class was generated from the following file: