-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathManipulation.cpp
More file actions
74 lines (55 loc) · 1.4 KB
/
Manipulation.cpp
File metadata and controls
74 lines (55 loc) · 1.4 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Manipulation.cpp
* -
*/
#include "Manipulation.h"
//#include <vector>
using namespace std;
Manipulation::~Manipulation() {
}
Manipulation::Manipulation() {
}
string Manipulation::vtos(float value) {
char str[50] = "";
sprintf(str, "%.4f", value);
return str;
}
string Manipulation::vtos(double value) {
char str[50] = "";
sprintf(str, "%.4lf", value);
return str;
}
string Manipulation::vtos(short value) {
char str[50] = "";
sprintf(str, "%hd", value);
return str;
}
string Manipulation::vtos(int value) {
char str[50] = "";
sprintf(str, "%d", value);
return str;
}
string Manipulation::vtos(long int value) {
char str[50] = "";
sprintf(str, "%ld", value);
return str;
}
string Manipulation::vtos(unsigned long int value) {
char str[50] = "";
sprintf(str, "%lu", value);
return str;
}
string Manipulation::vtos(long double value) {
char str[50] = "";
sprintf(str, "%Lf", value);
return str;
}
void Manipulation::Tokenize(const string& str, vector<string>& tokens, const string& delimiters) {
string::size_type lastPos = str.find_first_not_of(delimiters, 0);
string::size_type pos = str.find_first_of(delimiters, lastPos);
while (string::npos != pos || string::npos != lastPos) {
tokens.push_back(str.substr(lastPos, pos - lastPos));
lastPos = str.find_first_not_of(delimiters, pos);
pos = str.find_first_of(delimiters, lastPos);
}
}