STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::binary_reader Class Reference

Detailed Description

binary_reader represents a binary_buffer_ref with an additional cursor with which the memory can be read incrementally.

Definition at line 480 of file binary_buffer.h.

+ Inheritance diagram for stxxl::binary_reader:
+ Collaboration diagram for stxxl::binary_reader:

Public Member Functions

 binary_reader (const binary_buffer_ref &br)
 Constructor, assign memory area from binary_buffer. More...
 
 binary_reader (const void *data, size_t n)
 Constructor, assign memory area from pointer and length. More...
 
 binary_reader (const std::string &str)
 Constructor, assign memory area from string, does NOT copy. More...
 
void check_available (size_t n) const
 Throws a std::underflow_error unless n bytes are available at the cursor. More...
 
size_t curr () const
 Return the current read cursor. More...
 
bool cursor_available (size_t n) const
 Check that n bytes are available at the cursor. More...
 
bool empty () const
 Return true if the cursor is at the end of the buffer. More...
 
template<typename Type >
Type get ()
 Fetch a single item of the template type Type from the buffer, advancing the cursor. Be careful with implicit type conversions! More...
 
binary_buffer_ref get_binary_buffer_ref ()
 Fetch a binary_buffer_ref to a binary string or blob which was put via put_string(). Does NOT copy the data. More...
 
std::string get_string ()
 Fetch a string which was put via put_string(). More...
 
uint32 get_varint ()
 Fetch a varint with up to 32-bit from the buffer at the cursor. More...
 
uint64 get_varint64 ()
 Fetch a 64-bit varint from the buffer at the cursor. More...
 
binary_readerread (void *outdata, size_t datalen)
 Fetch a number of unstructured bytes from the buffer, advancing the cursor. More...
 
std::string read (size_t datalen)
 Fetch a number of unstructured bytes from the buffer as std::string, advancing the cursor. More...
 
binary_readerrewind ()
 Reset the read cursor. More...
 
binary_readerskip (size_t n)
 Advance the cursor given number of bytes without reading them. More...
 
- Public Member Functions inherited from stxxl::binary_buffer_ref
 binary_buffer_ref (const binary_buffer &bb)
 Constructor, assign memory area from binary_buffer. More...
 
 binary_buffer_ref (const void *data, size_t n)
 Constructor, assign memory area from pointer and length. More...
 
 binary_buffer_ref (const std::string &str)
 Constructor, assign memory area from string, does NOT copy. More...
 
const void * data () const
 Return a pointer to the currently kept memory area. More...
 
bool operator!= (const binary_buffer_ref &br) const
 Compare contents of two binary_buffer_refs. More...
 
bool operator== (const binary_buffer_ref &br) const
 Compare contents of two binary_buffer_refs. More...
 
size_t size () const
 Return the currently valid length in bytes. More...
 
std::string str () const
 Explicit conversion to std::string (copies memory of course). More...
 

Protected Attributes

size_t m_curr
 Current read cursor. More...
 
- Protected Attributes inherited from stxxl::binary_buffer_ref
const char * m_data
 Allocated buffer pointer. More...
 
size_t m_size
 Size of valid data. More...
 

Constructor & Destructor Documentation

stxxl::binary_reader::binary_reader ( const binary_buffer_ref br)
inline

Constructor, assign memory area from binary_buffer.

Definition at line 488 of file binary_buffer.h.

stxxl::binary_reader::binary_reader ( const void *  data,
size_t  n 
)
inline

Constructor, assign memory area from pointer and length.

Definition at line 493 of file binary_buffer.h.

stxxl::binary_reader::binary_reader ( const std::string &  str)
inline

Constructor, assign memory area from string, does NOT copy.

Definition at line 498 of file binary_buffer.h.

Member Function Documentation

void stxxl::binary_reader::check_available ( size_t  n) const
inline

Throws a std::underflow_error unless n bytes are available at the cursor.

Definition at line 523 of file binary_buffer.h.

size_t stxxl::binary_reader::curr ( ) const
inline

Return the current read cursor.

Definition at line 503 of file binary_buffer.h.

bool stxxl::binary_reader::cursor_available ( size_t  n) const
inline

Check that n bytes are available at the cursor.

Definition at line 516 of file binary_buffer.h.

bool stxxl::binary_reader::empty ( ) const
inline

Return true if the cursor is at the end of the buffer.

Definition at line 530 of file binary_buffer.h.

template<typename Type >
Type stxxl::binary_reader::get ( )
inline

Fetch a single item of the template type Type from the buffer, advancing the cursor. Be careful with implicit type conversions!

Definition at line 568 of file binary_buffer.h.

binary_buffer_ref stxxl::binary_reader::get_binary_buffer_ref ( )
inline

Fetch a binary_buffer_ref to a binary string or blob which was put via put_string(). Does NOT copy the data.

Definition at line 635 of file binary_buffer.h.

std::string stxxl::binary_reader::get_string ( )
inline

Fetch a string which was put via put_string().

Definition at line 627 of file binary_buffer.h.

uint32 stxxl::binary_reader::get_varint ( )
inline

Fetch a varint with up to 32-bit from the buffer at the cursor.

Definition at line 579 of file binary_buffer.h.

uint64 stxxl::binary_reader::get_varint64 ( )
inline

Fetch a 64-bit varint from the buffer at the cursor.

Definition at line 598 of file binary_buffer.h.

binary_reader& stxxl::binary_reader::read ( void *  outdata,
size_t  datalen 
)
inline

Fetch a number of unstructured bytes from the buffer, advancing the cursor.

Definition at line 546 of file binary_buffer.h.

std::string stxxl::binary_reader::read ( size_t  datalen)
inline

Fetch a number of unstructured bytes from the buffer as std::string, advancing the cursor.

Definition at line 557 of file binary_buffer.h.

binary_reader& stxxl::binary_reader::rewind ( )
inline

Reset the read cursor.

Definition at line 509 of file binary_buffer.h.

binary_reader& stxxl::binary_reader::skip ( size_t  n)
inline

Advance the cursor given number of bytes without reading them.

Definition at line 536 of file binary_buffer.h.

Member Data Documentation

size_t stxxl::binary_reader::m_curr
protected

Current read cursor.

Definition at line 484 of file binary_buffer.h.


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