Poco::CodeGeneration

class GeneratorEngine

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

GeneratorEngine();

Creates the GeneratorEngine.

Destructor

~GeneratorEngine

~GeneratorEngine();

Destroys the GeneratorEngine.

Member Functions

emptyCodeGen static

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

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

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

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

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

static void handleIncludes(
    const Poco::CppParser::Struct * pStruct,
    CodeGenerator & gen
);

Detects and handles all includes.

parseElementProperties static

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

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 inline

void registerDefaultCallback(
    MethodGenerator funcGen
);

Registers a default callback, invoked always when no callback is found for a given methodname

registerPostClassCallback inline

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 inline

void registerPostNameSpaceCallback(
    MethodGenerator funcGen
);

Allows to register a code generator that will write code to the implementation file after the namespace was closed.

registerPreClassCallback inline

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 inline

void registerPreNameSpaceCallback(
    MethodGenerator funcGen
);

Allows to register a code generator that will write code to the implementation file before the namespace is opened.

unregisterCallback inline

void unregisterCallback(
    const std::string & methodName
);

Unregisters a callback.

unregisterDefaultCallback inline

void unregisterDefaultCallback();

Unregisters the default callback.

unregisterPostClassCallback inline

void unregisterPostClassCallback();

Unregisters the post class callback.

unregisterPostNameSpaceCallback inline

void unregisterPostNameSpaceCallback();

Unregisters the post namespace callback.

unregisterPreClassCallback inline

void unregisterPreClassCallback();

Unregisters the pre class callback.

unregisterPreNameSpaceCallback inline

void unregisterPreNameSpaceCallback();

Unregisters the pre namespace callback.

Securely control IoT edge devices from anywhere   Connect a Device