osuplusplus/include/string_util.hpp

25 lines
624 B
C++
Raw Normal View History

#pragma once
#ifndef PP_DEBUG
#include <algorithm>
#include <string>
#endif
inline void toLower(std::string &str) {
std::transform(str.begin(), str.end(), str.begin(),
[](unsigned char c){ return std::tolower(c); });
}
inline void toUpper(std::string &str) {
std::transform(str.begin(), str.end(), str.begin(),
[](unsigned char c){ return std::toupper(c); });
}
inline bool isInt(const std::string &str) {
return str.find_first_not_of("1234567890") == std::string::npos;
}
inline bool isBlank(const std::string &str) {
return str.find_first_not_of(" \n\t\v\r\f") == std::string::npos;
}