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 ~CodeGenerator();
Destroys the CodeGenerator.
Member Functions
addFwdDecl
virtual void addFwdDecl(
const std::string & inclFile,
const std::string & className,
const std::string namespacePrefix
);
Adds a fwd decl.
addIncludeFile
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 void addSrcIncludeFile(
const std::string & incFile
);
Include file which will be written to an implementation file.
addSystemIncludeFile
virtual void addSystemIncludeFile(
const std::string & incFile
);
Adds a system include file
copyright
virtual const std::string & copyright() const;
Returns the copyright notice, can be empty.
endFile
virtual void endFile() = 0;
Closes the file.
includes
virtual const CodeGenerator::IncludeSet & includes() const;
Returns all includes that the CodeGenerator consists of.
libraryName
virtual const std::string & libraryName() const;
The prefix assigned to the namespace.
methodEnd
virtual void methodEnd(
const Poco::CppParser::Function * pFunc,
const CodeGenerator::Properties & properties
) = 0;
Closes the method.
methodStart
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 const std::string & nameSpace() const;
The namespace of the file
structEnd
virtual void structEnd() = 0;
Closes the class declaration.
structStart
virtual void structStart(
const Poco::CppParser::Struct * pStruct,
const CodeGenerator::Properties & properties
) = 0;
Writes the class declaration.
systemIncludes
virtual const CodeGenerator::IncludeSet & systemIncludes() const;
Returns all system includes that the CodeGenerator consists of.
usePocoIncludeStyle
virtual bool usePocoIncludeStyle() const;
Returns which include style should be used
variable
virtual void variable(
const Poco::CppParser::Variable * pVar
) = 0;
Writes a single variable.
variablesEnd
virtual void variablesEnd() = 0;
Ends variable definitions.
variablesStart
virtual void variablesStart() = 0;
Indicates that variables wil be written.
writeDefaultHeader
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 void writeFwdDecls(
const FwdDecls & decl
) = 0;
Writes the fwd decl to the header file and the include file to the src file.
writeImplementation
virtual void writeImplementation(
const std::string & code
) = 0;
Writes other non-method code.
writeInclude
virtual void writeInclude(
const std::string & include,
bool toHeader
) = 0;
Writes the include either to the header or the src file.
writeIncludes
virtual void writeIncludes();
Convenience Functions which calls for all include files writeInclude, also writes fwdDecls.
writeMethodImplementation
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 void writeNameSpaceBegin(
const std::string & fullNameSpace
) = 0;
Writes the enclosing namespace
writeNameSpaceEnd
virtual void writeNameSpaceEnd(
const std::string & fullNameSpace
) = 0;
Closes the namespace
writeSystemInclude
virtual void writeSystemInclude(
const std::string & include
) = 0;
Writes the system include file to the header.
writeTypeDef
virtual void writeTypeDef(
const Poco::CppParser::TypeDef * pType
) = 0;
Writes a single typedef
writeUsing
virtual void writeUsing(
const Poco::CppParser::TypeAlias * pType
) = 0;
Writes a single using