Public Types | Public Member Functions | List of all members
ByteStream Struct Reference

A stream of bytes in a resizeable buffer. More...

#include <ByteStream.h>

Public Types

typedef uint8_titerator
 
typedef uint8_t const * const_iterator
 

Public Member Functions

void Init ()
 
 ByteStream ()
 
 ByteStream (uint32_t size)
 
 ByteStream (uint8_t const *data, uint32_t size)
 
 ByteStream (ByteStream const &other)
 
 ~ByteStream ()
 
 ByteStream (ByteStream &&rhs)
 
ByteStreamoperator= (ByteStream const &other)
 
ByteStreamoperator= (ByteStream &&rhs)
 
uint32_t GetAllocSize () const
 Get the size, in bytes, of the memory allocated for this ByteStream. More...
 
uint32_t GetSize () const
 Get the size in bytes of the current data in this ByteStream. More...
 
uint8_t const * GetData () const
 Get a const pointer to the ByteStream. More...
 
uint8_tGetDataP () const
 Get a writable pointer to the ByteStream. More...
 
bool HasData () const
 return false if this ByteStream is empty. More...
 
void Clear ()
 Return this object to an empty/uninitialized state. More...
 
uint8_tExtractData ()
 
void Reserve (uint32_t size)
 Reserve memory for this ByteStream. More...
 
void Resize (uint32_t newSize)
 Resize the stream. More...
 
void SaveData (uint8_t const *data, uint32_t size)
 Save a stream of bytes into this ByteStream. More...
 
void Append (uint8_t const *data, uint32_t size)
 Append a stream of byes to the current end of this ByteStream. More...
 
bool empty () const
 
size_t size () const
 
size_t capacity () const
 
void reserve (size_t size)
 
void resize (size_t newSize)
 
void clear ()
 
uint8_t const * data () const
 
uint8_tdata ()
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
uint8_t const & operator[] (size_t i) const
 
uint8_toperator[] (size_t i)
 

Detailed Description

A stream of bytes in a resizeable buffer.

Released on destruction, never gets smaller. This class is more efficient than bvector<byte> since it does not initialize the memory to zeros.

Member Typedef Documentation

typedef uint8_t const* const_iterator
typedef uint8_t* iterator

Constructor & Destructor Documentation

ByteStream ( uint32_t  size)
explicit
ByteStream ( uint8_t const *  data,
uint32_t  size 
)
ByteStream ( ByteStream const &  other)
~ByteStream ( )
ByteStream ( ByteStream &&  rhs)

Member Function Documentation

void Append ( uint8_t const *  data,
uint32_t  size 
)

Append a stream of byes to the current end of this ByteStream.

Parameters
[in]datathe data to save
[in]sizenumber of bytes in data

References size().

iterator begin ( )
const_iterator begin ( ) const
size_t capacity ( ) const
void Clear ( )

Return this object to an empty/uninitialized state.

void clear ( )
uint8_t const* data ( ) const
uint8_t* data ( )
bool empty ( ) const
iterator end ( )

References size().

const_iterator end ( ) const

References size().

uint8_t* ExtractData ( )
uint32_t GetAllocSize ( ) const

Get the size, in bytes, of the memory allocated for this ByteStream.

Note
The allocated size may be larger than the currently used size returned by GetSize.
uint8_t const* GetData ( ) const

Get a const pointer to the ByteStream.

uint8_t* GetDataP ( ) const

Get a writable pointer to the ByteStream.

uint32_t GetSize ( ) const

Get the size in bytes of the current data in this ByteStream.

bool HasData ( ) const

return false if this ByteStream is empty.

void Init ( )
ByteStream& operator= ( ByteStream const &  other)
ByteStream& operator= ( ByteStream &&  rhs)
uint8_t const& operator[] ( size_t  i) const
uint8_t& operator[] ( size_t  i)
void Reserve ( uint32_t  size)

Reserve memory for this ByteStream.

The stream capacity will change but not its size.

Parameters
[in]sizethe number of bytes to reserve

References size().

void reserve ( size_t  size)
void Resize ( uint32_t  newSize)

Resize the stream.

If more memory is required, the new portion won't be initialized.

Parameters
[in]newSizenumber of bytes
void resize ( size_t  newSize)
void SaveData ( uint8_t const *  data,
uint32_t  size 
)

Save a stream of bytes into this ByteStream.

Parameters
[in]datathe data to save
[in]sizenumber of bytes in data

References Bentley::Append.

size_t size ( ) const

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

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.