Source-highlight Library
srchilite::CharTranslator Class Reference

Translates specific character sequences into corresponding ones; it can also use regular expression for the characters to be translated. More...

#include <chartranslator.h>

Inheritance diagram for srchilite::CharTranslator:
Collaboration diagram for srchilite::CharTranslator:

Public Member Functions

 CharTranslator (PreFormatterPtr f=PreFormatterPtr())
void set_translation (const std::string &s1, const std::string &s2)
 Adds a translation pair.
const std::string toString () const
 returns a string representation: what we translate and into what we translate
void setPreFormatter (PreFormatterPtr f)
 Sets the nested preformatter.
const std::string preformat (const std::string &text)
 Preformats the passed string (public version).

Protected Member Functions

virtual const std::string doPreformat (const std::string &text)
 The actual preformatting (char translation).

Protected Attributes

unsigned int counter
 keeps track of the translation patterns added
std::string translation_exp
 the translation regular expression (for buffering)
std::string translation_format
 the corresponding translated regular expression (for buffering)
boost::regex * reg_exp
 the actual regular expression
bool bol
 whether we are at the beginning of a new line

Private Attributes

PreFormatterPtr decorator
 the possible nested preformatter (Decorator pattern)

Detailed Description

Translates specific character sequences into corresponding ones; it can also use regular expression for the characters to be translated.

This is useful for translating some characters in the input which are special characters in the output formats, e.g., & in LaTeX, or < in HTML.

Constructor & Destructor Documentation

◆ CharTranslator()

srchilite::CharTranslator::CharTranslator ( PreFormatterPtr f = PreFormatterPtr())
Parameters
fthe decorated preformatter

Member Function Documentation

◆ doPreformat()

const string srchilite::CharTranslator::doPreformat ( const std::string & text)
protectedvirtual

The actual preformatting (char translation).

Parameters
textwhat to translate
Returns
the translated string

Reimplemented from srchilite::PreFormatter.

◆ preformat()

const string srchilite::PreFormatter::preformat ( const std::string & text)
inherited

Preformats the passed string (public version).

Parameters
textthe string to be preformatted
Returns
the preformatted string

◆ set_translation()

void srchilite::CharTranslator::set_translation ( const std::string & s1,
const std::string & s2 )

Adds a translation pair.

Parameters
s1what to translate
s2the translated expression

◆ setPreFormatter()

void srchilite::PreFormatter::setPreFormatter ( PreFormatterPtr f)
inherited

Sets the nested preformatter.

Parameters
fthe nested (decorated) preformatter

The documentation for this class was generated from the following files:
  • /cygdrive/d/a/scallywag/source-highlight/source-highlight-3.1.9-1.x86_64/src/source-highlight-3.1.9/lib/srchilite/chartranslator.h
  • /cygdrive/d/a/scallywag/source-highlight/source-highlight-3.1.9-1.x86_64/src/source-highlight-3.1.9/lib/srchilite/chartranslator.cc