fastcgi++
A C++ FastCGI/Web API
Public Member Functions | Private Attributes | List of all members
Fastcgipp::Block Class Reference

Data structure to hold a block of raw data. More...

#include <fastcgi++/block.hpp>

Public Member Functions

 Block ()
 Initialize an empty block. More...
 
 Block (const size_t size_)
 Initialize a block with equal size and reserve. More...
 
 Block (const char *const data, const size_t size_)
 Initialize a block with equal size and reserve from source data. More...
 
void assign (const char *const data, const size_t size_)
 Assign a sequence a data to the block. More...
 
 Block (Block &&x)
 Steal the data from another block. More...
 
Blockoperator= (Block &&x)
 Steal the data from another block. More...
 
size_t reserve () const
 See the reserve size. More...
 
void reserve (size_t x)
 Set the reserve size. More...
 
size_t size () const
 See the relevant data size. More...
 
void size (size_t x)
 Set the relevant data size. More...
 
char * begin ()
 Pointer to the first element. More...
 
const char * begin () const
 Constant pointer to the first element. More...
 
char * end ()
 Pointer to 1+ the last element. More...
 
const char * end () const
 Constant pointer to 1+ the last element. More...
 
void clear ()
 Deallocate memory and set size and reserve to zero. More...
 
 Block (const Block &)=delete
 
Blockoperator= (const Block &)=delete
 

Private Attributes

size_t m_reserve
 Total bytes allocated. More...
 
size_t m_size
 Size of relevant part of data allocation. More...
 
std::unique_ptr< char[]> m_data
 Point to allocated data. More...
 

Detailed Description

Data structure to hold a block of raw data.

This is basically a stripped down std::vector. It contains a contiguous block of memory with two sizes associated with it. The reserve indicates how much data is actually allocated while the size tells us how much of the data is relevant. The motivation for this as opposed to a vector is that this lacks element initialization.

Definition at line 44 of file block.hpp.

Constructor & Destructor Documentation

Fastcgipp::Block::Block ( )

Initialize an empty block.

Definition at line 50 of file block.cpp.

Referenced by end().

Fastcgipp::Block::Block ( const size_t  size_)

Initialize a block with equal size and reserve.

Definition at line 55 of file block.cpp.

Fastcgipp::Block::Block ( const char *const  data,
const size_t  size_ 
)

Initialize a block with equal size and reserve from source data.

Definition at line 61 of file block.cpp.

References m_data.

Fastcgipp::Block::Block ( Block &&  x)

Steal the data from another block.

Definition at line 69 of file block.cpp.

Fastcgipp::Block::Block ( const Block )
delete

Member Function Documentation

void Fastcgipp::Block::assign ( const char *const  data,
const size_t  size_ 
)

Assign a sequence a data to the block.

If the reserve if smaller the requested size then reallocation occurs. Otherwise the allocation is unchanged.

Definition at line 105 of file block.cpp.

References m_data, m_reserve, and m_size.

char* Fastcgipp::Block::begin ( )
inline
const char* Fastcgipp::Block::begin ( ) const
inline

Constant pointer to the first element.

Definition at line 109 of file block.hpp.

void Fastcgipp::Block::clear ( )

Deallocate memory and set size and reserve to zero.

Definition at line 98 of file block.cpp.

References m_data, m_reserve, and m_size.

Referenced by end().

char* Fastcgipp::Block::end ( )
inline

Pointer to 1+ the last element.

Definition at line 115 of file block.hpp.

References m_size.

Referenced by Fastcgipp::FcgiStreambuf< charT, traits >::emptyBuffer(), Fastcgipp::Manager_base::localHandler(), and Fastcgipp::Transceiver::transmit().

const char* Fastcgipp::Block::end ( ) const
inline

Constant pointer to 1+ the last element.

Definition at line 121 of file block.hpp.

References Block(), clear(), m_size, and operator=().

Fastcgipp::Block & Fastcgipp::Block::operator= ( Block &&  x)

Steal the data from another block.

Definition at line 78 of file block.cpp.

References m_data, m_reserve, and m_size.

Referenced by end().

Block& Fastcgipp::Block::operator= ( const Block )
delete
size_t Fastcgipp::Block::reserve ( ) const
inline
void Fastcgipp::Block::reserve ( size_t  x)

Set the reserve size.

Unlike std::vector this always obeys your command even if you are decreasing the reserve size. All data is copied over when a reserve is changed.

Definition at line 32 of file block.cpp.

References m_data, m_reserve, and m_size.

size_t Fastcgipp::Block::size ( ) const
inline
void Fastcgipp::Block::size ( size_t  x)

Set the relevant data size.

Definition at line 88 of file block.cpp.

References m_reserve, m_size, and reserve().

Member Data Documentation

std::unique_ptr<char[]> Fastcgipp::Block::m_data
private

Point to allocated data.

Definition at line 54 of file block.hpp.

Referenced by assign(), Block(), clear(), operator=(), and reserve().

size_t Fastcgipp::Block::m_reserve
private

Total bytes allocated.

Definition at line 48 of file block.hpp.

Referenced by assign(), clear(), operator=(), reserve(), and size().

size_t Fastcgipp::Block::m_size
private

Size of relevant part of data allocation.

Definition at line 51 of file block.hpp.

Referenced by assign(), clear(), end(), operator=(), reserve(), and size().


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