PhoenixGenerator  2.8.0
Set of tools to generate code
Loading...
Searching...
No Matches
CppTraitConfigStream.cpp
Go to the documentation of this file.
1
2/***************************************
3 Auteur : Pierre Aubert
4 Mail : pierre.aubert@lapp.in2p3.fr
5 Licence : CeCILL-C
6****************************************/
7
9
14
17
19
22void CppTraitConfigStream::headerExtraInclude(std::ofstream & fs, const GeneratorMode & mode) const{
23 if(!mode.enableConfigStream){return;}
24 fs << "#include \"phoenix_config_stream.h\"" << std::endl;
25}
26
28
32void CppTraitConfigStream::publicMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
33 if(!mode.enableConfigStream){return;}
34
35}
36
38
42void CppTraitConfigStream::publicMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
43 if(!mode.enableConfigStream){return;}
44
45}
46
48
52void CppTraitConfigStream::protectedMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
53
54}
55
57
61void CppTraitConfigStream::protectedMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
62
63}
64
66
70void CppTraitConfigStream::privateMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
71
72}
73
75
79void CppTraitConfigStream::privateMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
80
81}
82
84
88void CppTraitConfigStream::classExtraFunctionDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
89 if(!mode.enableConfigStream){return;}
90 PString name(classConfig.getName());
91 if(classConfig.getIsEnum()){
92 name = name + "::" + name;
93 }
94 fs << "template<>" << std::endl;
95 fs << "bool phoenix_config_stream<"<<name<<">(ConfigNodeIter & iter, "<<name<<" & data, const GenericConfigCheck * checker);" << std::endl << std::endl;
96}
97
99
103void CppTraitConfigStream::classExtraFunctionImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
104 if(!mode.enableConfigStream){return;}
105
106 PString name(classConfig.getName());
107 // PString fullName(classConfig.getFullName());
108 fs << "///Load and save the given " << name << " depending on the ConfigNodeIter mode (interface with PhoenixConfigStream)" << std::endl;
109 fs << "/**\t@param[out] iter : ConfigNodeIter to be used to load and save the configuration" << std::endl;
110 fs << " * \t@param[out] data : " << name << " to load or save" << std::endl;
111 fs << " * \t@param checker : check caracteristics of the given " << name << " (eg: boundaries or size)" << std::endl;
112 fs << " * \t@return true on success, false otherwise" << std::endl;
113 fs << "*/" << std::endl;
114 const PVecString & listTemplate = classConfig.getListTemplate();
115 if(listTemplate.size() == 0lu){
116 fs << "template<>" << std::endl;
117 }else{
118 fs << mode.templateDeclaration;
119 }
120 if(classConfig.getIsEnum()){
121 name = name + "::" + name;
122 }
123
124 fs << "bool phoenix_config_stream<"<<name << mode.defTemplate<<">(ConfigNodeIter & iter, "<<name << mode.defTemplate<<" & data, const GenericConfigCheck * checker){" << std::endl;
125 fs << "\tbool b(true);" << std::endl;
126 if(classConfig.getIsEnum()){
127 fs << "\tPString value = iter->getString();" << std::endl;
128 fs << "\tif(!fromString(data, value)){" << std::endl;
129 fs << "\t\t*iter.getOut() << \"phoenix_config_stream<"<<name << mode.defTemplate<<"> : cannot load enum '"<<name<<"' with value '\"<<value<<\"'\" << std::endl;" << std::endl;
130 fs << "\t\tb = false;" << std::endl;
131 fs << "\t}" << std::endl;
132 }else{
133 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
134 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
135 //TODO : add a call to the ConfigCheck when it will be available in the pdata
136 fs << "\tb &= phoenix_config_stream<"<<it->getType()<<">(iter, data.get"<<it->getName().firstToUpper()<<"(), \""<<it->getName().toSnakeCase()<<"\", checker);" << std::endl;
137 }
138 }
139 fs << "\treturn b;" << std::endl;
140 fs << "}" << std::endl << std::endl;
141}
142
143
144
145
std::vector< PClassAttribute > PVecClassAttribute
Definition PDataConfig.h:13
virtual ~CppTraitConfigStream()
Desctructor of CppTraitConfigStream.
virtual void protectedMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of protected methods.
virtual void publicMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of public methods.
virtual void protectedMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of protected methods.
CppTraitConfigStream()
Consctructor of CppTraitConfigStream.
virtual void headerExtraInclude(std::ofstream &fs, const GeneratorMode &mode) const
Add extra include on the header.
virtual void classExtraFunctionImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of extra functions.
virtual void publicMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of public methods.
virtual void privateMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of private methods.
virtual void privateMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of private methods.
virtual void classExtraFunctionDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of extra functions.
Class to describe a basic class.
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.
All the genertor modes.
PString defTemplate
Template definition for the class header.
PString templateDeclaration
Template declaration of the method implementation.
bool enableConfigStream
True to enable config stream interface generator.