ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ucommon::StringPager Class Reference

#include <memory.h>

Inheritance diagram for ucommon::StringPager:
[legend]
Collaboration diagram for ucommon::StringPager:
[legend]

Classes

class  member
 

Public Types

typedef linked_pointer< StringPager::memberiterator
 

Public Member Functions

virtual bool filter (char *text, size_t size)
 
 StringPager (size_t pagesize=256)
 
 StringPager (char **list, size_t pagesize=256)
 
unsigned count (void) const
 
const char * get (unsigned item) const
 
void set (unsigned item, const char *string)
 
void add (const char *text)
 
void push (const char *text)
 
void push (char **text)
 
const char * pull (void)
 
const char * pop (void)
 
void add (char **list)
 
void set (char **list)
 
void clear (void)
 
const char * operator[] (unsigned item) const
 
const char * at (unsigned item) const
 
StringPager::memberbegin (void) const
 
void operator+= (const char *text)
 
StringPageroperator<< (const char *text)
 
StringPageroperator>> (const char *text)
 
void sort (void)
 
char ** list (void)
 
unsigned token (const char *text, const char *list, const char *quote=NULL, const char *end=NULL)
 
unsigned split (const char *text, const char *string, unsigned flags=0)
 
unsigned split (stringex_t &expr, const char *string, unsigned flags=0)
 
String join (const char *prefix=NULL, const char *middle=NULL, const char *suffix=NULL)
 
 operator bool () const
 
bool operator! () const
 
StringPageroperator= (char **list)
 
const char * operator* ()
 
 operator char ** ()
 
size_t size (void) const
 
unsigned pages (void) const
 
void assign (StringPager &source)
 

Private Attributes

unsigned members
 
LinkedObjectroot
 
memberlast
 
char ** index
 

Additional Inherited Members

- Protected Member Functions inherited from ucommon::memalloc
page_tpager (void)
 
virtual void * _alloc (size_t size) __OVERRIDE
 
 memalloc (size_t page=0)
 
 memalloc (const memalloc &copy)
 
virtual ~memalloc ()
 
unsigned pages (void) const
 
unsigned max (void) const
 
size_t size (void) const
 
unsigned utilization (void) const
 
void purge (void)
 
void assign (memalloc &source)
 
- Protected Attributes inherited from ucommon::memalloc
unsigned limit
 

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 401 of file memory.h.

Member Typedef Documentation

◆ iterator

Convenience typedef for iterative pointer.

Definition at line 624 of file memory.h.

Constructor & Destructor Documentation

◆ StringPager() [1/2]

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

Create a pager with a maximum page size.

Parameters
sizeof pager allocation pages.

Definition at line 476 of file memory.cpp.

References index, last, members, and root.

◆ StringPager() [2/2]

ucommon::StringPager::StringPager ( char **  list,
size_t  pagesize = 256 
)

Definition at line 500 of file memory.cpp.

References add(), last, list(), members, and root.

Member Function Documentation

◆ add() [1/2]

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.

Definition at line 763 of file memory.cpp.

References add(), and list().

◆ add() [2/2]

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

Add text to list.

Parameters
textto add.

Definition at line 719 of file memory.cpp.

References ucommon::memalloc::_alloc(), index, last, members, root, ucommon::StringPager::member::set(), size(), and ucommon::str().

Referenced by add(), filter(), ucommon::DirPager::filter(), set(), split(), StringPager(), and token().

◆ assign()

void ucommon::StringPager::assign ( StringPager source)

Assign foreign pager to us. This relocates the heap references to our object, clears the other object.

Definition at line 485 of file memory.cpp.

References ucommon::memalloc::assign(), index, last, members, and root.

Referenced by ucommon::DirPager::assign().

◆ at()

const char* ucommon::StringPager::at ( unsigned  item) const
inline

Definition at line 538 of file memory.h.

◆ begin()

StringPager::member* ucommon::StringPager::begin ( void  ) const
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 547 of file memory.h.

Referenced by ucommon::_stream_operators::print().

◆ clear()

void ucommon::StringPager::clear ( void  )

Purge all members and release pager member. The list can then be added to again.

Definition at line 635 of file memory.cpp.

References index, last, members, ucommon::memalloc::purge(), and root.

Referenced by ucommon::DirPager::operator=(), and set().

◆ count()

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 459 of file memory.h.

Referenced by ucommon::DirPager::count(), sort(), split(), and token().

◆ filter()

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
textto filter.
sizeof text buffer for transforms.
Returns
false if end of data.

Reimplemented in ucommon::DirPager.

Definition at line 509 of file memory.cpp.

References add(), and buffer.

Referenced by ucommon::_stream_operators::input().

◆ get()

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
itemto access.
Returns
pointer to text for item, or NULL if out of range.

Definition at line 620 of file memory.cpp.

References __THROW_RANGE, list(), members, and root.

Referenced by ucommon::DirPager::at(), ucommon::DirPager::get(), and ucommon::DirPager::operator[]().

◆ join()

String ucommon::StringPager::join ( const char *  prefix = NULL,
const char *  middle = NULL,
const char *  suffix = NULL 
)

