Bitcoin Core  0.15.99
P2P Digital Currency
Public Types | Public Member Functions | Protected Types | Protected Attributes | Friends | List of all members
CDataStream Class Reference

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

#include <streams.h>

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

 CDataStream (int nTypeIn, int nVersionIn)
 
 CDataStream (const_iterator pbegin, const_iterator pend, int nTypeIn, int nVersionIn)
 
 CDataStream (const char *pbegin, const char *pend, int nTypeIn, int nVersionIn)
 
 CDataStream (const vector_type &vchIn, int nTypeIn, int nVersionIn)
 
 CDataStream (const std::vector< char > &vchIn, int nTypeIn, int nVersionIn)
 
 CDataStream (const std::vector< unsigned char > &vchIn, int nTypeIn, int nVersionIn)
 
template<typename... Args>
 CDataStream (int nTypeIn, int nVersionIn, Args &&... args)
 
void Init (int nTypeIn, int nVersionIn)
 
CDataStreamoperator+= (const CDataStream &b)
 
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=0)
 
void reserve (size_type n)
 
const_reference operator[] (size_type pos) const
 
reference operator[] (size_type pos)
 
void clear ()
 
iterator insert (iterator it, const char x=char())
 
void insert (iterator it, size_type n, const char x)
 
value_typedata ()
 
const value_typedata () const
 
void insert (iterator it, std::vector< char >::const_iterator first, std::vector< char >::const_iterator last)
 
void insert (iterator it, const char *first, const char *last)
 
iterator erase (iterator it)
 
iterator erase (iterator first, iterator last)
 
void Compact ()
 
bool Rewind (size_type n)
 
bool eof () const
 
CDataStreamrdbuf ()
 
int in_avail () const
 
void SetType (int n)
 
int GetType () const
 
void SetVersion (int n)
 
int GetVersion () const
 
void read (char *pch, size_t nSize)
 
void ignore (int nSize)
 
void write (const char *pch, size_t nSize)
 
template<typename Stream >
void Serialize (Stream &s) const
 
template<typename T >
CDataStreamoperator<< (const T &obj)
 
template<typename T >
CDataStreamoperator>> (T &&obj)
 
void GetAndClear (CSerializeData &d)
 
void Xor (const std::vector< unsigned char > &key)
 XOR the contents of this stream with a certain key. More...
 

Protected Types

typedef CSerializeData vector_type
 

Protected Attributes

vector_type vch
 
unsigned int nReadPos
 
int nType
 
int nVersion
 

Friends

CDataStream operator+ (const CDataStream &a, const CDataStream &b)
 

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

Member Typedef Documentation

◆ allocator_type

typedef vector_type::allocator_type CDataStream::allocator_type

Definition at line 232 of file streams.h.

◆ const_iterator

typedef vector_type::const_iterator CDataStream::const_iterator

Definition at line 239 of file streams.h.

◆ const_reference

typedef vector_type::const_reference CDataStream::const_reference

Definition at line 236 of file streams.h.

◆ difference_type

typedef vector_type::difference_type CDataStream::difference_type

Definition at line 234 of file streams.h.

◆ iterator

typedef vector_type::iterator CDataStream::iterator

Definition at line 238 of file streams.h.

◆ reference

typedef vector_type::reference CDataStream::reference

Definition at line 235 of file streams.h.

◆ reverse_iterator

typedef vector_type::reverse_iterator CDataStream::reverse_iterator

Definition at line 240 of file streams.h.

◆ size_type

typedef vector_type::size_type CDataStream::size_type

Definition at line 233 of file streams.h.

◆ value_type

typedef vector_type::value_type CDataStream::value_type

Definition at line 237 of file streams.h.

◆ vector_type

Definition at line 224 of file streams.h.

Constructor & Destructor Documentation

◆ CDataStream() [1/7]

CDataStream::CDataStream ( int  nTypeIn,
int  nVersionIn 
)
inlineexplicit

Definition at line 242 of file streams.h.

◆ CDataStream() [2/7]

