-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLRL_StringTools.cpp
More file actions
69 lines (55 loc) · 1.82 KB
/
LRL_StringTools.cpp
File metadata and controls
69 lines (55 loc) · 1.82 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
#include "LRL_StringTools.h"
#include <algorithm>
#include <cfloat>
#include <iostream>
#include <iterator>
#include <sstream>
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
bool LRL_StringTools::not_space(const char c) {
return(c != ' ');
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
bool LRL_StringTools::space(const char c) {
return(c == ' ');
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
std::string LRL_StringTools::strToupper(const std::string& s) {
std::string ss(s);
for (size_t i = 0; i < ss.length(); ++i)
ss[i] = static_cast<char>(toupper(ss[i]));
return(ss);
}
std::vector<double> LRL_StringTools::FromString(const std::string& s) {
std::istringstream istr(s);
std::vector<double> t;
double d;
int i = 0;
while (istr && !istr.eof()) {
istr >> d;
if (istr.eof() && d == DBL_MAX) break;
t.push_back(d);
++i;
d = DBL_MAX;
}
return t;
}
std::string LRL_StringTools::ConcatanateStrings(const std::vector<std::string>& sinput) {
std::string s;
for (size_t face = 0; face < sinput.size(); ++face)
s += sinput[face];
return s;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
std::vector<std::string> LRL_StringTools::SplitBetweenBlanks(const std::string& s) {
std::vector<std::string> str;
std::string::const_iterator i = s.begin();
while (i != s.end())
{
//look for the next non-blank
i = std::find_if(i, s.end(), not_space);
const std::string::const_iterator i2 = std::find_if(i, s.end(), space);
str.push_back(std::string(i, i2));
i = i2;
}
return(str);
}