String pager for storing lists of NULL terminated strings.
More...
#include <memory.h>
|
void | add (const char *text) |
| Add text to list.
|
|
void | add (char **list) |
| Add list to list.
|
|
const char * | at (unsigned item) const |
|
StringPager::member * | begin (void) const |
| Get root of pager list.
|
|
void | clear (void) |
| Purge all members and release pager member.
|
|
unsigned | count (void) const |
| Get the number of items in the pager string list.
|
|
virtual bool | filter (char *text, size_t size) |
| Filter text in a derived class.
|
|
const char * | get (unsigned item) const |
| 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.
|
|
StringPager & | operator<< (const char *text) |
| Convenience operator to add to pager.
|
|
StringPager & | operator= (char **list) |
|
StringPager & | operator>> (const char *text) |
|
const char * | operator[] (unsigned item) const |
| Return specified member from pager list.
|
|
unsigned | pages (void) |
|
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.
|
|
size_t | size (void) |
|
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.
|
|
|
virtual const char * | invalid (void) const |
|
virtual void * | _alloc (size_t size) |
| Allocate memory from the pager heap.
|
|
unsigned | max (void) const |
| Get the maximum number of pages that are permitted.
|
|
| memalloc (size_t page=0) |
| Construct a memory pager.
|
|
unsigned | pages (void) const |
| Get the number of pages that have been allocated from the real heap.
|
|
void | purge (void) |
| Purge all allocated memory and heap pages immediately.
|
|
unsigned | size (void) const |
| Get the size of a memory page.
|
|
unsigned | utilization (void) const |
| Determine fragmentation level of acquired heap pages.
|
|
virtual | ~memalloc () |
| Destroy a memory pager.
|
|
virtual void | fault (void) const |
| Report runtime memory exhaustion.
|
|
page_t * | pager (void) |
| Acquire a new page from the heap.
|
|
void * | alloc (size_t size) |
| Convenience function.
|
|
char * | dup (const char *string) |
| Duplicate NULL terminated string into allocated memory.
|
|
void * | dup (void *memory, size_t size) |
| Duplicate existing memory block into allocated memory.
|
|
void * | zalloc (size_t size) |
| Allocate memory from the pager heap.
|
|
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 364 of file memory.h.
ucommon::StringPager::StringPager |
( |
size_t |
pagesize = 256 | ) |
|
Create a pager with a maximum page size.
- Parameters
-
size | of pager allocation pages. |
void ucommon::StringPager::add |
( |
const char * |
text | ) |
|
Add text to list.
- Parameters
-
void ucommon::StringPager::add |
( |
char ** |
list | ) |
|
Add list to list.
This is a list of string pointers terminated with NULL.
- Parameters
-
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 |
| ) |
const |
|
inline |
Get the number of items in the pager string list.
- Returns
- number of items stored.
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.
const char* ucommon::StringPager::get |
( |
unsigned |
item | ) |
const |
Get string item from list.
This is useful when StringPager is passed as a pointer and hence inconvenient for the [] operator.
- Parameters
-
- Returns
- pointer to text for item, or NULL if out of range.
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
-
Definition at line 515 of file memory.h.
StringPager& ucommon::StringPager::operator<< |
( |
const char * |
text | ) |
|
|
inline |
Convenience operator to add to pager.
- Parameters
-
Definition at line 522 of file memory.h.
const char* ucommon::StringPager::operator[] |
( |
unsigned |
item | ) |
const |
|
inline |
Return specified member from pager list.
This is a convenience operator.
- Parameters
-
- Returns
- text of item or NULL if invalid.
Definition at line 497 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
-
void ucommon::StringPager::push |
( |
char ** |
text | ) |
|
Add text list to front of list.
- Parameters
-
void ucommon::StringPager::set |
( |
unsigned |
item, |
|
|
const char * |
string |
|
) |
| |
Replace string item in list.
- Parameters
-
item | to replace. |
string | to replace with. |
void ucommon::StringPager::set |
( |
char ** |
list | ) |
|
Set list to list.
This is a list of string pointers terminated with NULL.
- Parameters
-
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
-
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: