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

Class generator for setter trait. More...

#include <CppTraitConfigStream.h>

Inheritance diagram for CppTraitConfigStream:
Collaboration diagram for CppTraitConfigStream:

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.
 CppTraitConfigStream ()
 Consctructor of CppTraitConfigStream.
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
 Declaration of public methods.
virtual void publicMethodImplementation (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
 Implementation of public methods.
virtual void testCallFunction (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
virtual void testFunction (std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
virtual ~CppTraitConfigStream ()
 Desctructor of CppTraitConfigStream.

Detailed Description

Class generator for setter trait.

Definition at line 16 of file CppTraitConfigStream.h.

Constructor & Destructor Documentation

◆ CppTraitConfigStream()

CppTraitConfigStream::CppTraitConfigStream ( )

Consctructor of CppTraitConfigStream.

Definition at line 12 of file CppTraitConfigStream.cpp.

References PAbstractTraitBackend::PAbstractTraitBackend().

Here is the call graph for this function:

◆ ~CppTraitConfigStream()

CppTraitConfigStream::~CppTraitConfigStream ( )
virtual

Desctructor of CppTraitConfigStream.

Definition at line 17 of file CppTraitConfigStream.cpp.

17{}

Member Function Documentation

◆ classExtraFunctionDeclaration()

void CppTraitConfigStream::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 89 of file CppTraitConfigStream.cpp.

89 {
90 if(!mode.enableConfigStream){return;}
91 PString name(classConfig.getName());
92 if(classConfig.getIsEnum()){
93 name = name + "::" + name;
94 }
95 fs << "template<>" << std::endl;
96 fs << "bool phoenix_config_stream<"<<name<<">(ConfigNodeIter & iter, "<<name<<" & data, const GenericConfigCheck * checker);" << std::endl << std::endl;
97}
const PString & getName() const
Returns the class name.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
bool enableConfigStream
True to enable config stream interface generator.

References GeneratorMode::enableConfigStream, PClassConfig::getIsEnum(), and PClassConfig::getName().

Here is the call graph for this function:

◆ classExtraFunctionImplementation()

void CppTraitConfigStream::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 104 of file CppTraitConfigStream.cpp.

104 {
105 if(!mode.enableConfigStream){return;}
106
107 PString name(classConfig.getName());
108 // PString fullName(classConfig.getFullName());
109 fs << "///Load and save the given " << name << " depending on the ConfigNodeIter mode (interface with PhoenixConfigStream)" << std::endl;
110 fs << "/**\t@param[out] iter : ConfigNodeIter to be used to load and save the configuration" << std::endl;
111 fs << " * \t@param[out] data : " << name << " to load or save" << std::endl;
112 fs << " * \t@param checker : check caracteristics of the given " << name << " (eg: boundaries or size)" << std::endl;
113 fs << " * \t@return true on success, false otherwise" << std::endl;
114 fs << "*/" << std::endl;
115 const PVecString & listTemplate = classConfig.getListTemplate();
116 if(listTemplate.size() == 0LU){
117 fs << "template<>" << std::endl;
118 }else{
119 fs << mode.templateDeclaration;
120 }
121 if(classConfig.getIsEnum()){
122 name = name + "::" + name;
123 }
124
125 fs << "bool phoenix_config_stream<"<<name << mode.defTemplate<<">(ConfigNodeIter & iter, "<<name << mode.defTemplate<<" & data, const GenericConfigCheck * checker){" << std::endl;
126 fs << "\tbool b(true);" << std::endl;
127 if(classConfig.getIsEnum()){
128 fs << "\tPString value = iter->getString();" << std::endl;
129 fs << "\tif(!fromString(data, value)){" << std::endl;
130 fs << "\t\t*iter.getOut() << \"phoenix_config_stream<"<<name << mode.defTemplate<<"> : cannot load enum '"<<name<<"' with value '\"<<value<<\"'\" << std::endl;" << std::endl;
131 fs << "\t\tb = false;" << std::endl;
132 fs << "\t}" << std::endl;
133 }else{
134 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
135 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
136 //TODO : add a call to the ConfigCheck when it will be available in the pdata
137 PString attrName(it->getName().firstToUpper()), attrKey(it->getName().toSnakeCase());
138 if(getIsPointerType(it->getType())){
139 //phoenix_config_stream has a dedicated overload for T*& : go through a local variable since the getter returns the pointer by value, not by reference
140 PString pointeeType(it->getType().eraseFirstLastChar(" \n\t*")), localVar(it->getName().toSnakeCase());
141 fs << "\t" << pointeeType << " * " << localVar << "(data.get" << attrName << "());" << std::endl;
142 fs << "\tb &= phoenix_config_stream(iter, " << localVar << ", \"" << attrKey << "\", checker);" << std::endl;
143 fs << "\tdata.set" << attrName << "(" << localVar << ");" << std::endl;
144 }else{
145 fs << "\tb &= phoenix_config_stream<"<<it->getType()<<">(iter, data.get"<<attrName<<"(), \""<<attrKey<<"\", checker);" << std::endl;
146 }
147 }
148 }
149 fs << "\treturn b;" << std::endl;
150 fs << "}" << std::endl << std::endl;
151}
std::vector< PClassAttribute > PVecClassAttribute
Definition PDataConfig.h:13
const std::vector< PClassAttribute > & getListAttribute() const
Returns the list of attributes of the class.
const PVecString & getListTemplate() const
Returns the list of the template of the class.
PString defTemplate
Template definition for the class header.
PString templateDeclaration
Template declaration of the method implementation.
bool getIsPointerType(const PString &varType)
Say if a given type is a pointer type (i.e. it ends with a '*').

References GeneratorMode::defTemplate, GeneratorMode::enableConfigStream, PClassConfig::getIsEnum(), getIsPointerType(), PClassConfig::getListAttribute(), PClassConfig::getListTemplate(), PClassConfig::getName(), and GeneratorMode::templateDeclaration.

Here is the call graph for this function:

◆ headerExtraInclude()

void CppTraitConfigStream::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 23 of file CppTraitConfigStream.cpp.

23 {
24 if(!mode.enableConfigStream){return;}
25 fs << "#include \"phoenix_config_stream.h\"" << std::endl;
26}

References GeneratorMode::enableConfigStream.

◆ privateMethodDeclaration()

void CppTraitConfigStream::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 71 of file CppTraitConfigStream.cpp.

71 {
72
73}

◆ privateMethodImplementation()

void CppTraitConfigStream::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 80 of file CppTraitConfigStream.cpp.

80 {
81
82}

◆ protectedMethodDeclaration()

void CppTraitConfigStream::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 53 of file CppTraitConfigStream.cpp.

53 {
54
55}

◆ protectedMethodImplementation()

void CppTraitConfigStream::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 62 of file CppTraitConfigStream.cpp.

62 {
63
64}

◆ publicMethodDeclaration()

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

Declaration of public methods.

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

Reimplemented from PAbstractTraitBackend.

Definition at line 33 of file CppTraitConfigStream.cpp.

33 {
34 if(!mode.enableConfigStream){return;}
35
36}

References GeneratorMode::enableConfigStream.

◆ publicMethodImplementation()

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

Implementation of public methods.

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

Reimplemented from PAbstractTraitBackend.

Definition at line 43 of file CppTraitConfigStream.cpp.

43 {
44 if(!mode.enableConfigStream){return;}
45
46}

References GeneratorMode::enableConfigStream.

◆ testCallFunction()

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

Reimplemented in CppTraitCopy, CppTraitEmpty, CppTraitFromString, and CppTraitTypeStream.

Definition at line 38 of file PAbstractTraitBackend.h.

38{}

◆ testFunction()

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

Reimplemented in CppTraitCopy, CppTraitEmpty, CppTraitFromString, and CppTraitTypeStream.

Definition at line 37 of file PAbstractTraitBackend.h.

37{}

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