36 char _tmpFileName[] =
"fileXXXXXX";
37 int fd = mkstemp(_tmpFileName);
39 #else // mainly Windows 40 char _tmpFileName[] =
"fileXXXXXX";
41 _mktemp_s(_tmpFileName, strlen(_tmpFileName));
44 return std::string(_tmpFileName);
47 bool endsWith(std::string
const& value, std::string
const& ending) {
48 if (ending.size() > value.size())
return false;
49 return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
52 std::vector< std::string >
split(
const std::string& str,
53 const std::string& delim) {
54 std::vector< std::string > tokens;
55 size_t prev = 0, pos = 0;
57 pos = str.find(delim, prev);
58 if (pos == std::string::npos) pos = str.length();
59 std::string token = str.substr(prev, pos - prev);
60 if (!token.empty()) tokens.push_back(token);
61 prev = pos + delim.length();
62 }
while (pos < str.length() && prev < str.length());
78 const std::string& val,
79 const std::string& new_val) {
81 auto pos = retVal.find(val);
82 while (pos != std::string::npos) {
83 std::stringstream sBuff;
84 sBuff << s.substr(0, pos) << new_val
85 << s.substr(pos + val.size(), std::string::npos);
87 pos = retVal.find(val);
96 #endif // GUM_NO_INLINE std::string getUniqueFileName()
Returns a path to a unique file name.
Contains usefull methods for random stuff.
gum is the global namespace for all aGrUM entities
std::vector< std::string > split(const std::string &str, const std::string &delim)
Split str using the delimiter.
bool endsWith(std::string const &value, std::string const &ending)
Returns true if value ends with ending.
std::string replace(const std::string &s, const std::string &val, const std::string &new_val)
not usable for gcc 4.8 std::vector<std::string> split( const std::string& orig, const std::string& de...
Utilities for manipulating strings.