-
Notifications
You must be signed in to change notification settings - Fork 0
/
variable.cpp
48 lines (42 loc) · 1.41 KB
/
variable.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "variable.h"
Variable::Variable(QString expression, bool getter, bool setter, bool prefix) :
m_generateGetter(getter), m_generateSetter(setter)
{
QStringList m_parsedAttribute = expression.split(' ', QString::SkipEmptyParts);
m_prefixed_variable = m_parsedAttribute.last();
m_variable = m_prefixed_variable;
m_parsedAttribute.pop_back();
m_type = m_parsedAttribute.last();
m_parsedAttribute.pop_back();
if (!m_parsedAttribute.isEmpty())
{
m_keywords = m_parsedAttribute.join(' ');
m_keywords.push_front(" ");
m_keywords.push_back(" ");
}
else
m_keywords = "";
if(prefix)
m_prefixed_variable.push_front("m_");
}
void Variable::addToList(QListWidget *list)
{
list->addItem("[" + m_keywords + " " + m_type + " ] : " + m_prefixed_variable);
}
void Variable::addToCode(QString& publicBlock, QString& privateBlock)
{
privateBlock += m_keywords + m_type +" " + m_prefixed_variable + ";\n";
if (m_generateGetter)
{
m_variable[1].toUpper();
publicBlock += " " + m_type + " get" + m_variable + "() const { return " + m_prefixed_variable + " };\n";
m_variable[1].toLower();
}
if (m_generateSetter)
{
m_variable[1].toUpper();
publicBlock +=" void set" + m_variable + "( " + m_type + " val) { "
+ m_prefixed_variable + " = val; };\n";
m_variable[1].toLower();
}
}