CDataStream::CDataStream ( const_iterator  pbegin,
const_iterator  pend,
int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 247 of file streams.h.

◆ CDataStream() [3/7]

CDataStream::CDataStream ( const char *  pbegin,
const char *  pend,
int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 252 of file streams.h.

◆ CDataStream() [4/7]

CDataStream::CDataStream ( const vector_type vchIn,
int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 257 of file streams.h.

◆ CDataStream() [5/7]

CDataStream::CDataStream ( const std::vector< char > &  vchIn,
int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 262 of file streams.h.

◆ CDataStream() [6/7]

CDataStream::CDataStream ( const std::vector< unsigned char > &  vchIn,
int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 267 of file streams.h.

◆ CDataStream() [7/7]

template<typename... Args>
CDataStream::CDataStream ( int  nTypeIn,
int  nVersionIn,
Args &&...  args 
)
inline

Definition at line 273 of file streams.h.

Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

const_iterator CDataStream::begin ( ) const
inline

Definition at line 308 of file streams.h.

Here is the caller graph for this function:

◆ begin() [2/2]

iterator CDataStream::begin ( )
inline

Definition at line 309 of file streams.h.

◆ clear()

void CDataStream::clear ( )
inline

Definition at line 318 of file streams.h.

Here is the caller graph for this function:

◆ Compact()

void CDataStream::Compact ( )
inline

Definition at line 389 of file streams.h.

◆ data() [1/2]

value_type* CDataStream::data ( )
inline

Definition at line 321 of file streams.h.

Here is the caller graph for this function:

◆ data() [2/2]

const value_type* CDataStream::data ( ) const
inline

Definition at line 322 of file streams.h.

◆ empty()

bool CDataStream::empty ( ) const
inline

Definition at line 313 of file streams.h.

◆ end() [1/2]

const_iterator CDataStream::end ( ) const
inline

Definition at line 310 of file streams.h.

Here is the caller graph for this function:

◆ end() [2/2]

iterator CDataStream::end ( )
inline

Definition at line 311 of file streams.h.

◆ eof()

bool CDataStream::eof ( ) const
inline

Definition at line 408 of file streams.h.

Here is the call graph for this function:

◆ erase() [1/2]

iterator CDataStream::erase ( iterator  it)
inline

Definition at line 352 of file streams.h.

◆ erase() [2/2]

iterator CDataStream::erase ( iterator  first,
iterator  last 
)
inline

Definition at line 369 of file streams.h.

◆ GetAndClear()

void CDataStream::GetAndClear ( CSerializeData d)
inline

Definition at line 484 of file streams.h.

◆ GetType()

int CDataStream::GetType ( ) const
inline

Definition at line 413 of file streams.h.

◆ GetVersion()

int CDataStream::GetVersion ( ) const
inline

Definition at line 415 of file streams.h.

◆ ignore()

void CDataStream::ignore ( int  nSize)
inline

Definition at line 436 of file streams.h.

◆ in_avail()

int CDataStream::in_avail ( ) const
inline

Definition at line 410 of file streams.h.

Here is the call graph for this function:

◆ Init()

void CDataStream::Init ( int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 279 of file streams.h.

◆ insert() [1/4]

iterator CDataStream::insert ( iterator  it,
const char  x = char() 
)
inline

Definition at line 319 of file streams.h.

Here is the caller graph for this function:

◆ insert() [2/4]

void CDataStream::insert ( iterator  it,
size_type  n,
const char  x 
)
inline

Definition at line 320 of file streams.h.

◆ insert() [3/4]

void CDataStream::insert ( iterator  it,
std::vector< char >::const_iterator  first,
std::vector< char >::const_iterator  last 
)
inline

Definition at line 324 of file streams.h.

Here is the call graph for this function:

◆ insert() [4/4]

void CDataStream::insert ( iterator  it,
const char *  first,
const char *  last 
)
inline

Definition at line 338 of file streams.h.

Here is the call graph for this function:

◆ operator+=()

CDataStream& CDataStream::operator+= ( const CDataStream b)
inline

Definition at line 286 of file streams.h.

Here is the call graph for this function:

◆ operator<<()

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

Definition at line 469 of file streams.h.

Here is the call graph for this function:

◆ operator>>()

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

Definition at line 477 of file streams.h.

Here is the call graph for this function:

◆ operator[]() [1/2]

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

Definition at line 316 of file streams.h.

◆ operator[]() [2/2]

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

Definition at line 317 of file streams.h.

◆ rdbuf()

CDataStream* CDataStream::rdbuf ( )
inline

Definition at line 409 of file streams.h.

◆ read()

void CDataStream::read ( char *  pch,
size_t  nSize 
)
inline

Definition at line 417 of file streams.h.

Here is the call graph for this function:

◆ reserve()

void CDataStream::reserve ( size_type  n)
inline

Definition at line 315 of file streams.h.

Here is the caller graph for this function:

◆ resize()

void CDataStream::resize ( size_type  n,
value_type  c = 0 
)
inline

Definition at line 314 of file streams.h.

Here is the caller graph for this function:

◆ Rewind()

bool CDataStream::Rewind ( size_type  n)
inline

Definition at line 395 of file streams.h.

◆ Serialize()

template<typename Stream >
void CDataStream::Serialize ( Stream &  s) const
inline

Definition at line 461 of file streams.h.

◆ SetType()

void CDataStream::SetType ( int  n)
inline

Definition at line 412 of file streams.h.

Here is the caller graph for this function:

◆ SetVersion()

void CDataStream::SetVersion ( int  n)
inline

Definition at line 414 of file streams.h.

Here is the caller graph for this function:

◆ size()

size_type CDataStream::size ( ) const
inline

Definition at line 312 of file streams.h.

Here is the caller graph for this function:

◆ str()

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

Definition at line 299 of file streams.h.

◆ write()

void CDataStream::write ( const char *  pch,
size_t  nSize 
)
inline

Definition at line 454 of file streams.h.

Here is the caller graph for this function:

◆ Xor()

void CDataStream::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 494 of file streams.h.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator+

CDataStream operator+ ( const CDataStream a,
const CDataStream b 
)
friend

Definition at line 292 of file streams.h.

Member Data Documentation

◆ nReadPos

unsigned int CDataStream::nReadPos
protected

Definition at line 226 of file streams.h.

◆ nType

int CDataStream::nType
protected

Definition at line 228 of file streams.h.

◆ nVersion

int CDataStream::nVersion
protected

Definition at line 229 of file streams.h.

◆ vch

vector_type CDataStream::vch
protected

Definition at line 225 of file streams.h.


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