/
td3Utility.cpp
51 lines (43 loc) · 1.03 KB
/
td3Utility.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
49
50
#include <string>
#include <sstream>
#include <vector>
#include <cstdlib>
#include "td3Utility.hpp"
using std::string;
using std::vector;
using std::ostringstream;
string td3Utility::toString(int number, bool fpn)
{
ostringstream s;
s << number;
return s.str();
}
string td3Utility::toString(double number, bool fpn)
{
ostringstream s;
s << number;
return (fpn && !isFloat(s.str())) ? s.str()+".0" : s.str();
}
vector<vector<string> > td3Utility::makeVector(string operand1, string operand2)
{
vector<vector<string> > parameters;
vector<string> subparameters;
subparameters.push_back(operand1);
parameters.push_back(subparameters);
subparameters.clear();
subparameters.push_back(operand2);
parameters.push_back(subparameters);
return parameters;
}
bool td3Utility::isFloat(string number)
{
return (number.find(".") != string::npos);
}
int td3Utility::stoi(string number)
{
return atoi(number.c_str());
}
double td3Utility::stof(string number)
{
return atof(number.c_str());
}