Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::util::Formatter Class Referenceabstract

#include <elm/util/Formatter.h>

Public Member Functions

 Formatter (char esc= '%')
 
virtual ~Formatter (void)
 
int format (io::InStream &in, io::OutStream &out=io::out)
 
char escape (void) const
 

Protected Member Functions

virtual int process (io::OutStream &out, char chr)=0
 

Static Protected Attributes

static const int DONE = 0
 
static const int CONTINUE = 1
 
static const int REJECT = 2
 

Detailed Description

Class for formatting some parts of a stream. The changed parts starts with an escape character ('' as default). When such a sequenceis found, the method Formatter::process() is called with the following character and may :

  • reject the character,
  • accept it and perform a specific output,
  • accept the character and answer for the next character (for multi-character escape sequence).
Note that two times the escape character is replaced by one occurence of the escape character.

Constructor & Destructor Documentation

elm::util::Formatter::Formatter ( char  escape = '%')

Build a new formatter.

Parameters
escapeEscape character ('' as default).
virtual elm::util::Formatter::~Formatter ( void  )
virtual

Member Function Documentation

char elm::util::Formatter::escape ( void  ) const

Get the escape character.

Returns
Escape character.
int elm::util::Formatter::format ( io::InStream in,
io::OutStream out = io::out 
)

Format the given input stream to the given output stream.

Parameters
inInput stream.
outOutput streal (default to io::stdout).
Returns
0 for success, <0 for an IO error.

References CONTINUE, DONE, elm::io::InStream::ENDED, elm::io::InStream::FAILED, process(), elm::io::InStream::read(), REJECT, and elm::io::OutStream::write().

int elm::util::Formatter::process ( io::OutStream out,
char  chr 
)
protectedpure virtual

This method must be overloaded for performing special formatting.

Parameters
outOut stream to perform output in.
chrEscaped character.
Returns
One of DONE, CONTINUE, REJECT or a negative error code.

Referenced by format().

Member Data Documentation

const int elm::util::Formatter::CONTINUE = 1
staticprotected

Referenced by format().

const int elm::util::Formatter::DONE = 0
staticprotected

Referenced by format().

const int elm::util::Formatter::REJECT = 2
staticprotected

Referenced by format().


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