CppParser
Loading...
Searching...
No Matches
CppWriter Class Reference

Responsible for emitting C/C++ source from CppAst data structure. More...

#include <cppwriter.h>

Collaboration diagram for CppWriter:
Collaboration graph

Public Types

enum  EmittingType { kRaw , kHeader , kSource }
 

Public Member Functions

 CppWriter ()
 
void setEmittingType (EmittingType type)
 
EmittingType getEmittingType () const
 
virtual void emit (CppObj *cppObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitVar (CppVar *varObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitVarList (CppVarList *varListObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitEnum (CppEnum *enmObj, std::ostream &stm, bool emitNewLine, CppIndent indentation=CppIndent()) const
 
virtual void emitTypedef (CppTypedefName *typedefName, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitUsingDecl (CppUsingDecl *usingDecl, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitTypedefList (CppTypedefList *typedefList, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitFwdDecl (CppFwdClsDecl *fwdClsDeclObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitMacroCall (CppMacroCall *macroCallObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitCompound (CppCompound *compoundObj, std::ostream &stm, CppIndent indentation=CppIndent(), bool emitNewLine=true) const
 
virtual void emitFunction (CppFunction *funcObj, std::ostream &stm, bool emitNewLine, CppIndent indentation=CppIndent()) const
 
virtual void emitFunctionPtr (CppFunctionPointer *funcPtrObj, std::ostream &stm, bool emitNewLine, CppIndent indentation=CppIndent()) const
 
virtual void emitConstructor (CppConstructor *ctorObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitDestructor (CppDestructor *dtorObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitTypeConverter (CppTypeConverter *typeConverterObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitDocComment (CppDocComment *docCommentObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitExpr (CppExpr *exprObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitDefine (CppDefine *defineObj, std::ostream &stm) const
 
virtual void emitUndef (CppUndef *undefObj, std::ostream &stm) const
 
virtual void emitInclude (CppInclude *includeObj, std::ostream &stm) const
 
virtual void emitHashIf (CppHashIf *hashIfObj, std::ostream &stm) const
 
virtual void emitHashIf (CppHashIf::CondType condType, const std::string &cond, std::ostream &stm) const
 
virtual void emitEndIf (std::ostream &stm) const
 
virtual void emitPragma (CppPragma *pragmaObj, std::ostream &stm) const
 
virtual void emitBlob (CppBlob *blobObj, std::ostream &stm, bool formatLineStarts, CppIndent indentation) const
 
virtual void emitVarType (CppVarType *varTypeObj, std::ostream &stm) const
 
virtual void emitParamList (CppParamVector *paramListObj, std::ostream &stm) const
 
virtual void emitExprAtom (CppExprAtom &exprObj, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitIfBlock (CppIfBlock *ifBlock, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitWhileBlock (CppWhileBlock *whileBlock, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitDoBlock (CppDoWhileBlock *doBlock, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitForBlock (CppForBlock *forBlock, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
virtual void emitSwitchBlock (CppSwitchBlock *switchBlock, std::ostream &stm, CppIndent indentation=CppIndent()) const
 
void emitVar (CppVar *varObj, std::ostream &stm, bool skipName) const
 
void emitParamList (CppParamVector *paramListObj, std::ostream &stm, bool skipName) const
 
void emitFunctionPtr (CppFunctionPointer *funcPtrObj, std::ostream &stm, bool skipName, bool emitNewLine) const
 
void emitFunction (CppFunction *funcObj, std::ostream &stm, bool skipParamName, bool emitNewLine) const
 
void emitConstructor (CppConstructor *ctorObj, std::ostream &stm, bool skipParamName) const
 
void emitTemplSpec (CppTemplateParamList *templSpec, std::ostream &stm, CppIndent indentation) const
 

Private Member Functions

void emit (CppObj *cppObj, std::ostream &stm, CppIndent indentation, bool noNewLine) const
 
void emitVar (CppVar *varObj, std::ostream &stm, CppIndent indentation, bool skipName) const
 
void emitFunctionPtr (CppFunctionPointer *funcPtrObj, std::ostream &stm, CppIndent indentation, bool skipName, bool emitNewLine) const
 
void emitFunction (CppFunction *funcObj, std::ostream &stm, CppIndent indentation, bool skipName, bool skipParamName, bool emitNewLine) const
 
void emitConstructor (CppConstructor *ctorObj, std::ostream &stm, CppIndent indentation, bool skipParamName) const
 
void emitVarDecl (std::ostream &stm, CppVarDecl &varDecl, bool skipName) const
 

Private Attributes

CppIndent preproIndent_
 
EmittingType emittingType_
 

Detailed Description

Responsible for emitting C/C++ source from CppAst data structure.

Implementation of emitting various C/C++ objects should never change the style of code generated. Addition of new functionality and bug fixes are allowed but care must be taken not to change the style of emitted code.

Definition at line 39 of file cppwriter.h.

Member Enumeration Documentation

◆ EmittingType

Enumerator
kRaw 

No intelligence is applied and things are emitted as is.

kHeader 

No function definition is emitted unless it is explicitly inline.

kSource 

No method declaration is emitted unless it is part of the class that is defined in the same file.

Definition at line 44 of file cppwriter.h.

Constructor & Destructor Documentation

◆ CppWriter()

CppWriter::CppWriter ( )
inline

Definition at line 163 of file cppwriter.h.

Member Function Documentation

◆ emit() [1/2]

void CppWriter::emit ( CppObj cppObj,
std::ostream &  stm,
CppIndent  indentation,
bool  noNewLine 
) const
private

Definition at line 75 of file cppwriter.cpp.

Here is the call graph for this function:

◆ emit() [2/2]

void CppWriter::emit ( CppObj cppObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 70 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitBlob()

void CppWriter::emitBlob ( CppBlob blobObj,
std::ostream &  stm,
bool  formatLineStarts,
CppIndent  indentation 
) const
virtual

Definition at line 226 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitCompound()

void CppWriter::emitCompound ( CppCompound compoundObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent(),
bool  emitNewLine = true 
) const
virtual

Definition at line 473 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitConstructor() [1/3]

void CppWriter::emitConstructor ( CppConstructor ctorObj,
std::ostream &  stm,
bool  skipParamName 
) const
inline

Definition at line 201 of file cppwriter.h.

Here is the call graph for this function:

◆ emitConstructor() [2/3]

void CppWriter::emitConstructor ( CppConstructor ctorObj,
std::ostream &  stm,
CppIndent  indentation,
bool  skipParamName 
) const
private

Definition at line 668 of file cppwriter.cpp.

Here is the call graph for this function:

◆ emitConstructor() [3/3]

void CppWriter::emitConstructor ( CppConstructor ctorObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 726 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitDefine()

void CppWriter::emitDefine ( CppDefine defineObj,
std::ostream &  stm 
) const
virtual

Definition at line 150 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitDestructor()

void CppWriter::emitDestructor ( CppDestructor dtorObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 731 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitDoBlock()

void CppWriter::emitDoBlock ( CppDoWhileBlock doBlock,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 1104 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitDocComment()

void CppWriter::emitDocComment ( CppDocComment docCommentObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 786 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitEndIf()

void CppWriter::emitEndIf ( std::ostream &  stm) const
virtual

Definition at line 181 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitEnum()

void CppWriter::emitEnum ( CppEnum enmObj,
std::ostream &  stm,
bool  emitNewLine,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 334 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitExpr()

void CppWriter::emitExpr ( CppExpr exprObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 946 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitExprAtom()

void CppWriter::emitExprAtom ( CppExprAtom exprObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 928 of file cppwriter.cpp.

◆ emitForBlock()

void CppWriter::emitForBlock ( CppForBlock forBlock,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 1117 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitFunction() [1/3]

void CppWriter::emitFunction ( CppFunction funcObj,
std::ostream &  stm,
bool  emitNewLine,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 653 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitFunction() [2/3]

void CppWriter::emitFunction ( CppFunction funcObj,
std::ostream &  stm,
bool  skipParamName,
bool  emitNewLine 
) const
inline

Definition at line 193 of file cppwriter.h.

Here is the call graph for this function:

◆ emitFunction() [3/3]

void CppWriter::emitFunction ( CppFunction funcObj,
std::ostream &  stm,
CppIndent  indentation,
bool  skipName,
bool  skipParamName,
bool  emitNewLine 
) const
private

Definition at line 564 of file cppwriter.cpp.

Here is the call graph for this function:

◆ emitFunctionPtr() [1/3]

void CppWriter::emitFunctionPtr ( CppFunctionPointer funcPtrObj,
std::ostream &  stm,
bool  emitNewLine,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 658 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitFunctionPtr() [2/3]

void CppWriter::emitFunctionPtr ( CppFunctionPointer funcPtrObj,
std::ostream &  stm,
bool  skipName,
bool  emitNewLine 
) const
inline

Definition at line 183 of file cppwriter.h.

Here is the call graph for this function:

◆ emitFunctionPtr() [3/3]

void CppWriter::emitFunctionPtr ( CppFunctionPointer funcPtrObj,
std::ostream &  stm,
CppIndent  indentation,
bool  skipName,
bool  emitNewLine 
) const
private

◆ emitFwdDecl()

void CppWriter::emitFwdDecl ( CppFwdClsDecl fwdClsDeclObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 417 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitHashIf() [1/2]

void CppWriter::emitHashIf ( CppHashIf hashIfObj,
std::ostream &  stm 
) const
virtual

Definition at line 176 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitHashIf() [2/2]

void CppWriter::emitHashIf ( CppHashIf::CondType  condType,
const std::string &  cond,
std::ostream &  stm 
) const
virtual

Definition at line 186 of file cppwriter.cpp.

Here is the call graph for this function:

◆ emitIfBlock()

void CppWriter::emitIfBlock ( CppIfBlock ifBlock,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 1067 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitInclude()

void CppWriter::emitInclude ( CppInclude includeObj,
std::ostream &  stm 
) const
virtual

Definition at line 172 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitMacroCall()

void CppWriter::emitMacroCall ( CppMacroCall macroCallObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 433 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitParamList() [1/2]

void CppWriter::emitParamList ( CppParamVector paramListObj,
std::ostream &  stm 
) const
virtual

Definition at line 538 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitParamList() [2/2]

void CppWriter::emitParamList ( CppParamVector paramListObj,
std::ostream &  stm,
bool  skipName 
) const

Definition at line 543 of file cppwriter.cpp.

Here is the call graph for this function:

◆ emitPragma()

void CppWriter::emitPragma ( CppPragma pragmaObj,
std::ostream &  stm 
) const
virtual

Definition at line 221 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitSwitchBlock()

void CppWriter::emitSwitchBlock ( CppSwitchBlock switchBlock,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 1143 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitTemplSpec()

void CppWriter::emitTemplSpec ( CppTemplateParamList templSpec,
std::ostream &  stm,
CppIndent  indentation 
) const

Definition at line 440 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitTypeConverter()

void CppWriter::emitTypeConverter ( CppTypeConverter typeConverterObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 760 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitTypedef()

void CppWriter::emitTypedef ( CppTypedefName typedefName,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 385 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitTypedefList()

void CppWriter::emitTypedefList ( CppTypedefList typedefList,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 409 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitUndef()

void CppWriter::emitUndef ( CppUndef undefObj,
std::ostream &  stm 
) const
virtual

Definition at line 167 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ emitUsingDecl()

void CppWriter::emitUsingDecl ( CppUsingDecl usingDecl,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 394 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitVar() [1/3]

void CppWriter::emitVar ( CppVar varObj,
std::ostream &  stm,
bool  skipName 
) const
inline

Definition at line 178 of file cppwriter.h.

Here is the call graph for this function:

◆ emitVar() [2/3]

void CppWriter::emitVar ( CppVar varObj,
std::ostream &  stm,
CppIndent  indentation,
bool  skipName 
) const
private

Definition at line 306 of file cppwriter.cpp.

Here is the call graph for this function:

◆ emitVar() [3/3]

void CppWriter::emitVar ( CppVar varObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 267 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitVarDecl()

void CppWriter::emitVarDecl ( std::ostream &  stm,
CppVarDecl varDecl,
bool  skipName 
) const
private

Definition at line 274 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitVarList()

void CppWriter::emitVarList ( CppVarList varListObj,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 319 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitVarType()

void CppWriter::emitVarType ( CppVarType varTypeObj,
std::ostream &  stm 
) const
virtual

Definition at line 251 of file cppwriter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitWhileBlock()

void CppWriter::emitWhileBlock ( CppWhileBlock whileBlock,
std::ostream &  stm,
CppIndent  indentation = CppIndent() 
) const
virtual

Definition at line 1090 of file cppwriter.cpp.

Here is the caller graph for this function:

◆ getEmittingType()

CppWriter::EmittingType CppWriter::getEmittingType ( ) const
inline

Definition at line 173 of file cppwriter.h.

Here is the caller graph for this function:

◆ setEmittingType()

void CppWriter::setEmittingType ( EmittingType  type)
inline

Definition at line 168 of file cppwriter.h.

Member Data Documentation

◆ emittingType_

EmittingType CppWriter::emittingType_
private

Definition at line 160 of file cppwriter.h.

◆ preproIndent_

CppIndent CppWriter::preproIndent_
mutableprivate

Definition at line 158 of file cppwriter.h.


The documentation for this class was generated from the following files: