#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 cmemlink &l) |
Links to l. | |
| void | link (const void *first, const void *last) |
Links to iterator range first - last. | |
| virtual void | unlink (void) |
| 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 |
| 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". | |
| void | link (const void *p, int n) |
| void | link (const void *p, long n) |
| void | link (const void *p, unsigned long n) |
Protected Member Functions | |
| 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));
|
|
Resets all to 0. Do NOT override this function. It is virtual only for memlink, memblock, and the streams; there is no way to "unvirtualize" a function, hence the documentation. Reimplemented in ustl::memblock, ustl::memlink, ustl::istream, ustl::ostream, and ustl::ostringstream.
|