-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunction.cpp
46 lines (42 loc) · 1.21 KB
/
Function.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
//
// Created by hegedus on 2017.12.14..
//
#include "Function.h"
Function::Function(Visibility visibility, std::string name, std::map<std::string, std::string> params,
std::string type, bool isStatic, bool isVirtual) :
visibility{visibility}, name{name}, parameters{params}, return_type{type}, isStatic{isStatic}, isVirtual{isVirtual} {}
std::string Function::write() const {
std::string ret;
switch (visibility) {
case PUBLIC :
ret = "+ ";
break;
case PRIVATE :
ret = "- ";
break;
case PROTECTED :
ret = "# ";
break;
default:
ret = "+ ";
break;
}
ret += name + "(";
std::string params = "";
if(!parameters.empty()) {
for (auto it = parameters.begin(); it != parameters.end(); ++it) {
params += it.operator*().second + " : " + it.operator*().first + ", ";
}
params.pop_back();
params.pop_back();
}
ret += params + ") : " + return_type;
if(isStatic) {
ret = "<U>" + ret + "</U>";
}
if(isVirtual) {
ret = "<I>" + ret + "</I>";
}
ret += "<BR ALIGN=\"LEFT\"/>";
return ret;
}