-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
35 lines (27 loc) · 785 Bytes
/
utils.h
File metadata and controls
35 lines (27 loc) · 785 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
33
34
35
#pragma once
#include <regex>
#include <string>
#include <algorithm>
#include "console.h"
bool is_whitespace(const std::string& str){
static std::regex emptystr{"^\\s*$"};
return std::regex_search(str, emptystr);
}
bool is_not_whitespace(const std::string& str){
return !is_whitespace(str);
}
std::wstring string_to_wstring(const std::string& str){
std::wstring ret;
ret.reserve(str.size());
std::copy(std::begin(str), std::end(str), std::back_inserter(ret));
return ret;
}
template <class Str=std::string>
bool is_int(const Str& str){
return std::all_of(std::begin(str), std::end(str), ::isdigit);
}
bool is_int(int i){ return true; }
template <class Str=std::string>
int to_int(const Str& str){
return std::stoi(str, nullptr, 10);
}