File Information
Library: CodeGeneration
Package: CodeGeneration
Header: Poco/CodeGeneration/GeneratorEngine.h
Description
A GeneratorEngine iterates over a Struct and calls the correct methods in a CodeGenerator.
Member Summary
Member Functions: emptyCodeGen, generate, getBoolProperty, getStringProperty, getUInt32Property, handleIncludeFile, handleIncludes, parseElementProperties, parseProperties, registerCallback, registerDefaultCallback, registerPostClassCallback, registerPostNameSpaceCallback, registerPreClassCallback, registerPreNameSpaceCallback, unregisterCallback, unregisterDefaultCallback, unregisterPostClassCallback, unregisterPostNameSpaceCallback, unregisterPreClassCallback, unregisterPreNameSpaceCallback
Types
Callbacks
typedef std::map < std::string, MethodGenerator > Callbacks;
MethodGenerator
typedef void (* MethodGenerator)(const Poco::CppParser::Function *, const Poco::CppParser::Struct *, CodeGenerator &, void * param);
Constructors
GeneratorEngine
Creates the GeneratorEngine.
Destructor
~GeneratorEngine
~GeneratorEngine();
Destroys the GeneratorEngine.
Member Functions
emptyCodeGen
static void emptyCodeGen(
const Poco::CppParser::Function * param86,
const Poco::CppParser::Struct * param87,
CodeGenerator & param88,
void * param
);
generate
void generate(
const Poco::CppParser::Struct * pStruct,
CodeGenerator & gen,
void * addParam = 0,
bool isFirstClass = true,
bool isLastClass = true
);
Generates code for the given struct using the given CodeGenerator, addParam can be used to provide a pointer to additional information, required for the registered callbacks. If isFirstClass is true, the copyright header and the namespace begin is written, if isLastClass is true the namespace is closed.
getBoolProperty
static bool getBoolProperty(
const CodeGenerator::Properties & props,
const std::string & propName,
bool & value
);
Returns true if it finds for the given property name the attrValue, writes the found value to parameter value.
getStringProperty
static bool getStringProperty(
const CodeGenerator::Properties & props,
const std::string & propName,
std::string & value
);
Returns true if it finds for the given property name the attrValue, writes the found value to parameter value.
getUInt32Property
static bool getUInt32Property(
const CodeGenerator::Properties & props,
const std::string & propName,
Poco::UInt32 & value
);
Returns true if it finds for the given property name the attrValue, writes the found value to parameter value.
handleIncludeFile
static void handleIncludeFile(
const Poco::CppParser::Struct * pStruct,
const std::string & classDecl,
const std::string & defaultLibrary,
CodeGenerator & gen
);
Checks first the file in pStruct, then regenerates the include based on the classDecl
handleIncludes
static void handleIncludes(
const Poco::CppParser::Struct * pStruct,
CodeGenerator & gen
);
Detects and handles all includes.
parseElementProperties
static void parseElementProperties(
const std::string & elemVal,
CodeGenerator::Properties & props
);
Parses and adds element properties in lower case to props. Element properties are properties defined for single parameters or variables
parseProperties
static void parseProperties(
const Poco::CppParser::Symbol * pSym,
CodeGenerator::Properties & props
);
Parses and adds properties in lower case to props.
registerCallback
void registerCallback(
const std::string & methodName,
MethodGenerator funcGen
);
Registers a callback for a method name if and only if no other callback is registered yet. Throws an exception in the latter case.
registerDefaultCallback
void registerDefaultCallback(
MethodGenerator funcGen
);
Registers a default callback, invoked always when no callback is found for a given methodname
registerPostClassCallback
void registerPostClassCallback(
MethodGenerator funcGen
);
Allows to register a code generator that will write code to the implementation file after the last method was written. Useful to initialize static members.
registerPostNameSpaceCallback
void registerPostNameSpaceCallback(
MethodGenerator funcGen
);
Allows to register a code generator that will write code to the implementation file after the namespace was closed.
registerPreClassCallback
void registerPreClassCallback(
MethodGenerator funcGen
);
Allows to register a code generator that will write code to the implementation file before the first constructor is written. Useful to initialize static members. With templates the code will be written right after namespace_begin.
registerPreNameSpaceCallback
void registerPreNameSpaceCallback(
MethodGenerator funcGen
);
Allows to register a code generator that will write code to the implementation file before the namespace is opened.
unregisterCallback
void unregisterCallback(
const std::string & methodName
);
Unregisters a callback.
unregisterDefaultCallback
void unregisterDefaultCallback();
Unregisters the default callback.
unregisterPostClassCallback
void unregisterPostClassCallback();
Unregisters the post class callback.
unregisterPostNameSpaceCallback
void unregisterPostNameSpaceCallback();
Unregisters the post namespace callback.
unregisterPreClassCallback
void unregisterPreClassCallback();
Unregisters the pre class callback.
unregisterPreNameSpaceCallback
void unregisterPreNameSpaceCallback();
Unregisters the pre namespace callback.