Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

mpcl::text::codegen::TPatternBasedCodeGenerator Class Reference

#include <pattern_based_code_generator.hh>

Inheritance diagram for mpcl::text::codegen::TPatternBasedCodeGenerator:

List of all members.

Public Methods

 TPatternBasedCodeGenerator (const TString &rkySOURCE_CDML_FILE, const TString &rkyCDML_PATH)
 TPatternBasedCodeGenerator (void)
 Builds a new instance without loading any CDML document.

void clear (void)
 Resets values removing all instructions.

void clearCode (void)
 Clears code from all clauses.

void compile (void)
void loadFrom (const TString &rkySOURCE_CDML_FILE)
void preprocessVariables (void)
void setDescription (const char *pkcSOURCE_DESCRIPTION)
void setCdmlPath (const TString &rkyCDML_PATH)
const TStringToVariableMapvariables (void) const
bool existsVariable (const char *pkcVARIABLE_NAME) const
const TInstructionBodyoperator[] (const char *pkcINSTRUCTION_NAME) const
TInstructionBodyoperator[] (const char *pkcINSTRUCTION_NAME)

Protected Methods

void initConstants (void) const
 Initializes pattern-length constants if needed.

void inheritFrom (const TString &rkySOURCE_CDML_FILE)
void read (std::basic_istream< char_type, traits_type > &rtSOURCE_STREAM)
void write (std::basic_ostream< char_type, traits_type > &rtTARGET_OSTREAM) const

Detailed Description

Pattern-based code generator.

As its name says, its function is, given a CDML file, an instruction name, and a clause name, it generates the corresponding code.

CDML (Code Description Mark-up Language) is a language that defines a matter of generating parameterizable code. Each CDML file can inherit from another CDML file (just one), but this means that only instructions/clauses that already stand in father CDML file, can be (re)defined. Variables can't contain other variable tags.

Warning:
The string "::" isn't permitted in clause names, because it is used for name mangling.

Definition at line 70 of file pattern_based_code_generator.hh.


Constructor & Destructor Documentation

mpcl::text::codegen::TPatternBasedCodeGenerator::TPatternBasedCodeGenerator const TString   rkySOURCE_CDML_FILE,
const TString   rkyCDML_PATH
 

Builds a new instance from a CDML file.

Parameters:
rkySOURCE_CDML_FILE  Source CDML file name.
rkyCDML_PATH  This string musts be a colon separated paths string, like "dir1/dir2:dir3/dir4". Where symbol '/' must be changed for each platform.

Definition at line 37 of file pattern_based_code_generator.cc.

References initConstants(), loadFrom(), and mpcl::text::TString.


Member Function Documentation

void mpcl::text::codegen::TPatternBasedCodeGenerator::compile void   
 

Makes the CDML file to inherit from no other CDML file. It really only empties yInherit value and makes substitutions of entity '&eoc;'.

Definition at line 148 of file pattern_based_code_generator.cc.

bool mpcl::text::codegen::TPatternBasedCodeGenerator::existsVariable const char *    pkcVARIABLE_NAME const
 

Returns true if there is a variable named pkcVARIABLE_NAME.

Parameters:
pkcVARIABLE_NAME  Name of the variable.
Returns:
True if there is a variable named pkcVARIABLE_NAME.

void mpcl::text::codegen::TPatternBasedCodeGenerator::inheritFrom const TString   rkySOURCE_CDML_FILE [protected]
 

Inherits from another CDML file.

Parameters:
pkcSOURCE_CDML_FILE  Source CDML file name.
Warning:
If the file pkcSOURCE_CDML_FILE is the same as ours, a loop will happen.

Definition at line 264 of file pattern_based_code_generator.cc.

References loadFrom(), and mpcl::text::TString.

Referenced by read().

void mpcl::text::codegen::TPatternBasedCodeGenerator::loadFrom const TString   rkySOURCE_CDML_FILE
 

Loads a CDML file.

Parameters:
rkySOURCE_CDML_FILE  Source file name.
Exceptions:
TExceptionPBCG_FileNotFound  If file isn't found.

Definition at line 92 of file pattern_based_code_generator.cc.

References mpcl::text::Format(), read(), and mpcl::text::TString.

Referenced by inheritFrom(), and TPatternBasedCodeGenerator().

TInstructionBody& mpcl::text::codegen::TPatternBasedCodeGenerator::operator[] const char *    pkcINSTRUCTION_NAME [inline]
 

Gets the instruction body corresponding to instruction pkcINSTRUCTION_NAME. This member function is a synonym of instruction().

Parameters:
pkcINSTRUCTION_NAME  Instruction name.
Returns:
The instruction body.

Definition at line 250 of file pattern_based_code_generator.hh.

const TInstructionBody& mpcl::text::codegen::TPatternBasedCodeGenerator::operator[] const char *    pkcINSTRUCTION_NAME const [inline]
 

Gets the instruction body corresponding to instruction pkcINSTRUCTION_NAME. This member function is a synonym of instruction().

Parameters:
pkcINSTRUCTION_NAME  Instruction name.
Returns:
The instruction body.

Definition at line 238 of file pattern_based_code_generator.hh.

void mpcl::text::codegen::TPatternBasedCodeGenerator::preprocessVariables void   
 

Preprocess entities on variables.

Definition at line 205 of file pattern_based_code_generator.cc.

References mpcl::text::codegen::InstantiateEntities().

void mpcl::text::codegen::TPatternBasedCodeGenerator::read std::basic_istream< char_type, traits_type > &    rtSOURCE_STREAM [protected]
 

Loads the instance from stream rtSOURCE_ISTREAM.

Parameters:
rtSOURCE_ISTREAM  Source stream.

Definition at line 283 of file pattern_based_code_generator.cc.

References mpcl::text::Format(), mpcl::text::codegen::TClauseTagString::hasTarget(), inheritFrom(), mpcl::text::codegen::TClauseTagString::overloadFrom(), and mpcl::text::TString.

Referenced by loadFrom().

void mpcl::text::codegen::TPatternBasedCodeGenerator::setCdmlPath const TString   rkyCDML_PATH
 

Sets path for loading CDML files.

Parameters:
rkyCDML_PATH  This string must be a colon separated paths string, like "dir1/dir2:dir3/dir4". Where '/' must be changed for every platform.

Definition at line 229 of file pattern_based_code_generator.cc.

References mpcl::text::TString.

void mpcl::text::codegen::TPatternBasedCodeGenerator::setDescription const char *    pkcSOURCE_DESCRIPTION
 

Updates attribute yDescription.

Parameters:
pkcSOURCE_DESCRIPTION  Source description string.

Definition at line 220 of file pattern_based_code_generator.cc.

const mpcl::text::codegen::TStringToVariableMap & mpcl::text::codegen::TPatternBasedCodeGenerator::variables void    const
 

Gets the variable map.

Returns:
The variable map.
See also:
TStringToVariableMap.

Definition at line 655 of file pattern_based_code_generator.cc.

void mpcl::text::codegen::TPatternBasedCodeGenerator::write std::basic_ostream< char_type, traits_type > &    rtTARGET_OSTREAM const [protected]
 

Writes the instance onto stream rtTARGET_OSTREAM.

Parameters:
rtTARGET_OSTREAM  Target output stream.

Definition at line 735 of file pattern_based_code_generator.cc.


The documentation for this class was generated from the following files:
Generated on Mon Oct 13 02:35:26 2003 for MPCL by doxygen1.2.18