PhoenixGenerator  2.0.4
Set of tools to generate code
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 11 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 16 of file CppTraitConfigStream.cpp.

16{}

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 88 of file CppTraitConfigStream.cpp.

88 {
89 if(!mode.enableConfigStream){return;}
90 PString name(classConfig.getName());
91 fs << "template<>" << std::endl;
92 fs << "bool phoenix_config_stream<"<<name<<">(ConfigNodeIter & iter, "<<name<<" & data, const GenericConfigCheck * checker);" << std::endl << std::endl;
93}
const PString & getName() const
Returns the class name.
bool enableConfigStream
True to enable config stream interface generator.

References GeneratorMode::enableConfigStream, 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 100 of file CppTraitConfigStream.cpp.

100 {
101 if(!mode.enableConfigStream){return;}
102
103 PString name(classConfig.getName());
104 fs << "///Load and save the given " << name << " depending on the ConfigNodeIter mode (interface with PhoenixConfigStream)" << std::endl;
105 fs << "/**\t@param[out] iter : ConfigNodeIter to be used to load and save the configuration" << std::endl;
106 fs << " * \t@param[out] data : " << name << " to load or save" << std::endl;
107 fs << " * \t@param checker : check caracteristics of the given " << name << " (eg: boundaries or size)" << std::endl;
108 fs << " * \t@return true on success, false otherwise" << std::endl;
109 fs << "*/" << std::endl;
110 const PVecString & listTemplate = classConfig.getListTemplate();
111 if(listTemplate.size() == 0lu){
112 fs << "template<>" << std::endl;
113 }else{
114 fs << mode.templateDeclaration;
115 }
116 fs << "bool phoenix_config_stream<"<<name << mode.defTemplate<<">(ConfigNodeIter & iter, "<<name << mode.defTemplate<<" & data, const GenericConfigCheck * checker){" << std::endl;
117 fs << "\tbool b(true);" << std::endl;
118 if(classConfig.getIsEnum()){
119 fs << "\tPString value = iter->getString();" << std::endl;
120 fs << "\tif(!fromString(data, value)){" << std::endl;
121 fs << "\t\t*iter.getOut() << \"phoenix_config_stream<"<<name << mode.defTemplate<<"> : cannot load enum '"<<name<<"' with value '\"<<value<<\"'\" << std::endl;" << std::endl;
122 fs << "\t\tb = false;" << std::endl;
123 fs << "\t}" << std::endl;
124 }else{
125 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
126 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
127 //TODO : add a call to the ConfigCheck when it will be available in the pdata
128 fs << "\tb &= phoenix_config_stream<"<<it->getType()<<">(iter, data.get"<<it->getName().firstToUpper()<<"(), \""<<it->getName().toSnakeCase()<<"\", checker);" << std::endl;
129 }
130 }
131 fs << "\treturn b;" << std::endl;
132 fs << "}" << std::endl << std::endl;
133}
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.
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.

References GeneratorMode::defTemplate, GeneratorMode::enableConfigStream, PClassConfig::getIsEnum(), 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 22 of file CppTraitConfigStream.cpp.

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

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 70 of file CppTraitConfigStream.cpp.

70 {
71
72}

◆ 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 79 of file CppTraitConfigStream.cpp.

79 {
80
81}

◆ 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 52 of file CppTraitConfigStream.cpp.

52 {
53
54}

◆ 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 61 of file CppTraitConfigStream.cpp.

61 {
62
63}

◆ 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 32 of file CppTraitConfigStream.cpp.

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

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 42 of file CppTraitConfigStream.cpp.

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

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 37 of file PAbstractTraitBackend.h.

37{}

◆ 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 36 of file PAbstractTraitBackend.h.

36{}

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