Yate
Public Member Functions | Static Public Member Functions | List of all members
RefStorage Class Reference

A fixed ref counted storage. More...

#include <yatemath.h>

Inheritance diagram for RefStorage:
RefObject GenObject

Public Member Functions

 RefStorage (const void *value, unsigned int len)
 
unsigned int length () const
 
void * data (unsigned int offs, unsigned int len) const
 
bool set (const void *buf, unsigned int len, unsigned int offs=0)
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual void * getObject (const String &name) const
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Static Public Member Functions

static void fill (void *dest, unsigned int len, int val=0)
 
static bool copy (void *dest, const void *src, unsigned int len)
 
static bool equals (const void *buf1, const void *buf2, unsigned int len)
 
static StringdumpSplit (String &buf, const String &str, unsigned int lineLen, unsigned int offset=0, const char *linePrefix=0, const char *suffix="\r\n")
 
- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Additional Inherited Members

- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 

Detailed Description

A fixed ref counted storage.

This class holds a ref counted storage

Constructor & Destructor Documentation

RefStorage ( const void *  value,
unsigned int  len 
)
inline

Constructor

Parameters
valueData to assign, may be NULL to fill with zeros
lenLength of data, may be zero (then value is ignored)

Member Function Documentation

static bool copy ( void *  dest,
const void *  src,
unsigned int  len 
)
inlinestatic

Copy data

Parameters
destDestination buffer
srcSource buffer
lenThe number of bytes to copy
Returns
True on success, false if parameters are invalid

Referenced by SliceVector< Obj >::copy(), and RefStorage::set().

void* data ( unsigned int  offs,
unsigned int  len 
) const
inline

Get a pointer to a byte range inside the stored data

Parameters
offsByte offset inside the stored data
lenNumber of bytes that must be valid starting at offset (must not be 0)
Returns
A pointer to the data or NULL if the range is not available

References DataBlock::data().

Referenced by RefStorage::set().

static String& dumpSplit ( String buf,
const String str,
unsigned int  lineLen,
unsigned int  offset = 0,
const char *  linePrefix = 0,
const char *  suffix = "\r\n" 
)
static

Split a string and append lines to another one

Parameters
bufDestination string
strInput string
lineLenLine length, characters to copy
offsetOffset in first line (if incomplete). No data will be added on first line if offset is greater then line length
linePrefixPrefix for new lines. Set it to empty string or 0 to use the suffix
suffixEnd of line for the last line
Returns
Destination string address

Referenced by SliceVector< Obj >::dumpHex().

static bool equals ( const void *  buf1,
const void *  buf2,
unsigned int  len 
)
inlinestatic

Compare data

Parameters
buf1First buffer
buf2Second buffer
lenThe number of bytes to compare
Returns
True if equal

Referenced by SliceVector< Obj >::equals().

static void fill ( void *  dest,
unsigned int  len,
int  val = 0 
)
inlinestatic

Fill a buffer

Parameters
destDestination buffer
lenThe number of bytes to fill
valValue to fill with

Referenced by SliceVector< Obj >::bzero().

unsigned int length ( ) const
inline

Get the length of the stored data

Returns
The length of the stored data, zero for NULL

References DataBlock::length().

bool set ( const void *  buf,
unsigned int  len,
unsigned int  offs = 0 
)
inline

Copy data to this storage

Parameters
bufBuffer to copy
lenThe number of bytes to copy
offsThe start index in this storage
Returns
True on success, false if there is not enough space in our storage or the buffer pointer is NULL

References RefStorage::copy(), and RefStorage::data().

Referenced by SliceVector< Obj >::SliceVector().


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