PhoenixGenerator  3.4.0
Generate code from template files and projects in C++, Rust, Python and wrapped C++ to Python
Loading...
Searching...
No Matches
CppTraitTypeStream Class Reference

Class generator for setter trait. More...

#include <CppTraitTypeStream.h>

Inheritance diagram for CppTraitTypeStream:
Collaboration diagram for CppTraitTypeStream:

Public Member Functions

virtual void classExtraFunctionDeclaration (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Declaration of extra functions.
virtual void classExtraFunctionImplementation (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Implementation of extra functions.
 CppTraitTypeStream ()
 Consctructor of CppTraitTypeStream.
virtual void headerExtraInclude (std::ofstream &fs, const GeneratorMode &mode) const
 Add extra include on the header.
virtual void privateMethodDeclaration (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Declaration of private methods.
virtual void privateMethodImplementation (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Implementation of private methods.
virtual void protectedMethodDeclaration (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Declaration of protected methods.
virtual void protectedMethodImplementation (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Implementation of protected methods.
virtual void publicMethodDeclaration (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
virtual void publicMethodImplementation (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
virtual void testCallFunction (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Call of the test function.
virtual void testFunction (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Implementation of test function.
virtual ~CppTraitTypeStream ()
 Desctructor of CppTraitTypeStream.

Detailed Description

Class generator for setter trait.

Definition at line 16 of file CppTraitTypeStream.h.

Constructor & Destructor Documentation

◆ CppTraitTypeStream()

CppTraitTypeStream::CppTraitTypeStream ( )

Consctructor of CppTraitTypeStream.

Definition at line 11 of file CppTraitTypeStream.cpp.

References PAbstractTraitBackend::PAbstractTraitBackend().

Here is the call graph for this function:

◆ ~CppTraitTypeStream()

CppTraitTypeStream::~CppTraitTypeStream ( )
virtual

Desctructor of CppTraitTypeStream.

Definition at line 16 of file CppTraitTypeStream.cpp.

16{}

Member Function Documentation

◆ classExtraFunctionDeclaration()

void CppTraitTypeStream::classExtraFunctionDeclaration ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Declaration of extra functions.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 72 of file CppTraitTypeStream.cpp.

72 {
73 if(!mode.enableTypeStream){return;}
74 PString name(classConfig.getName());
75 PString fullName(classConfig.getFullName());
76
77 if(classConfig.getIsEnum()){
78 name = name + "::" + name;
79 }
80
81 const PVecString & listTemplate = classConfig.getListTemplate();
82 if(listTemplate.size() != 0LU){
83 fs << "///Get the name of the class " << name << std::endl;
84 fs << "/**\t@return name of the class " << name << std::endl;
85 fs << "*/" << std::endl;
86 fs << mode.templateDeclaration;
87 fs << "std::string phoenix_getTypeName<"<<fullName << mode.defTemplate <<" >(){" << std::endl;
88 fs << "\treturn \""<<name<<"\"";
89 fs << " + \"<\"";
90 for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
91 fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()";
92 }
93 fs << " + \">\"";
94 fs << ";" << std::endl;
95 fs << "}" << std::endl << std::endl;
96
97 }else{
98 fs << "template<>" << std::endl;
99 //Enums are generated without their namespace (namespace Name{enum Name}), so they keep Name::Name
100 fs << "std::string phoenix_getTypeName<"<<(classConfig.getIsEnum() ? name : fullName)<<">();" << std::endl << std::endl;
101 }
102}
PString getFullName() const
Returns the full name of the class including the namespace.
const PVecString & getListTemplate() const
Returns the list of the template of the class.
const PString & getName() const
Returns the class name.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
PString defTemplate
Template definition for the class header.
PString templateDeclaration
Template declaration of the method implementation.
bool enableTypeStream
True to enable type stream interface generator.

References GeneratorMode::defTemplate, GeneratorMode::enableTypeStream, PClassConfig::getFullName(), PClassConfig::getIsEnum(), PClassConfig::getListTemplate(), PClassConfig::getName(), and GeneratorMode::templateDeclaration.

Here is the call graph for this function:

◆ classExtraFunctionImplementation()

void CppTraitTypeStream::classExtraFunctionImplementation ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Implementation of extra functions.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 109 of file CppTraitTypeStream.cpp.

109 {
110 if(!mode.enableTypeStream){return;}
111 PString name(classConfig.getName());
112 PString fullName(classConfig.getFullName());
113 fs << "///Get the name of the class " << name << " for PhoenixTypeStream" << std::endl;
114 fs << "/**\t@return name of the class " << name << " for PhoenixTypeStream" << std::endl;
115 fs << "*/" << std::endl;
116 if(classConfig.getIsEnum()){
117 //Enums are generated without their namespace (namespace Name{enum Name}), so they keep Name::Name
118 name = name + "::" + name;
119 fullName = name;
120 }
121 const PVecString & listTemplate = classConfig.getListTemplate();
122 if(listTemplate.size() == 0LU){
123 fs << "template<>" << std::endl;
124 }else{
125 fs << mode.templateDeclaration;
126 }
127 fs << "std::string phoenix_getTypeName<"<<fullName << mode.defTemplate <<" >(){" << std::endl;
128 fs << "\treturn \""<<name<<"\"";
129 if(listTemplate.size() != 0LU){
130 fs << " + \"<\"";
131 for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
132 fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()";
133 }
134 fs << " + \">\"";
135 }
136 fs << ";" << std::endl;
137 fs << "}" << std::endl << std::endl;
138}

References GeneratorMode::defTemplate, GeneratorMode::enableTypeStream, PClassConfig::getFullName(), PClassConfig::getIsEnum(), PClassConfig::getListTemplate(), PClassConfig::getName(), and GeneratorMode::templateDeclaration.

Here is the call graph for this function:

◆ headerExtraInclude()

void CppTraitTypeStream::headerExtraInclude ( std::ofstream & fs,
const GeneratorMode & mode ) const
virtual

Add extra include on the header.

Parameters
[out]fs: file to be completed
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 22 of file CppTraitTypeStream.cpp.

22 {
23 if(!mode.enableTypeStream){return;}
24 fs << "#include \"phoenix_type_stream.h\"" << std::endl;
25}

References GeneratorMode::enableTypeStream.

◆ privateMethodDeclaration()

void CppTraitTypeStream::privateMethodDeclaration ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Declaration of private methods.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 52 of file CppTraitTypeStream.cpp.

52 {
53 if(!mode.enableTypeStream){return;}
54
55}

References GeneratorMode::enableTypeStream.

◆ privateMethodImplementation()

void CppTraitTypeStream::privateMethodImplementation ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Implementation of private methods.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 62 of file CppTraitTypeStream.cpp.

62 {
63 if(!mode.enableTypeStream){return;}
64
65}

References GeneratorMode::enableTypeStream.

◆ protectedMethodDeclaration()

void CppTraitTypeStream::protectedMethodDeclaration ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Declaration of protected methods.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 32 of file CppTraitTypeStream.cpp.

32 {
33 if(!mode.enableTypeStream){return;}
34
35}

References GeneratorMode::enableTypeStream.

◆ protectedMethodImplementation()

void CppTraitTypeStream::protectedMethodImplementation ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Implementation of protected methods.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 42 of file CppTraitTypeStream.cpp.

42 {
43 if(!mode.enableTypeStream){return;}
44
45}

References GeneratorMode::enableTypeStream.

◆ publicMethodDeclaration()

virtual void PAbstractTraitBackend::publicMethodDeclaration ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
inlinevirtualinherited

◆ publicMethodImplementation()

virtual void PAbstractTraitBackend::publicMethodImplementation ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
inlinevirtualinherited

◆ testCallFunction()

void CppTraitTypeStream::testCallFunction ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Call of the test function.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 162 of file CppTraitTypeStream.cpp.

162 {
163 if(!mode.enableTypeStream){return;}
164 PString name(classConfig.getName());
165 fs << "\tcheck"+name+"TypeStream();\n";
166}

References GeneratorMode::enableTypeStream, and PClassConfig::getName().

Here is the call graph for this function:

◆ testFunction()

void CppTraitTypeStream::testFunction ( std::ofstream & fs,
const PClassConfig & classConfig,
const GeneratorMode & mode ) const
virtual

Implementation of test function.

Parameters
[out]fs: file to be completed
classConfig: PClassConfig to be used
mode: mode of the generator

Reimplemented from PAbstractTraitBackend.

Definition at line 145 of file CppTraitTypeStream.cpp.

145 {
146 if(!mode.enableTypeStream){return;}
147 PString name(classConfig.getName());
148 fs << "///Check TypeStream of class "+name+"\n";
149 fs << "void check"+name+"TypeStream(){\n";
150 if(classConfig.getIsEnum()){
151 name = name + "::" + name;
152 }
153 fs << "\t"<<mode.assertCall<<"(phoenix_getTypeToStr<"<<name<<">() == \""<<name<<"\");\n";
154 fs << "}\n\n";
155}
PString assertCall
Assert to be used.

References GeneratorMode::assertCall, GeneratorMode::enableTypeStream, PClassConfig::getIsEnum(), and PClassConfig::getName().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
  • /builds/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixGenerator/src/TraitBackEnd/CPP/CppTraitTypeStream/CppTraitTypeStream.h
  • /builds/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixGenerator/src/TraitBackEnd/CPP/CppTraitTypeStream/CppTraitTypeStream.cpp