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]

Public Types

typedef linked_pointer< StringPager::memberiterator
 Convenience typedef for iterative pointer.

Public Member Functions

void add (char **list)
 Add list to list.
void add (char *text)
 Add text to list.
char * at (unsigned item)
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.
virtual bool filter (char *text, size_t size)
 Filter text in a derived class.
char * get (unsigned item)
 Get string item from list.
String join (char *prefix=((void *) 0), char *middle=((void *) 0), char *suffix=((void *) 0))
char ** list (void)
 Gather index list.
char * operator * ()
 operator bool ()
 operator char ** ()
bool operator! ()
void operator+= (char *text)
 Convenience operator to add to pager and auto-sort.
StringPageroperator<< (char *text)
 Convenience operator to add to pager.
StringPageroperator= (char **list)
StringPageroperator>> (char *text)
char * operator[] (unsigned item)
 Return specified member from pager list.
unsigned pages (void)
 Get the number of pages that have been allocated from the real heap.
char * pop (void)
 Remove element from back of list.
char * pull (void)
 Remove element from front of list.
void push (char **text)
 Add text list to front of list.
void push (char *text)
 Add text to front of list.
void set (char **list)
 Set list to list.
void set (unsigned item, char *string)
 Replace string item in list.
size_t size (void)
 Get the size of a memory page.
void sort (void)
 Sort members.
unsigned split (stringex_t &expr, char *string, unsigned flags=0)
unsigned split (char *text, char *string, unsigned flags=0)
 StringPager (char **list, size_t pagesize=256)
 StringPager (size_t pagesize=256)
 Create a pager with a maximum page size.
unsigned token (char *text, char *list, char *quote=((void *) 0), char *end=((void *) 0))
 Tokenize a string and add each token to the StringPager.

Protected Member Functions

virtual char * invalid (void)

Data Structures

class  member
 Member of string list. More...

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@gnutelephony.org>

Definition at line 364 of file memory.h.


Constructor & Destructor Documentation

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

Create a pager with a maximum page size.

Parameters:
size of pager allocation pages.


Member Function Documentation

void ucommon::StringPager::add ( char **  list  ) 

Add list to list.

This is a list of string pointers terminated with NULL.

Parameters:
list of text to add.

void ucommon::StringPager::add ( char *  text  ) 

Add text to list.

Parameters:
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 508 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.

Reimplemented in ucommon::DirPager.

Definition at line 423 of file memory.h.

virtual bool ucommon::StringPager::filter ( char *  text,
size_t  size 
) [virtual]

Filter text in a derived class.

The base class filter removes newlines at end of text and filters out empty strings.

Parameters:
text to filter.
size of text buffer for transforms.
Returns:
false if end of data.

Reimplemented in ucommon::DirPager.

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:
item to 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+= ( char *  text  )  [inline]

Convenience operator to add to pager and auto-sort.

Parameters:
text to add to list.

Definition at line 515 of file memory.h.

StringPager& ucommon::StringPager::operator<< ( char *  text  )  [inline]

Convenience operator to add to pager.

Parameters:
text to add to list.

Definition at line 522 of file memory.h.

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

Return specified member from pager list.

This is a convenience operator.

Parameters:
item to access.
Returns:
text of item or NULL if invalid.

Reimplemented in ucommon::DirPager.

Definition at line 497 of file memory.h.

unsigned ucommon::StringPager::pages ( void   )  [inline]

Get the number of pages that have been allocated from the real heap.

Returns:
pages allocated from heap.

Reimplemented from ucommon::memalloc.

Reimplemented in ucommon::DirPager.

Definition at line 578 of file memory.h.

char* ucommon::StringPager::pop ( void   ) 

Remove element from back of list.

Does not release memory.

Returns:
text removed.

char* ucommon::StringPager::pull ( void   ) 

Remove element from front of list.

Does not release memory.

Returns:
text removed.

Referenced by ucommon::shift().

void ucommon::StringPager::push ( char **  text  ) 

Add text list to front of list.

Parameters:
text to add.

void ucommon::StringPager::push ( char *  text  ) 

Add text to front of list.

Parameters:
text to add.

Referenced by ucommon::unshift().

void ucommon::StringPager::set ( char **  list  ) 

Set list to list.

This is a list of string pointers terminated with NULL.

Parameters:
list of text to set.

void ucommon::StringPager::set ( unsigned  item,
char *  string 
)

Replace string item in list.

Parameters:
item to replace.
string to replace with.

size_t ucommon::StringPager::size ( void   )  [inline]

Get the size of a memory page.

Returns:
size of each pager heap allocation.

Reimplemented from ucommon::memalloc.

Reimplemented in ucommon::DirPager.

Definition at line 575 of file memory.h.

unsigned ucommon::StringPager::token ( char *  text,
char *  list,
char *  quote = ((void *) 0),
char *  end = ((void *) 0) 
)

Tokenize a string and add each token to the StringPager.

Parameters:
text to tokenize.
list of characters to use as token separators.
quote pairs of characters for quoted text or NULL if not used.
end of line marker characters or NULL if not used.
Returns:
number of tokens parsed.


The documentation for this class was generated from the following file:
Generated on 14 Aug 2013 for UCommon by  doxygen 1.4.7