-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.cpp
96 lines (86 loc) · 1.38 KB
/
service.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* service.cpp
* bkglibML
*
* Created by Marat Kazanov on 2/3/12.
* Copyright 2012 BalalayKrokoG. All rights reserved.
*
*/
//#include <stdafx.h>
#include <sstream>
#include <iterator>
#include <algorithm>
#include "service.h"
vector<string> split(string s)
{
vector<string> ret;
istringstream iss(s);
copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter<vector<string> >(ret));
return(ret);
}
vector<string> splitd(string s, char delimiter)
{
vector<string> ret;
string item;
stringstream ss(s);
while(getline(ss,item,delimiter))
{
ret.push_back(item);
}
return(ret);
}
int isNumeric(string s)
{
float f;
istringstream ss(s);
if(!(ss >> f))
return(0);
else
return(1);
}
string Upper(string s)
{
//string ss;
//ss = s;
transform(s.begin(),s.end(),s.begin(),::toupper);
return(s);
}
double str2d(string s)
{
double ret;
istringstream iss(s);
iss >> ret;
return(ret);
}
int str2i(string s)
{
int ret;
istringstream iss(s);
iss >> ret;
return(ret);
}
unsigned long str2ul(string s)
{
unsigned long ret;
istringstream iss(s);
iss >> ret;
return(ret);
}
string i2str(int i)
{
ostringstream oss;
oss << i;
return(oss.str());
}
string d2str(double d)
{
ostringstream oss;
oss << d;
return(oss.str());
}
string ul2str(unsigned long ul)
{
ostringstream oss;
oss << ul;
return(oss.str());
}