Poco::CodeGeneration

class CodeGenerator

File Information

Library: CodeGeneration
Package: CodeGeneration
Header: Poco/CodeGeneration/CodeGenerator.h

Description

A CodeGenerator defines an interface for code generators.

Inheritance

Known Derived Classes: CppGenerator, MethodPropertyFilter

Member Summary

Member Functions: addFwdDecl, addIncludeFile, addSrcIncludeFile, addSystemIncludeFile, copyright, endFile, includes, libraryName, methodEnd, methodStart, nameSpace, structEnd, structStart, systemIncludes, usePocoIncludeStyle, variable, variablesEnd, variablesStart, writeDefaultHeader, writeFwdDecls, writeImplementation, writeInclude, writeIncludes, writeMethodImplementation, writeNameSpaceBegin, writeNameSpaceEnd, writeSystemInclude, writeTypeDef, writeUsing

Nested Classes

struct FwdDecl

 

Types

FwdDecls

typedef std::set < FwdDecl > FwdDecls;

IncludeSet

typedef std::set < std::string > IncludeSet;

Properties

typedef std::map < std::string, std::string > Properties;

Maps a property name to its value.

Constructors

CodeGenerator

CodeGenerator(
    const std::string & nameSpace,
    const std::string & libraryName,
    bool usePocoIncludeStyle,
    const std::string & copyright
);

Creates the CodeGenerator. The nameSpace declares in which nameSpace the generated class will be, the library name contaisn the name of the project

Destructor

~CodeGenerator virtual

virtual ~CodeGenerator();

Destroys the CodeGenerator.

Member Functions

addFwdDecl virtual

virtual void addFwdDecl(
    const std::string & inclFile,
    const std::string & className,
    const std::string namespacePrefix
);

Adds a fwd decl.

addIncludeFile virtual inline

virtual void addIncludeFile(
    const std::string & incFile
);

Adds an include file to the CodeGenerator. A call to this method is only meaningful until structStart was not called. Duplicate includes will be ignored. Contains the include path only, e.g. "include/MyClass.h" (without enclosing ")

addSrcIncludeFile virtual inline

virtual void addSrcIncludeFile(
    const std::string & incFile
);

Include file which will be written to an implementation file.

addSystemIncludeFile virtual inline

virtual void addSystemIncludeFile(
    const std::string & incFile
);

Adds a system include file

copyright virtual inline

virtual const std::string & copyright() const;

Returns the copyright notice, can be empty.

endFile virtual

virtual void endFile() = 0;

Closes the file.

includes virtual inline

virtual const CodeGenerator::IncludeSet & includes() const;

Returns all includes that the CodeGenerator consists of.

libraryName virtual inline

virtual const std::string & libraryName() const;

The prefix assigned to the namespace.

methodEnd virtual

virtual void methodEnd(
    const Poco::CppParser::Function * pFunc,
    const CodeGenerator::Properties & properties
) = 0;

Closes the method.

methodStart virtual

virtual void methodStart(
    const Poco::CppParser::Function * pFunc,
    const CodeGenerator::Properties & properties
) = 0;

Writes the method header. Properties contains the properties found in the functions docuementation and in the class documentation.

nameSpace virtual inline

virtual const std::string & nameSpace() const;

The namespace of the file

structEnd virtual

virtual void structEnd() = 0;

Closes the class declaration.

structStart virtual

virtual void structStart(
    const Poco::CppParser::Struct * pStruct,
    const CodeGenerator::Properties & properties
) = 0;

Writes the class declaration.

systemIncludes virtual inline

virtual const CodeGenerator::IncludeSet & systemIncludes() const;

Returns all system includes that the CodeGenerator consists of.

usePocoIncludeStyle virtual inline

virtual bool usePocoIncludeStyle() const;

Returns which include style should be used

variable virtual

virtual void variable(
    const Poco::CppParser::Variable * pVar
) = 0;

Writes a single variable.

variablesEnd virtual

virtual void variablesEnd() = 0;

Ends variable definitions.

variablesStart virtual

virtual void variablesStart() = 0;

Indicates that variables wil be written.

writeDefaultHeader virtual

virtual void writeDefaultHeader(
    const Poco::CppParser::Struct * pStruct,
    const std::string & className,
    const std::string & libraryName,
    const std::string & package
) = 0;

Writes the default header, e.g. copyright notice, no include namespace open or anything else is written This is always the first method that is called!

writeFwdDecls virtual

virtual void writeFwdDecls(
    const FwdDecls & decl
) = 0;

Writes the fwd decl to the header file and the include file to the src file.

writeImplementation virtual

virtual void writeImplementation(
    const std::string & code
) = 0;

Writes other non-method code.

writeInclude virtual

virtual void writeInclude(
    const std::string & include,
    bool toHeader
) = 0;

Writes the include either to the header or the src file.

writeIncludes virtual

virtual void writeIncludes();

Convenience Functions which calls for all include files writeInclude, also writes fwdDecls.

writeMethodImplementation virtual

virtual void writeMethodImplementation(
    const std::string & code
) = 0;

Only valid when inside a method. Simply forwards the code lines to the implementation file.

writeNameSpaceBegin virtual

virtual void writeNameSpaceBegin(
    const std::string & fullNameSpace
) = 0;

Writes the enclosing namespace

writeNameSpaceEnd virtual

virtual void writeNameSpaceEnd(
    const std::string & fullNameSpace
) = 0;

Closes the namespace

writeSystemInclude virtual

virtual void writeSystemInclude(
    const std::string & include
) = 0;

Writes the system include file to the header.

writeTypeDef virtual

virtual void writeTypeDef(
    const Poco::CppParser::TypeDef * pType
) = 0;

Writes a single typedef

writeUsing virtual

virtual void writeUsing(
    const Poco::CppParser::TypeAlias * pType
) = 0;

Writes a single using

Securely control IoT edge devices from anywhere   Connect a Device