UCommon
Data Structures | Public Member Functions
ucommon::stringpager Class Reference

String pager for storing lists of NULL terminated strings. More...

#include <memory.h>

Inheritance diagram for ucommon::stringpager:
Inheritance graph
[legend]
Collaboration diagram for ucommon::stringpager:
Collaboration graph
[legend]

Data Structures

class  member
 Member of string list. More...

Public Member Functions

void add (const char *text)
 Add text to list.
void add (char **list)
 Add list to list.
stringpager::memberbegin (void)
 Get root of pager list.
void clear (void)
 Purge all members and release pager member.
unsigned count (void)
 Get the number of items in the pager string list.
const char * get (unsigned item)
 Get string item from list.
String join (const char *prefix=((void *) 0), const char *middle=((void *) 0), const char *suffix=((void *) 0))
char ** list (void)
 Gather index list.
 operator bool ()
 operator char ** ()
bool operator! ()
const char * operator* ()
void operator+= (const char *text)
 Convenience operator to add to pager and auto-sort.
stringpageroperator<< (const char *text)
 Convenience operator to add to pager.
stringpageroperator= (char **list)
stringpageroperator>> (const char *text)
const char * operator[] (unsigned item)
 Return specified member from pager list.
const char * pop (void)
 Remove element from back of list.
const char * pull (void)
 Remove element from front of list.
void push (const char *text)
 Add text to front of list.
void push (char **text)
 Add text list to front of list.
void set (unsigned item, const char *string)
 Replace string item in list.
void set (char **list)
 Set list to list.
void sort (void)
 Sort members.
unsigned split (const char *text, const char *string, unsigned flags=0)
unsigned split (stringex_t &expr, const char *string, unsigned flags=0)
 stringpager (size_t pagesize=256)
 Create a pager with a maximum page size.
 stringpager (char **list, size_t pagesize=256)
unsigned token (const char *text, const char *list, const char *quote=((void *) 0), const char *end=((void *) 0))
 Tokenize a string and add each token to the stringpager.

Additional Inherited Members

- Protected Member Functions inherited from ucommon::memalloc
virtual void * _alloc (size_t size)
 Allocate memory from the pager heap.
unsigned getAlloc (void)
 Get the size of a memory page.
unsigned getLimit (void)
 Get the maximum number of pages that are permitted.
unsigned getPages (void)
 Get the number of pages that have been allocated from the real heap.
 memalloc (size_t page=0)
 Construct a memory pager.
void purge (void)
 Purge all allocated memory and heap pages immediately.
unsigned utilization (void)
 Determine fragmentation level of acquired heap pages.
virtual ~memalloc ()
 Destroy a memory pager.
page_t * pager (void)
 Acquire a new page from the heap.

Detailed Description

String pager for storing lists of NULL terminated strings.

This is used for accumulating lists which can be destroyed all at once.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 342 of file memory.h.

Constructor & Destructor Documentation

ucommon::stringpager::stringpager ( size_t  pagesize = 256)

Create a pager with a maximum page size.

Parameters
sizeof pager allocation pages.

Member Function Documentation

void ucommon::stringpager::add ( const char *  text)

Add text to list.

Parameters
textto add.
void ucommon::stringpager::add ( char **  list)

Add list to list.

This is a list of string pointers terminated with NULL.

Parameters
listof text to add.
stringpager::member* ucommon::stringpager::begin ( void  )
inline

Get root of pager list.

This is useful for externally enumerating the list of strings.

Returns
first member of list or NULL if empty.

Definition at line 471 of file memory.h.

void ucommon::stringpager::clear ( void  )

Purge all members and release pager member.

The list can then be added to again.

unsigned ucommon::stringpager::count ( void  )
inline

Get the number of items in the pager string list.

Returns
number of items stored.

Definition at line 389 of file memory.h.

const char* ucommon::stringpager::get ( unsigned  item)

Get string item from list.

This is useful when stringpager is passed as a pointer and hence inconvenient for the [] operator.

Parameters
itemto access.
Returns
pointer to text for item, or NULL if out of range.

Reimplemented in ucommon::DirPager.

char** ucommon::stringpager::list ( void  )

Gather index list.

Returns
index.
void ucommon::stringpager::operator+= ( const char *  text)
inline

Convenience operator to add to pager and auto-sort.

Parameters
textto add to list.

Definition at line 478 of file memory.h.

Here is the call graph for this function:

stringpager& ucommon::stringpager::operator<< ( const char *  text)
inline

Convenience operator to add to pager.

Parameters
textto add to list.

Definition at line 485 of file memory.h.

Here is the call graph for this function:

const char* ucommon::stringpager::operator[] ( unsigned  item)
inline

Return specified member from pager list.

This is a convenience operator.

Parameters
itemto access.
Returns
text of item or NULL if invalid.

Reimplemented in ucommon::DirPager.

Definition at line 463 of file memory.h.

const char* ucommon::stringpager::pop ( void  )

Remove element from back of list.

Does not release memory.

Returns
text removed.
const char* ucommon::stringpager::pull ( void  )

Remove element from front of list.

Does not release memory.

Returns
text removed.
void ucommon::stringpager::push ( const char *  text)

Add text to front of list.

Parameters
textto add.
void ucommon::stringpager::push ( char **  text)

Add text list to front of list.

Parameters
textto add.
void ucommon::stringpager::set ( unsigned  item,
const char *  string 
)

Replace string item in list.

Parameters
itemto replace.
stringto replace with.
void ucommon::stringpager::set ( char **  list)

Set list to list.

This is a list of string pointers terminated with NULL.

Parameters
listof text to set.
unsigned ucommon::stringpager::token ( const char *  text,
const char *  list,
const char *  quote = ((void *) 0),
const char *  end = ((void *) 0) 
)

Tokenize a string and add each token to the stringpager.

Parameters
textto tokenize.
listof characters to use as token separators.
quotepairs of characters for quoted text or NULL if not used.
endof line marker characters or NULL if not used.
Returns
number of tokens parsed.

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