Bitcoin Core  27.99.0
P2P Digital Currency
Public Types | Public Member Functions | Protected Types | Protected Attributes | List of all members
DataStream Class Reference

Double ended buffer combining vector and stream-like interfaces. More...

#include <streams.h>

Inheritance diagram for DataStream:
[legend]

Public Types

typedef vector_type::allocator_type allocator_type
 
typedef vector_type::size_type size_type
 
typedef vector_type::difference_type difference_type
 
typedef vector_type::reference reference
 
typedef vector_type::const_reference const_reference
 
typedef vector_type::value_type value_type
 
typedef vector_type::iterator iterator
 
typedef vector_type::const_iterator const_iterator
 
typedef vector_type::reverse_iterator reverse_iterator
 

Public Member Functions

 DataStream ()
 
 DataStream (Span< const uint8_t > sp)
 
 DataStream (Span< const value_type > sp)
 
std::string str () const
 
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
size_type size () const
 
bool empty () const
 
void resize (size_type n, value_type c=value_type{})
 
void reserve (size_type n)
 
const_reference operator[] (size_type pos) const
 
reference operator[] (size_type pos)
 
void clear ()
 
value_typedata ()
 
const value_typedata () const
 
void Compact ()
 
bool Rewind (std::optional< size_type > n=std::nullopt)
 
bool eof () const
 
int in_avail () const
 
void read (Span< value_type > dst)
 
void ignore (size_t num_ignore)
 
void write (Span< const value_type > src)
 
template<typename T >
DataStreamoperator<< (const T &obj)
 
template<typename T >
DataStreamoperator>> (T &&obj)
 
void Xor (const std::vector< unsigned char > &key)
 XOR the contents of this stream with a certain key. More...
 

Protected Types

using vector_type = SerializeData
 

Protected Attributes

vector_type vch
 
vector_type::size_type m_read_pos {0}
 

Detailed Description

Double ended buffer combining vector and stream-like interfaces.

and << read and write unformatted data using the above serialization templates.

Fills with data in linear time; some stringstream implementations take N^2 time.

Definition at line 146 of file streams.h.

Member Typedef Documentation

◆ allocator_type

typedef vector_type::allocator_type DataStream::allocator_type

Definition at line 154 of file streams.h.

◆ const_iterator

typedef vector_type::const_iterator DataStream::const_iterator

Definition at line 161 of file streams.h.

◆ const_reference

typedef vector_type::const_reference DataStream::const_reference

Definition at line 158 of file streams.h.

◆ difference_type

typedef vector_type::difference_type DataStream::difference_type

Definition at line 156 of file streams.h.

◆ iterator

typedef vector_type::iterator DataStream::iterator

Definition at line 160 of file streams.h.

◆ reference

typedef vector_type::reference DataStream::reference

Definition at line 157 of file streams.h.

◆ reverse_iterator

typedef vector_type::reverse_iterator DataStream::reverse_iterator

Definition at line 162 of file streams.h.

◆ size_type

typedef vector_type::size_type DataStream::size_type

Definition at line 155 of file streams.h.

◆ value_type

typedef vector_type::value_type DataStream::value_type

Definition at line 159 of file streams.h.

◆ vector_type

Definition at line 149 of file streams.h.

Constructor & Destructor Documentation

◆ DataStream() [1/3]

DataStream::DataStream ( )
inlineexplicit

Definition at line 164 of file streams.h.

◆ DataStream() [2/3]

DataStream::DataStream ( Span< const uint8_t >  sp)
inlineexplicit

Definition at line 165 of file streams.h.

◆ DataStream() [3/3]

DataStream::DataStream ( Span< const value_type sp)
inlineexplicit

Definition at line 166 of file streams.h.

Member Function Documentation

◆ begin() [1/2]

iterator DataStream::begin ( )
inline

Definition at line 178 of file streams.h.

◆ begin() [2/2]

const_iterator DataStream::begin ( ) const
inline

Definition at line 177 of file streams.h.

Here is the caller graph for this function:

◆ clear()

void DataStream::clear ( )
inline

Definition at line 187 of file streams.h.

Here is the caller graph for this function:

◆ Compact()

void DataStream::Compact ( )
inline

Definition at line 191 of file streams.h.

◆ data() [1/2]

value_type* DataStream::data ( )
inline

Definition at line 188 of file streams.h.

Here is the caller graph for this function:

◆ data() [2/2]

const value_type* DataStream::data ( ) const
inline

Definition at line 189 of file streams.h.

◆ empty()

bool DataStream::empty ( ) const
inline

Definition at line 182 of file streams.h.

Here is the caller graph for this function:

◆ end() [1/2]

iterator DataStream::end ( )
inline

Definition at line 180 of file streams.h.

◆ end() [2/2]

const_iterator DataStream::end ( ) const
inline

Definition at line 179 of file streams.h.

Here is the caller graph for this function:

◆ eof()

bool DataStream::eof ( ) const
inline

Definition at line 215 of file streams.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ignore()

void DataStream::ignore ( size_t  num_ignore)
inline

Definition at line 236 of file streams.h.

Here is the call graph for this function:

◆ in_avail()

int DataStream::in_avail ( ) const
inline

Definition at line 216 of file streams.h.

Here is the call graph for this function:

◆ operator<<()

template<typename T >
DataStream& DataStream::operator<< ( const T obj)
inline

Definition at line 258 of file streams.h.

Here is the call graph for this function:

◆ operator>>()

template<typename T >
DataStream& DataStream::operator>> ( T &&  obj)
inline

Definition at line 265 of file streams.h.

Here is the call graph for this function:

◆ operator[]() [1/2]

reference DataStream::operator[] ( size_type  pos)
inline

Definition at line 186 of file streams.h.

◆ operator[]() [2/2]

const_reference DataStream::operator[] ( size_type  pos) const
inline

Definition at line 185 of file streams.h.

◆ read()

void DataStream::read ( Span< value_type dst)
inline

Definition at line 218 of file streams.h.

Here is the call graph for this function:

◆ reserve()

void DataStream::reserve ( size_type  n)
inline

Definition at line 184 of file streams.h.

Here is the caller graph for this function:

◆ resize()

void DataStream::resize ( size_type  n,
value_type  c = value_type{} 
)
inline

Definition at line 183 of file streams.h.

◆ Rewind()

bool DataStream::Rewind ( std::optional< size_type n = std::nullopt)
inline

Definition at line 197 of file streams.h.

Here is the caller graph for this function:

◆ size()

size_type DataStream::size ( ) const
inline

Definition at line 181 of file streams.h.

Here is the caller graph for this function:

◆ str()

std::string DataStream::str ( ) const
inline

Definition at line 168 of file streams.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write()

void DataStream::write ( Span< const value_type src)
inline

Definition at line 251 of file streams.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Xor()

void DataStream::Xor ( const std::vector< unsigned char > &  key)
inline

XOR the contents of this stream with a certain key.

Parameters
[in]keyThe key used to XOR the data in this stream.

Definition at line 276 of file streams.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_read_pos

vector_type::size_type DataStream::m_read_pos {0}
protected

Definition at line 151 of file streams.h.

◆ vch

vector_type DataStream::vch
protected

Definition at line 150 of file streams.h.


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