#include <ustl.h>
Inheritance diagram for ustl::cmemlink:
Public Types | |
typedef char | value_type |
typedef const value_type * | pointer |
typedef const value_type * | const_pointer |
typedef value_type | reference |
typedef value_type | const_reference |
typedef size_t | size_type |
typedef ptrdiff_t | difference_type |
typedef const_pointer | const_iterator |
typedef const_iterator | iterator |
Public Member Functions | |
cmemlink (void) | |
Default constructor initializes to point to NULL,0. | |
cmemlink (const void *p, size_type n) | |
Attaches the object to pointer p of size n . | |
cmemlink (const cmemlink &l) | |
Copies values from l. | |
void | link (const void *p, size_type n) |
Attaches the object to pointer p of size n . | |
void | link (const void *first, const void *last) |
Links to iterator range first - last . | |
void | link (const cmemlink &l) |
Links to l . | |
virtual void | unlink (void) |
Resets all to 0. | |
const cmemlink & | operator= (const cmemlink &l) |
Copies values from l. | |
bool | operator== (const cmemlink &l) const |
Compares to memory block pointed by l. Size is compared first. | |
void | swap (cmemlink &l) |
swaps the contents with l | |
const_pointer | cdata (void) const |
Returns the pointer to the internal data. | |
iterator | begin (void) const |
Returns the pointer to the internal data. | |
iterator | end (void) const |
Returns the pointer to the end of the internal data. | |
size_type | size (void) const |
Returns the size of the block. | |
size_type | max_size (void) const |
Returns the maximum size of the block (non-resizable, so always == size()). | |
size_type | readable_size (void) const |
Returns the readable size of the block. | |
bool | empty (void) const |
true if size() == 0 | |
void | resize (size_type n) |
Resizes the block as seen by users of the class (no memory allocation). | |
void | read (istream &) |
Reads the object from stream os . | |
void | write (ostream &os) const |
Writes the object to stream os . | |
size_type | stream_size (void) const |
Returns the number of bytes required to write this object to a stream. | |
void | write_file (const char *filename, int mode=0644) const |
Writes the data to file "filename" . | |
virtual size_type | elementSize (void) const |
Returns the size of the atomic element in the block, if any. | |
size_type | elementBytes (size_type n) const |
Use this class the way you would a const pointer to an allocated unstructured block. The pointer and block size are available through member functions and cast operator.
Example usage:
void* p = malloc (46721); cmemlink a, b; a.link (p, 46721); assert (a.size() == 46721)); b = a; assert (b.size() == 46721)); assert (b.DataAt(34) == a.DataAt(34)); assert (0 == memcmp (a, b, 12));
|
Attaches the object to pointer
If Reimplemented in ustl::memlink, ustl::istream, ustl::vector< T >, and ustl::vector< pair< K, V > >. |
|
Resets all to 0.
Reimplemented in ustl::memblock, ustl::memlink, ustl::istream, ustl::ostream, and ustl::ostringstream. |