TARAXA
dev::RLPStream Class Reference

Class for writing to an RLP bytestream. More...

#include <RLP.h>

Public Member Functions

 RLPStream ()
 Initializes empty RLPStream. More...
 
 RLPStream (size_t _listItems)
 Initializes the RLPStream as a list of _listItems items. More...
 
 ~RLPStream ()
 
void reserve (size_t cap_out, size_t cap_lists)
 
template<typename N >
std::enable_if_t< is_integer< N >Signedness::signed_only), RLPStream & > append (N const &_i)
 
template<typename N >
std::enable_if_t< is_integer< N >Signedness::unsigned_only), RLPStream & > append (N const &_i)
 
RLPStreamappend (bool _i)
 
RLPStreamappend (bytesConstRef _s, bool _compact=false)
 
RLPStreamappend (bytes const &_s)
 
RLPStreamappend (std::string const &_s)
 
RLPStreamappend (char const *_s)
 
template<unsigned N>
RLPStreamappend (FixedHash< N > _s, bool _compact=false, bool _allOrNothing=false)
 
RLPStreamappend (RLP const &_rlp, size_t _itemCount=1)
 
template<class _T >
RLPStreamappend (std::vector< _T > const &_s)
 Appends a sequence of data to the stream as a list. More...
 
template<class _T >
RLPStreamappendVector (std::vector< _T > const &_s)
 
template<class _T , size_t S>
RLPStreamappend (std::array< _T, S > const &_s)
 
template<class _T >
RLPStreamappend (std::set< _T > const &_s)
 
template<class _T >
RLPStreamappend (std::unordered_set< _T > const &_s)
 
template<class T , class U >
RLPStreamappend (std::pair< T, U > const &_s)
 
RLPStreamappendList (size_t _items)
 Appends a list. More...
 
RLPStreamappendList (bytesConstRef _rlp)
 
RLPStreamappendList (bytes const &_rlp)
 
RLPStreamappendList (RLPStream const &_s)
 
RLPStreamappendRaw (bytesConstRef _rlp, size_t _itemCount=1)
 Appends raw (pre-serialised) RLP data. Use with caution. More...
 
RLPStreamappendRaw (bytes const &_rlp, size_t _itemCount=1)
 
template<class T >
RLPStreamoperator<< (T _data)
 Shift operators for appending data items. More...
 
void clear ()
 Clear the output stream so far. More...
 
bytes const & out () const
 Read the byte stream. More...
 
bytes && invalidate ()
 Invalidate the object and steal the output byte stream. More...
 
void swapOut (bytes &_dest)
 Swap the contents of the output stream out for some other byte array. More...
 

Private Member Functions

template<typename N >
RLPStreamappend_int_ (N const &_i)
 
RLPStreamappend_int_ (bool _i)
 
void noteAppended (size_t _itemCount=1)
 
void pushCount (size_t _count, ::byte _offset)
 
template<class _T >
void pushInt (_T _i, size_t _br)
 Push an integer as a raw big-endian byte-stream. More...
 

Private Attributes

bytes m_out
 Our output byte stream. More...
 
std::vector< std::pair< size_t, size_t > > m_listStack
 

Detailed Description

Class for writing to an RLP bytestream.

Constructor & Destructor Documentation

◆ RLPStream() [1/2]

dev::RLPStream::RLPStream ( )
inline

Initializes empty RLPStream.

◆ RLPStream() [2/2]

dev::RLPStream::RLPStream ( size_t  _listItems)
inlineexplicit

Initializes the RLPStream as a list of _listItems items.

◆ ~RLPStream()

dev::RLPStream::~RLPStream ( )
inline

Member Function Documentation

◆ append() [1/14]

RLPStream& dev::RLPStream::append ( bool  _i)
inline

◆ append() [2/14]

RLPStream& dev::RLPStream::append ( bytes const &  _s)
inline

◆ append() [3/14]

RLPStream & RLPStream::append ( bytesConstRef  _s,
bool  _compact = false 
)

◆ append() [4/14]

RLPStream& dev::RLPStream::append ( char const *  _s)
inline

◆ append() [5/14]

template<unsigned N>
RLPStream& dev::RLPStream::append ( FixedHash< N >  _s,
bool  _compact = false,
bool  _allOrNothing = false 
)
inline

