Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Formatter Class Referenceabstract

#include <elm/string/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
 
void escape (char c)
 

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 occurrence of the escape character.

Constructor & Destructor Documentation

◆ Formatter()

Formatter ( char  escape = '%')

Build a new formatter.

Parameters
escapeEscape character ('' as default).

◆ ~Formatter()

virtual ~Formatter ( void  )
inlinevirtual

Member Function Documentation

◆ escape() [1/2]

void escape ( char  c)
inline

Change the escape character.

◆ escape() [2/2]

char escape ( void  ) const
inline

Get the escape character.

Returns
Escape character.

◆ format()

int 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 Formatter::CONTINUE, Formatter::DONE, InStream::ENDED, InStream::FAILED, Formatter::process(), and Formatter::REJECT.

◆ process()

int 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 Formatter::format().

Member Data Documentation

◆ CONTINUE

const int CONTINUE = 1
staticprotected

Referenced by Formatter::format().

◆ DONE

const int DONE = 0
staticprotected

Referenced by Formatter::format().

◆ REJECT

const int REJECT = 2
staticprotected

Referenced by Formatter::format().


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