◆ list()

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

Gather index list.

Returns
index.

Definition at line 799 of file memory.cpp.

References ucommon::memalloc::_alloc(), index, ucommon::is(), members, ucommon::linked_pointer< T >::next(), root, and ucommon::StringPager::member::text.

Referenced by add(), get(), push(), set(), sort(), StringPager(), and token().

◆ operator bool()

ucommon::StringPager::operator bool ( ) const
inline

Definition at line 600 of file memory.h.

◆ operator char **()

ucommon::StringPager::operator char ** ( )
inline

Definition at line 617 of file memory.h.

◆ operator!()

bool ucommon::StringPager::operator! ( void  ) const
inline

Definition at line 604 of file memory.h.

◆ operator*()

const char* ucommon::StringPager::operator* ( )
inline

Definition at line 613 of file memory.h.

◆ operator+=()

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 555 of file memory.h.

◆ operator<<()

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

Convenience operator to add to pager.

Parameters
textto add to list.

Definition at line 563 of file memory.h.

◆ operator=()

StringPager& ucommon::StringPager::operator= ( char **  list)
inline

Definition at line 608 of file memory.h.

◆ operator>>()

StringPager& ucommon::StringPager::operator>> ( const char *  text)
inline

Definition at line 568 of file memory.h.

◆ operator[]()

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

Return specified member from pager list. This is a convenience operator.

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

Definition at line 534 of file memory.h.

◆ pages()

unsigned ucommon::StringPager::pages ( void  ) const
inline

Definition at line 630 of file memory.h.

References ucommon::memalloc::pages().

◆ pop()

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

Remove element from back of list. Does not release memory.

Returns
text removed.

Definition at line 687 of file memory.cpp.

References __THROW_RUNTIME, index, ucommon::is(), last, members, ucommon::LinkedObject::Next, ucommon::linked_pointer< T >::next(), out, root, and ucommon::StringPager::member::text.

◆ pull()

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

Remove element from front of list. Does not release memory.

Returns
text removed.

Definition at line 644 of file memory.cpp.

References __THROW_RUNTIME, index, last, members, ucommon::LinkedObject::Next, result(), root, and ucommon::StringPager::member::text.

◆ push() [1/2]

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

Add text list to front of list.

Parameters
textto add.

Definition at line 751 of file memory.cpp.

References list(), and push().

◆ push() [2/2]

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

Add text to front of list.

Parameters
textto add.

Definition at line 664 of file memory.cpp.

References ucommon::memalloc::_alloc(), index, last, members, root, size(), and ucommon::str().

Referenced by push().

◆ set() [1/2]

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.

Definition at line 745 of file memory.cpp.

References add(), clear(), and list().

◆ set() [2/2]

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

Replace string item in list.

Parameters
itemto replace.
stringto replace with.

Definition at line 601 of file memory.cpp.

References ucommon::memalloc::_alloc(), list(), members, root, size(), and ucommon::str().

◆ size()

size_t ucommon::StringPager::size ( void  ) const
inline

Definition at line 626 of file memory.h.

References ucommon::memalloc::size().

Referenced by add(), ucommon::_stream_operators::input(), push(), and set().

◆ sort()

void ucommon::StringPager::sort ( void  )

Sort members.

Definition at line 775 of file memory.cpp.

References count(), index, ucommon::is(), list(), members, ucommon::ncompare(), ucommon::linked_pointer< T >::next(), and root.

Referenced by ucommon::DirPager::load().

◆ split() [1/2]

unsigned ucommon::StringPager::split ( const char *  text,
const char *  string,
unsigned  flags = 0 
)

Definition at line 555 of file memory.cpp.

References add(), count(), ucommon::String::dup(), and ucommon::String::INSENSITIVE.

◆ split() [2/2]

unsigned ucommon::StringPager::split ( stringex_t expr,
const char *  string,
unsigned  flags = 0 
)

◆ token()

unsigned ucommon::StringPager::token ( const char *  text,
const char *  list,
const char *  quote = NULL,
const char *  end = NULL 
)

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.

Definition at line 515 of file memory.cpp.

References add(), count(), list(), quote, result(), and ucommon::String::token().

Member Data Documentation

◆ index

char** ucommon::StringPager::index
private

Definition at line 636 of file memory.h.

Referenced by add(), assign(), clear(), list(), pop(), pull(), push(), sort(), and StringPager().

◆ last

member* ucommon::StringPager::last
private

Definition at line 635 of file memory.h.

Referenced by add(), assign(), clear(), pop(), pull(), push(), and StringPager().

◆ members

unsigned ucommon::StringPager::members
private

Definition at line 404 of file memory.h.

Referenced by add(), assign(), clear(), get(), join(), list(), pop(), pull(), push(), set(), sort(), and StringPager().

◆ root

LinkedObject* ucommon::StringPager::root
private

Definition at line 405 of file memory.h.

Referenced by add(), assign(), clear(), get(), join(), list(), pop(), pull(), push(), set(), sort(), and StringPager().


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