1 // Copyright 2009-2021 Intel Corporation 2 // SPDX-License-Identifier: Apache-2.0 3 4 #include "string.h" 5 6 #include <algorithm> 7 #include <ctype.h> 8 9 namespace embree 10 { to_lower(char c)11 char to_lower(char c) { return char(tolower(int(c))); } to_upper(char c)12 char to_upper(char c) { return char(toupper(int(c))); } toLowerCase(const std::string & s)13 std::string toLowerCase(const std::string& s) { std::string dst(s); std::transform(dst.begin(), dst.end(), dst.begin(), to_lower); return dst; } toUpperCase(const std::string & s)14 std::string toUpperCase(const std::string& s) { std::string dst(s); std::transform(dst.begin(), dst.end(), dst.begin(), to_upper); return dst; } 15 string_to_Vec2f(std::string str)16 Vec2f string_to_Vec2f ( std::string str ) 17 { 18 size_t next = 0; 19 const float x = std::stof(str,&next); str = str.substr(next+1); 20 const float y = std::stof(str,&next); 21 return Vec2f(x,y); 22 } 23 string_to_Vec3f(std::string str)24 Vec3f string_to_Vec3f ( std::string str ) 25 { 26 size_t next = 0; 27 const float x = std::stof(str,&next); str = str.substr(next+1); 28 const float y = std::stof(str,&next); str = str.substr(next+1); 29 const float z = std::stof(str,&next); 30 return Vec3f(x,y,z); 31 } 32 string_to_Vec4f(std::string str)33 Vec4f string_to_Vec4f ( std::string str ) 34 { 35 size_t next = 0; 36 const float x = std::stof(str,&next); str = str.substr(next+1); 37 const float y = std::stof(str,&next); str = str.substr(next+1); 38 const float z = std::stof(str,&next); str = str.substr(next+1); 39 const float w = std::stof(str,&next); 40 return Vec4f(x,y,z,w); 41 } 42 } 43