15 inline std::string toString(
const glm::vec3& pos) {
17 std::snprintf(buf,
sizeof(buf),
"%f:%f:%f", pos.x, pos.y, pos.z);
21 inline bool startsWith(
const std::string&
string,
const std::string& token) {
22 return !
string.compare(0, token.size(), token);
25 inline float strToFloat(
const std::string& str) {
26 return static_cast<float>(::atof(str.c_str()));
29 inline std::string eraseAllSpaces(
const std::string& str) {
32 std::string tmp = str;
33 tmp.erase(std::remove(tmp.begin(), tmp.end(),
' '), tmp.end());
37 inline void splitString(
const std::string&
string, std::vector<std::string>& tokens,
const std::string& delimiters =
"()") {
39 std::string::size_type lastPos =
string.find_first_not_of(delimiters, 0);
41 std::string::size_type pos =
string.find_first_of(delimiters, lastPos);
43 while (std::string::npos != pos || std::string::npos != lastPos) {
45 tokens.push_back(
string.substr(lastPos, pos - lastPos));
47 lastPos =
string.find_first_not_of(delimiters, pos);
49 pos =
string.find_first_of(delimiters, lastPos);