UCommon
Public Member Functions | Protected Member Functions | Protected Attributes
ucommon::CharacterProtocol Class Reference

Common character processing protocol. More...

#include <protocols.h>

Inheritance diagram for ucommon::CharacterProtocol:
Inheritance graph
[legend]

Public Member Functions

int getchar (void)
 Get the next character.
size_t getline (char *string, size_t size)
 Get text as a line of input from the buffer.
size_t getline (String &buffer)
 Get a string as a line of input from the buffer.
size_t input (InputProtocol &format)
size_t load (StringPager *list)
 Load input to a string list.
size_t print (const PrintProtocol &format)
int putchar (int code)
 Put the next character.
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.
size_t save (const StringPager *list)
 Save output from a string list.

Protected Member Functions

virtual int _getch (void)=0
 Get the next character.
virtual int _putch (int code)=0
 Put the next character.
void putback (int code)
 Write to back buffer.
void seteol (const char *string)
 Set end of line marker.

Protected Attributes

int back
const char * eol

Detailed Description

Common character processing protocol.

This is used to access a character from some type of streaming buffer or memory object.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 175 of file protocols.h.


Member Function Documentation

virtual int ucommon::CharacterProtocol::_getch ( void  ) [protected, pure virtual]

Get the next character.

Returns:
next character or EOF.

Implemented in ucommon::BufferProtocol.

virtual int ucommon::CharacterProtocol::_putch ( int  code) [protected, pure virtual]

Put the next character.

Parameters:
codeto put.
Returns:
code or EOF if cannot put.

Implemented in ucommon::BufferProtocol.

int ucommon::CharacterProtocol::getchar ( void  ) [inline]

Get the next character.

Returns:
next character or EOF.

Definition at line 220 of file protocols.h.

size_t ucommon::CharacterProtocol::getline ( char *  string,
size_t  size 
)

Get text as a line of input from the buffer.

The eol character(s) are used to mark the end of a line. Because the end of line character is stripped, the length of the string may be less than the actual count read. If at the end of the file buffer and unable to read more data an error occured then 0 is returned.

Parameters:
stringto save input into.
sizelimit of string to save.
Returns:
count of characters actually read or 0 if at end of data.

Get a string as a line of input from the buffer.

The eol character(s) are used to mark the end of a line. Because the end of line character is stripped, the length of the string may be less than the actual count read. If at the end of the file buffer and unable to read more data an error occured then 0 is returned.

Parameters:
bufferto save input into.
Returns:
count of characters actually read or 0 if at end of data.

Load input to a string list.

The string list filter method is used to control loading.

Parameters:
listto load into.
Returns:
number of items loaded.
void ucommon::CharacterProtocol::putback ( int  code) [inline, protected]

Write to back buffer.

Mostly used for input format processing.

Parameters:
codeto write into backbuffer.

Definition at line 200 of file protocols.h.

int ucommon::CharacterProtocol::putchar ( int  code) [inline]

Put the next character.

Parameters:
codeto put.
Returns:
code or EOF if cannot put.

Definition at line 228 of file protocols.h.

size_t ucommon::CharacterProtocol::putline ( const char *  string)

Put a string as a line of output to the buffer.

The eol character is appended to the end.

Parameters:
stringto write.
Returns:
total characters successfully written, including eol chars.

Save output from a string list.

Parameters:
listto save from.
Returns:
number of items loaded.
void ucommon::CharacterProtocol::seteol ( const char *  string) [inline, protected]

Set end of line marker.

Normally this is set to cr & lf, which actually supports both lf alone and cr/lf termination of lines. However, putline() will always add the full cr/lf if this mode is used. This option only effects getline() and putline().

Parameters:
stringfor eol for getline and putline.

Definition at line 210 of file protocols.h.


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