◆ append() [6/14]

template<typename N >
std::enable_if_t<is_integer<N>Signedness::signed_only), RLPStream&> dev::RLPStream::append ( N const &  _i)
inline

◆ append() [7/14]

template<typename N >
std::enable_if_t<is_integer<N>Signedness::unsigned_only), RLPStream&> dev::RLPStream::append ( N const &  _i)
inline

◆ append() [8/14]

RLPStream& dev::RLPStream::append ( RLP const &  _rlp,
size_t  _itemCount = 1 
)
inline

Appends an arbitrary RLP fragment - this must be a single item unless _itemCount is given.

◆ append() [9/14]

template<class _T , size_t S>
RLPStream& dev::RLPStream::append ( std::array< _T, S > const &  _s)
inline

◆ append() [10/14]

template<class T , class U >
RLPStream& dev::RLPStream::append ( std::pair< T, U > const &  _s)
inline

◆ append() [11/14]

template<class _T >
RLPStream& dev::RLPStream::append ( std::set< _T > const &  _s)
inline

◆ append() [12/14]

RLPStream& dev::RLPStream::append ( std::string const &  _s)
inline

◆ append() [13/14]

template<class _T >
RLPStream& dev::RLPStream::append ( std::unordered_set< _T > const &  _s)
inline

◆ append() [14/14]

template<class _T >
RLPStream& dev::RLPStream::append ( std::vector< _T > const &  _s)
inline

Appends a sequence of data to the stream as a list.

◆ append_int_() [1/2]

RLPStream& dev::RLPStream::append_int_ ( bool  _i)
inlineprivate

◆ append_int_() [2/2]

template<typename N >
RLPStream& dev::RLPStream::append_int_ ( N const &  _i)
inlineprivate

◆ appendList() [1/4]

RLPStream& dev::RLPStream::appendList ( bytes const &  _rlp)
inline

◆ appendList() [2/4]

RLPStream & RLPStream::appendList ( bytesConstRef  _rlp)

◆ appendList() [3/4]

RLPStream& dev::RLPStream::appendList ( RLPStream const &  _s)
inline

◆ appendList() [4/4]

RLPStream & RLPStream::appendList ( size_t  _items)

Appends a list.

◆ appendRaw() [1/2]

RLPStream& dev::RLPStream::appendRaw ( bytes const &  _rlp,
size_t  _itemCount = 1 
)
inline

◆ appendRaw() [2/2]

RLPStream & RLPStream::appendRaw ( bytesConstRef  _rlp,
size_t  _itemCount = 1 
)

Appends raw (pre-serialised) RLP data. Use with caution.

◆ appendVector()

template<class _T >
RLPStream& dev::RLPStream::appendVector ( std::vector< _T > const &  _s)
inline

◆ clear()

void dev::RLPStream::clear ( )
inline

Clear the output stream so far.

◆ invalidate()

bytes&& dev::RLPStream::invalidate ( )
inline

Invalidate the object and steal the output byte stream.

◆ noteAppended()

void RLPStream::noteAppended ( size_t  _itemCount = 1)
private

◆ operator<<()

template<class T >
RLPStream& dev::RLPStream::operator<< ( _data)
inline

Shift operators for appending data items.

◆ out()

bytes const& dev::RLPStream::out ( ) const
inline

Read the byte stream.

◆ pushCount()

void RLPStream::pushCount ( size_t  _count,
::byte  _offset 
)
private

Push the node-type byte (using _base) along with the item count _count.

  • _count is number of characters for strings, data-bytes for ints, or items for lists.

◆ pushInt()

template<class _T >
void dev::RLPStream::pushInt ( _T  _i,
size_t  _br 
)
inlineprivate

Push an integer as a raw big-endian byte-stream.

◆ reserve()

void RLPStream::reserve ( size_t  cap_out,
size_t  cap_lists 
)

◆ swapOut()

void dev::RLPStream::swapOut ( bytes _dest)
inline

Swap the contents of the output stream out for some other byte array.

Member Data Documentation

◆ m_listStack

std::vector<std::pair<size_t, size_t> > dev::RLPStream::m_listStack
private

◆ m_out

bytes dev::RLPStream::m_out
private

Our output byte stream.


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