PhoenixGenerator
2.8.0
Set of tools to generate code
Toggle main menu visibility
Loading...
Searching...
No Matches
CppTraitGetter.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
8
#include "
CppTraitGetter.h
"
9
11
18
PString
getter_createGetterDecl
(
const
PString & varType,
const
PString & varName,
const
PString & className,
bool
isConst,
bool
isPtr){
19
PString functionDecl(
""
);
20
functionDecl +=
makeVarType
(varType,
false
, isConst, !isConst, isPtr) +
" "
;
21
if
(className !=
""
) functionDecl += className +
"::"
;
22
functionDecl +=
"get"
+ varName.firstToUpper() +
"()"
;
23
return
functionDecl;
24
}
25
27
CppTraitGetter::CppTraitGetter
()
28
:
PAbstractTraitBackend
()
29
{}
30
32
CppTraitGetter::~CppTraitGetter
(){}
33
35
39
void
CppTraitGetter::publicMethodDeclaration
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
40
if
(!mode.
enableGetter
|| classConfig.
getIsEnum
()){
return
;}
41
const
PVecClassAttribute
& vecAttr(classConfig.
getListAttribute
());
42
for
(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
43
fs <<
"\t\t"
<<
getter_createGetterDecl
(it->getType(), it->getName(),
""
,
true
, it->getIsPointer()) <<
" const;"
<< std::endl;
44
fs <<
"\t\t"
<<
getter_createGetterDecl
(it->getType(), it->getName(),
""
,
false
, it->getIsPointer()) <<
";"
<< std::endl;
45
}
46
}
47
49
53
void
CppTraitGetter::publicMethodImplementation
(std::ofstream & fs,
const
PClassConfig
& classConfig,
const
GeneratorMode
& mode)
const
{
54
if
(!mode.
enableGetter
|| classConfig.
getIsEnum
()){
return
;}
55
const
PVecClassAttribute
& vecAttr(classConfig.
getListAttribute
());
56
for
(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
57
fs <<
"///Gets the "
<< it->getName() <<
" of the "
<< classConfig.
getName
() << std::endl;
58
fs <<
"/**\t@return "
<< it->getName() <<
" of the "
<< classConfig.
getName
() << std::endl;
59
fs <<
"*/"
<< std::endl;
60
fs << mode.
templateDeclaration
;
61
fs <<
getter_createGetterDecl
(it->getType(), it->getName(), classConfig.
getName
() + mode.
defTemplate
,
true
, it->getIsPointer()) <<
" const{"
<< std::endl;
62
fs <<
"\treturn p_"
<< it->getName() <<
";"
<< std::endl;
63
fs <<
"}"
<< std::endl << std::endl;
64
fs <<
"///Gets the "
<< it->getName() <<
" of the "
<< classConfig.
getName
() << std::endl;
65
fs <<
"/**\t@return "
<< it->getName() <<
" of the "
<< classConfig.
getName
() << std::endl;
66
fs <<
"*/"
<< std::endl;
67
fs << mode.
templateDeclaration
;
68
fs <<
getter_createGetterDecl
(it->getType(), it->getName(), classConfig.
getName
() + mode.
defTemplate
,
false
, it->getIsPointer()) <<
"{"
<< std::endl;
69
fs <<
"\treturn p_"
<< it->getName() <<
";"
<< std::endl;
70
fs <<
"}"
<< std::endl << std::endl;
71
}
72
}
73
74
75
76
77
getter_createGetterDecl
PString getter_createGetterDecl(const PString &varType, const PString &varName, const PString &className, bool isConst, bool isPtr)
Creates a function decl for setters.
Definition
CppTraitGetter.cpp:18
CppTraitGetter.h
PVecClassAttribute
std::vector< PClassAttribute > PVecClassAttribute
Definition
PDataConfig.h:13
CppTraitGetter::CppTraitGetter
CppTraitGetter()
Consctructor of CppTraitGetter.
Definition
CppTraitGetter.cpp:27
CppTraitGetter::~CppTraitGetter
virtual ~CppTraitGetter()
Desctructor of CppTraitGetter.
Definition
CppTraitGetter.cpp:32
CppTraitGetter::publicMethodImplementation
virtual void publicMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of methods.
Definition
CppTraitGetter.cpp:53
CppTraitGetter::publicMethodDeclaration
virtual void publicMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of methods.
Definition
CppTraitGetter.cpp:39
PAbstractTraitBackend::PAbstractTraitBackend
PAbstractTraitBackend()
Definition
PAbstractTraitBackend.h:22
PClassConfig
Class to describe a basic class.
Definition
PClassConfig.h:14
PClassConfig::getListAttribute
const std::vector< PClassAttribute > & getListAttribute() const
Returns the list of attributes of the class.
Definition
PClassConfig.cpp:167
PClassConfig::getName
const PString & getName() const
Returns the class name.
Definition
PClassConfig.cpp:129
PClassConfig::getIsEnum
bool getIsEnum() const
Say if the current PClassConfig is an enum.
Definition
PClassConfig.cpp:197
GeneratorMode
All the genertor modes.
Definition
GeneratorMode.h:27
GeneratorMode::enableGetter
bool enableGetter
True to enable getters trait generator.
Definition
GeneratorMode.h:42
GeneratorMode::defTemplate
PString defTemplate
Template definition for the class header.
Definition
GeneratorMode.h:48
GeneratorMode::templateDeclaration
PString templateDeclaration
Template declaration of the method implementation.
Definition
GeneratorMode.h:50
makeVarType
PString makeVarType(const PString &varType, bool isSetter, bool isConst, bool isRef, bool isPtr)
Makes the var type by taking account of the type.
Definition
type_utils.cpp:153
src
TraitBackEnd
CPP
CppTraitGetter
CppTraitGetter.cpp
Generated by
1.17.0