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 | { |
11 | char to_lower(char c) { return char(tolower(c: int(c))); } |
12 | char to_upper(char c) { return char(toupper(c: int(c))); } |
13 | std::string toLowerCase(const std::string& s) { std::string dst(s); std::transform(first: dst.begin(), last: dst.end(), result: dst.begin(), unary_op: to_lower); return dst; } |
14 | std::string toUpperCase(const std::string& s) { std::string dst(s); std::transform(first: dst.begin(), last: dst.end(), result: dst.begin(), unary_op: to_upper); return dst; } |
15 | |
16 | Vec2f string_to_Vec2f ( std::string str ) |
17 | { |
18 | size_t next = 0; |
19 | const float x = std::stof(str: str,idx: &next); str = str.substr(pos: next+1); |
20 | const float y = std::stof(str: str,idx: &next); |
21 | return Vec2f(x,y); |
22 | } |
23 | |
24 | Vec3f string_to_Vec3f ( std::string str ) |
25 | { |
26 | size_t next = 0; |
27 | const float x = std::stof(str: str,idx: &next); str = str.substr(pos: next+1); |
28 | const float y = std::stof(str: str,idx: &next); str = str.substr(pos: next+1); |
29 | const float z = std::stof(str: str,idx: &next); |
30 | return Vec3f(x,y,z); |
31 | } |
32 | |
33 | Vec4f string_to_Vec4f ( std::string str ) |
34 | { |
35 | size_t next = 0; |
36 | const float x = std::stof(str: str,idx: &next); str = str.substr(pos: next+1); |
37 | const float y = std::stof(str: str,idx: &next); str = str.substr(pos: next+1); |
38 | const float z = std::stof(str: str,idx: &next); str = str.substr(pos: next+1); |
39 | const float w = std::stof(str: str,idx: &next); |
40 | return Vec4f(x,y,z,w); |
41 | } |
42 | } |
43 | |