-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
32 lines (30 loc) · 796 Bytes
/
Copy pathutils.cpp
File metadata and controls
32 lines (30 loc) · 796 Bytes
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
#include "utils.hh"
std::vector<std::string> utils::split( std::string& str, char delim){
std::vector<std::string> result = {""};
bool cont = false;
for ( auto cha : str ){
if ( cha == '"' ){
cont = !cont;
} else if ( cha == delim && !cont){
result.push_back("");
} else {
result.back().push_back(cha);
}
}
if ( result.back() == "" ){
result.erase(--result.end());
}
return result;
}
bool utils::is_numeric(std::string s, bool zero_allowed)
{
if( not zero_allowed and s.length() == 1 and s.at(0) == '0' ) {
return false;
}
for( unsigned int i = 0; i < s.length(); ++i ) {
if( not isdigit(s.at(i)) ) {
return false;
}
}
return true;
}