-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstring.hpp
More file actions
31 lines (25 loc) · 971 Bytes
/
string.hpp
File metadata and controls
31 lines (25 loc) · 971 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
#pragma once
#ifndef __CPPM_UTIL_STRING_HPP__
#define __CPPM_UTIL_STRING_HPP__
#include <string>
#include <vector>
#include <sstream>
namespace cppm::util::str {
inline std::string quot(const std::string& str) { return "\""+str+"\""; }
inline std::string operator"" _quot(const char* str, std::size_t len) { return quot({str, len}); }
inline std::string str_cut(const std::string& str, size_t size) {
return str.size() > size ? str.substr(0, size-1) + "$" : str;
}
inline bool has_str(const std::string& target, const std::string& str) {
if(target == "") { return false; }
return target.find(str) != std::string::npos;
}
inline std::vector<std::string> split(std::string str, char delimiter) {
std::vector<std::string> result;
std::stringstream ss(str);
std::string temp;
while(getline(ss, temp, delimiter)) { result.push_back(temp); }
return result;
}
}
#endif