UCommon
Public Member Functions | Protected Member Functions
ucommon::bufpager Class Reference

Buffered pager for storing paged strings for character protocol. More...

#include <memory.h>

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

Public Member Functions

void add (const char *text)
 Add text to string buffer. More...
 
 bufpager (size_t page=0)
 
char * copy (size_t *iosize)
 Get pointer to copy character data. More...
 
char * dup (void)
 Create an output string from buffer. More...
 
size_t get (char *text, size_t size)
 Get string from buffer. More...
 
 operator bool () const
 Check if can still save into buffer. More...
 
bool operator! () const
 Check if can still save into buffer. More...
 
char * operator* ()
 Convenience operator to get text. More...
 
bufpageroperator<< (const char *text)
 Convenience operator to add to pager. More...
 
void put (const char *text, size_t size)
 Put memory string into buffer including NULL byte. More...
 
char * request (size_t *iosize)
 Request character buffer to write into directly. More...
 
void reset (void)
 Reset pager text buffer protocol.
 
void rewind (void)
 Rewind to start of text buffer protocol.
 
void set (const char *text)
 Set text of string buffer. More...
 
void update (size_t size)
 Used to complete a request method. More...
 
unsigned long used (void) const
 Get total size. More...
 
- Public Member Functions inherited from ucommon::memalloc
unsigned max (void) const
 Get the maximum number of pages that are permitted. More...
 
 memalloc (size_t page=0)
 Construct a memory pager. More...
 
unsigned pages (void) const
 Get the number of pages that have been allocated from the real heap. More...
 
void purge (void)
 Purge all allocated memory and heap pages immediately.
 
unsigned size (void) const
 Get the size of a memory page. More...
 
unsigned utilization (void) const
 Determine fragmentation level of acquired heap pages. More...
 
virtual ~memalloc ()
 Destroy a memory pager. More...
 
- Public Member Functions inherited from ucommon::CharacterProtocol
int getchar (void)
 Get the next character. More...
 
size_t getline (char *string, size_t size)
 Get text as a line of input from the buffer. More...
 
size_t getline (String &buffer)
 Get a string as a line of input from the buffer. More...
 
size_t input (InputProtocol &format)
 
size_t load (StringPager *list)
 Load input to a string list. More...
 
size_t print (const PrintProtocol &format)
 
int putchar (int code)
 Put the next character. More...
 
size_t putchars (const char *string, size_t count=0)
 
size_t putline (const char *string)
 Put a string as a line of output to the buffer. More...
 
size_t save (const StringPager *list)
 Save output from a string list. More...
 

Protected Member Functions

virtual void * _alloc (size_t size)
 Allocate memory from the pager heap. More...
 
- Protected Member Functions inherited from ucommon::memalloc
virtual void fault (void) const
 Report runtime memory exhaustion.
 
page_t * pager (void)
 Acquire a new page from the heap. More...
 
- Protected Member Functions inherited from ucommon::CharacterProtocol
void putback (int code)
 Write to back buffer. More...
 
void seteol (const char *string)
 Set end of line marker. More...
 

Additional Inherited Members

- Protected Attributes inherited from ucommon::memalloc
unsigned limit
 
- Protected Attributes inherited from ucommon::CharacterProtocol
int back
 
const char * eol
 

Detailed Description

Buffered pager for storing paged strings for character protocol.

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

Definition at line 659 of file memory.h.

Member Function Documentation

virtual void* ucommon::bufpager::_alloc ( size_t  size)
protectedvirtual

Allocate memory from the pager heap.

The size of the request must be less than the size of the memory page used. This implements the memory protocol allocation method.

Parameters
sizeof memory request.
Returns
allocated memory or NULL if not possible.

Reimplemented from ucommon::memalloc.

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

Add text to string buffer.

Parameters
textto add.
char* ucommon::bufpager::copy ( size_t *  iosize)

Get pointer to copy character data.

The memory pointer is positioned at the next chunk automatically.

Parameters
iosizeof data you can copy.
Returns
to data from buffer or NULL if past end.
char* ucommon::bufpager::dup ( void  )

Create an output string from buffer.

Returns
output string allocated.
size_t ucommon::bufpager::get ( char *  text,
size_t  size 
)

Get string from buffer.

Parameters
textto save into.
sizeof buffer.
Returns
count of characters copied.
ucommon::bufpager::operator bool ( ) const
inline

Check if can still save into buffer.

Used for is() function.

Returns
true if pager can still store more.

Definition at line 778 of file memory.h.

bool ucommon::bufpager::operator! ( ) const
inline

Check if can still save into buffer.

Returns
true if buffer is full.

Definition at line 771 of file memory.h.

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

Convenience operator to get text.

Returns
text string of buffer.

Definition at line 734 of file memory.h.

Here is the call graph for this function:

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

Convenience operator to add to pager.

Parameters
textto add to list.

Definition at line 741 of file memory.h.

void ucommon::bufpager::put ( const char *  text,
size_t  size 
)

Put memory string into buffer including NULL byte.

Parameters
textto add.
sizeof text to add.
char* ucommon::bufpager::request ( size_t *  iosize)

Request character buffer to write into directly.

Parameters
iosizemade available.
Returns
pointer to buffer or NULL if out of memory.
void ucommon::bufpager::set ( const char *  text)

Set text of string buffer.

Parameters
textto set.
void ucommon::bufpager::update ( size_t  size)

Used to complete a request method.

Parameters
sizeof data actually written.
unsigned long ucommon::bufpager::used ( void  ) const
inline

Get total size.

Returns
number of characters in buffer.

Definition at line 727 of file memory.h.


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