Public Types | Public Member Functions | List of all members
ustl::memlink Class Reference

Wrapper for pointer to block with size. More...

#include <ustl.h>

Inheritance diagram for ustl::memlink:
ustl::cmemlink ustl::memblock ustl::ostream ustl::string ustl::ostringstream ustl::ofstream

Public Types

typedef value_type * pointer
 
typedef cmemlink::pointer const_pointer
 
typedef cmemlink::const_iterator const_iterator
 
typedef pointer iterator
 
typedef const memlinkrcself_t
 

Public Member Functions

 memlink (void *p, size_type n)
 
 memlink (const void *p, size_type n)
 
 memlink (rcself_t l)
 
 memlink (const cmemlink &l)
 
pointer data (void)
 
const_pointer data (void) const
 
iterator begin (void)
 
iterator iat (size_type i)
 
iterator end (void)
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
const_iterator iat (size_type i) const
 
size_type writable_size (void) const
 
rcself_t operator= (const cmemlink &l)
 
rcself_t operator= (rcself_t l)
 
void link (const void *p, size_type n)
 
void link (void *p, size_type n)
 
void link (const cmemlink &l)
 
void link (memlink &l)
 
void link (const void *first, const void *last)
 
void link (void *first, void *last)
 
void relink (const void *p, size_type n)
 
void relink (void *p, size_type n)
 
void swap (memlink &l)
 
void fill (const_iterator start, const void *p, size_type elsize, size_type elCount=1) noexcept
 
void insert (const_iterator start, size_type size)
 
void erase (const_iterator start, size_type size)
 
void read (istream &is)
 Reads the object from stream s.
 

Detailed Description

Wrapper for pointer to block with size.

Use this class the way you would a 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);
memlink a, b;
a.link (p, 46721);
assert (a.size() == 46721));
b = a;
assert (b.size() == 46721));
assert (b.begin() + 34 == a.begin + 34);
assert (0 == memcmp (a, b, 12));
a.fill (673, b, 42, 67);
b.erase (87, 12);

Member Function Documentation

void ustl::memlink::erase ( const_iterator  cstart,
size_type  n 
)
inline

Shifts the data in the linked block from start + n to start. The contents of the uncovered bytes is undefined.

References ustl::rotate().

Referenced by ustl::memblock::erase(), and ustl::ostream::erase().

void ustl::memlink::fill ( const_iterator  cstart,
const void *  p,
size_type  elSize,
size_type  elCount = 1 
)
noexcept

Fills the linked block with the given pattern.

  • start Offset at which to start filling the linked block
  • p Pointer to the pattern.
  • elSize Size of the pattern.
  • elCount Number of times to write the pattern. Total number of bytes written is elSize * elCount.

References ustl::copy_n(), and ustl::fill_n().

Referenced by ustl::string::insert(), and ustl::string::replace().

void ustl::memlink::insert ( const_iterator  cstart,
size_type  n 
)
inline

Shifts the data in the linked block from start to start + n. The contents of the uncovered bytes is undefined.

References ustl::rotate().

Referenced by ustl::memblock::insert(), and ustl::ostream::insert().


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

Generated on Mon Sep 28 2015 17:58:50 for uSTL by Doxygen 1.8.10