PhoenixGenerator  2.6.4
Set of tools to generate code
Loading...
Searching...
No Matches
CppTraitCheckStream Class Reference

Class generator for setter trait. More...

#include <CppTraitCheckStream.h>

+ Inheritance diagram for CppTraitCheckStream:
+ Collaboration diagram for CppTraitCheckStream:

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.
 
 CppTraitCheckStream ()
 Consctructor of CppTraitCheckStream.
 
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 ~CppTraitCheckStream ()
 Desctructor of CppTraitCheckStream.
 

Detailed Description

Class generator for setter trait.

Definition at line 16 of file CppTraitCheckStream.h.

Constructor & Destructor Documentation

◆ CppTraitCheckStream()

CppTraitCheckStream::CppTraitCheckStream ( )

Consctructor of CppTraitCheckStream.

Definition at line 11 of file CppTraitCheckStream.cpp.

References PAbstractTraitBackend::PAbstractTraitBackend().

+ Here is the call graph for this function:

◆ ~CppTraitCheckStream()

CppTraitCheckStream::~CppTraitCheckStream ( )
virtual

Desctructor of CppTraitCheckStream.

Definition at line 16 of file CppTraitCheckStream.cpp.

16{}

Member Function Documentation

◆ classExtraFunctionDeclaration()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

88 {
89 if(!mode.enableCheckStream){return;}
90 PString name(classConfig.getName());
91 PString fullName(classConfig.getFullName());
92 const PVecString & listTemplate = classConfig.getListTemplate();
93 if(classConfig.getIsEnum()){
94 fs << "PHOENIX_CHECK_STREAM_ENUM("<<name<<"::"<<name<<")" << std::endl << std::endl;
95 return;
96 }
97 if(listTemplate.size() != 0lu){
98 fs << "///@brief Generic "<<name<<" check function" << std::endl;
99 fs << mode.templateDeclaration;
100 fs << "struct CheckStream<"<<fullName << mode.defTemplate<<">{" << std::endl;
101 fs << "\tstatic bool check_stream(const std::string & fieldDescription, const "<<fullName << mode.defTemplate<<" & data, const "<<fullName << mode.defTemplate<<" & reference, std::ostream & out);" << std::endl;
102 fs << "\t\tbool b(true);" << std::endl;
103 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
104 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
105 fs << "\t\tb &= CheckStream<"<<it->getType()<<">::check_stream(fieldDescription + \"\\n- "<<name<<"::"<<it->getName()<<"\", data.get"<<it->getName().firstToUpper()<<"(), reference.get"<<it->getName().firstToUpper()<<"(), out);" << std::endl;
106 }
107 fs << "\t\treturn b;" << std::endl;
108 fs << "\t}" << std::endl;
109 fs << "};" << std::endl;
110 }else{
111 fs << "///@brief Generic "<<name<<" Check function" << std::endl;
112 fs << "template<>" << std::endl;
113 fs << "struct CheckStream<"<<fullName<<">{" << std::endl;
114 fs << "\tstatic bool check_stream(const std::string & fieldDescription, const "<<fullName<<" & data, const "<<fullName<<" & reference, std::ostream & out);" << std::endl;
115 fs << "};" << std::endl;
116 }
117 fs << std::endl << std::endl;
118}
std::vector< PClassAttribute > PVecClassAttribute
Definition PDataConfig.h:13
PString getFullName() const
Returns the full name of the class including the namespace.
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.
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 enableCheckStream
True to enable check stream interface generator.

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

+ Here is the call graph for this function:

◆ classExtraFunctionImplementation()

void CppTraitCheckStream::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 125 of file CppTraitCheckStream.cpp.

125 {
126 if(!mode.enableCheckStream || classConfig.getIsEnum()){return;}
127
128 PString name(classConfig.getName());
129 PString fullName(classConfig.getFullName());
130 const PVecString & listTemplate = classConfig.getListTemplate();
131 if(listTemplate.size() == 0lu){
132 fs << "///Check Stream for a "<<name<<"" << std::endl;
133 fs << "/**\t@param fieldDescription : description of the field to be checked" << std::endl;
134 fs << " * \t@param data : data to be checked" << std::endl;
135 fs << " * \t@param reference : reference of the check" << std::endl;
136 fs << " * \t@param out : ostream used to collect feed back in case of error (std::cerr or a logger)" << std::endl;
137 fs << " * \t@return true on success, false otherwise" << std::endl;
138 fs << "*/" << std::endl;
139 fs << "bool CheckStream<"<<fullName<<">::check_stream(const std::string & fieldDescription, const "<<fullName<<" & data, const "<<fullName<<" & reference, std::ostream & out){" << std::endl;
140 fs << "\tbool b(true);" << std::endl;
141 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
142 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
143 fs << "\tb &= CheckStream<"<<it->getType()<<">::check_stream(fieldDescription + \"\\n- "<<name<<"::"<<it->getName()<<"\", data.get"<<it->getName().firstToUpper()<<"(), reference.get"<<it->getName().firstToUpper()<<"(), out);" << std::endl;
144 }
145 fs << "\treturn b;" << std::endl;
146 fs << "}" << std::endl;
147 }
148 fs << std::endl << std::endl;
149}

References GeneratorMode::enableCheckStream, PClassConfig::getFullName(), PClassConfig::getIsEnum(), PClassConfig::getListAttribute(), PClassConfig::getListTemplate(), and PClassConfig::getName().

+ Here is the call graph for this function:

◆ headerExtraInclude()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

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

References GeneratorMode::enableCheckStream.

◆ privateMethodDeclaration()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

70 {
71
72}

◆ privateMethodImplementation()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

79 {
80
81}

◆ protectedMethodDeclaration()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

52 {
53
54}

◆ protectedMethodImplementation()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

61 {
62
63}

◆ publicMethodDeclaration()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

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

References GeneratorMode::enableCheckStream.

◆ publicMethodImplementation()

void CppTraitCheckStream::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 CppTraitCheckStream.cpp.

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

References GeneratorMode::enableCheckStream.

◆ 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: