Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

constbuf Class Reference

Inherited by databuf.

List of all members.


Detailed Description

An immutable data buffer.

Equivalent to a pair<const void*, size_t>: this is just a convenient way of passing a reference to an immutable data buffer.


Public Methods

 constbuf ()
 Null constructor.

 constbuf (const void *dat, unsigned int len)
 Constructs a reference to an immutable data buffer.

 constbuf (const string &s)
 Constructs a reference to a string.

const char * data () const
 Returns a pointer to the beginning of the data buffer.

unsigned int length () const
 Returns the length of the data buffer.

 operator const void * () const
 Returns a non-null value if the data buffer is non-null.

 operator string () const
 Returns the constbuf as a string (always makes a copy).

string as_string () const
 Returns a human-readable representation of the data buffer.


Protected Attributes

char * dat
unsigned int len


Constructor & Destructor Documentation

constbuf::constbuf  
 

Null constructor.

constbuf::constbuf const void *    dat,
unsigned int    len
 

Constructs a reference to an immutable data buffer.

constbuf::constbuf const string &    s [explicit]
 

Constructs a reference to a string.

This constbuf will cease to be valid whenever the value of s.data() changes, i.e., whenever any of s's iterators are invalidated or the string is destructed.


Member Function Documentation

string constbuf::as_string   const
 

Returns a human-readable representation of the data buffer.

const char* constbuf::data   const
 

Returns a pointer to the beginning of the data buffer.

unsigned int constbuf::length   const
 

Returns the length of the data buffer.

constbuf::operator const void *   const
 

Returns a non-null value if the data buffer is non-null.

Exists to enable the if (buf) { ... } metaphor.

constbuf::operator string   const
 

Returns the constbuf as a string (always makes a copy).


Member Data Documentation

char* constbuf::dat [protected]
 

unsigned int constbuf::len [protected]
 


The documentation for this class was generated from the following file:
Generated on Fri Dec 20 13:35:10 2002 for NMSTL