Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
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 ()=default
 DataStream (std::span< const uint8_t > sp)
 DataStream (std::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)
int in_avail () const
void read (std::span< value_type > dst)
void ignore (size_t num_ignore)
void write (std::span< const value_type > src)
template<typename T>
DataStreamoperator<< (const T &obj)
template<typename T>
DataStreamoperator>> (T &&obj)
size_t GetMemoryUsage () const noexcept
 Compute total memory usage of this object (own memory + any dynamic memory).

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 132 of file streams.h.

Member Typedef Documentation

◆ allocator_type

typedef vector_type::allocator_type DataStream::allocator_type

Definition at line 140 of file streams.h.

◆ const_iterator

typedef vector_type::const_iterator DataStream::const_iterator

Definition at line 147 of file streams.h.

◆ const_reference

typedef vector_type::const_reference DataStream::const_reference

Definition at line 144 of file streams.h.

◆ difference_type

typedef vector_type::difference_type DataStream::difference_type

Definition at line 142 of file streams.h.

◆ iterator

typedef vector_type::iterator DataStream::iterator

Definition at line 146 of file streams.h.

◆ reference

typedef vector_type::reference DataStream::reference

Definition at line 143 of file streams.h.

◆ reverse_iterator

typedef vector_type::reverse_iterator DataStream::reverse_iterator

Definition at line 148 of file streams.h.

◆ size_type

typedef vector_type::size_type DataStream::size_type

Definition at line 141 of file streams.h.

◆ value_type

typedef vector_type::value_type DataStream::value_type

Definition at line 145 of file streams.h.

◆ vector_type

Definition at line 135 of file streams.h.

Constructor & Destructor Documentation

◆ DataStream() [1/3]

DataStream::DataStream ( )
explicitdefault
Here is the caller graph for this function:

◆ DataStream() [2/3]

DataStream::DataStream ( std::span< const uint8_t > sp)
inlineexplicit

Definition at line 151 of file streams.h.

Here is the call graph for this function:

◆ DataStream() [3/3]

DataStream::DataStream ( std::span< const value_type > sp)
inlineexplicit

Definition at line 152 of file streams.h.

Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

iterator DataStream::begin ( )
inline

Definition at line 164 of file streams.h.

◆ begin() [2/2]

const_iterator DataStream::begin ( ) const
inline

Definition at line 163 of file streams.h.

Here is the caller graph for this function:

◆ clear()

void DataStream::clear ( )
inline

Definition at line 173 of file streams.h.

Here is the caller graph for this function:

◆ Compact()

void DataStream::Compact ( )
inline

Definition at line 177 of file streams.h.

◆ data() [1/2]

value_type * DataStream::data ( )
inline

Definition at line 174 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 175 of file streams.h.

◆ empty()

bool DataStream::empty ( ) const
inline

Definition at line 168 of file streams.h.

Here is the caller graph for this function:

◆ end() [1/2]

iterator DataStream::end ( )
inline

Definition at line 166 of file streams.h.

◆ end() [2/2]

const_iterator DataStream::end ( ) const
inline

Definition at line 165 of file streams.h.

Here is the caller graph for this function:

◆ GetMemoryUsage()

size_t DataStream::GetMemoryUsage ( ) const
noexcept

Compute total memory usage of this object (own memory + any dynamic memory).

Definition at line 140 of file streams.cpp.

Here is the call graph for this function:

◆ ignore()

void DataStream::ignore ( size_t num_ignore)
inline

Definition at line 221 of file streams.h.

Here is the call graph for this function:

◆ in_avail()

int DataStream::in_avail ( ) const
inline

Definition at line 201 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 243 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 250 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 172 of file streams.h.

◆ operator[]() [2/2]

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

Definition at line 171 of file streams.h.

◆ read()

void DataStream::read ( std::span< value_type > dst)
inline

Definition at line 203 of file streams.h.

Here is the call graph for this function:

◆ reserve()

void DataStream::reserve ( size_type n)
inline

Definition at line 170 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 169 of file streams.h.

◆ Rewind()

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

Definition at line 183 of file streams.h.

Here is the caller graph for this function:

◆ size()

size_type DataStream::size ( ) const
inline

Definition at line 167 of file streams.h.

Here is the caller graph for this function:

◆ str()

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

Definition at line 154 of file streams.h.

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

◆ write()

void DataStream::write ( std::span< const value_type > src)
inline

Definition at line 236 of file streams.h.

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 137 of file streams.h.

◆ vch

vector_type DataStream::vch
protected

Definition at line 136 of file streams.h.


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