android_helpers.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include <inttypes.h>
7 #include <stdlib.h>
8 #include <sstream>
9 #include <ios>
10 #include <android/ndk-version.h>
11 
12 #if __NDK_MAJOR__ <= 16
13 namespace std
14 {
15  template <typename T>
17  {
18  std::ostringstream os;
19  os << value;
20  return os.str();
21  }
22 
23  template <typename T>
24  inline T stoT(const std::string& value)
25  {
26  char* endptr;
27  auto x = strtoimax(value.c_str(), &endptr, 10);
28 
29  return static_cast<T>(x);
30  }
31 
32  inline long long stoll(const std::string& value)
33  {
34  return stoT<long long>(value);
35  }
36 
37  inline unsigned long stoul(const std::string& value)
38  {
39  return stoT<unsigned long>(value);
40  }
41 
42  inline int stoi(const std::string& value)
43  {
44  return stoT<int>(value);
45  }
46 
47  inline float stof(const std::string& value)
48  {
49  char* pEnd;
50  return strtof(value.c_str(), &pEnd);
51  }
52 
53  inline double stod(const std::string& value)
54  {
55  char* pEnd;
56  return strtod(value.c_str(), &pEnd);
57  }
58 
59  inline std::ios_base& hexfloat(std::ios_base& str)
60  {
61  str.setf(std::ios_base::fixed | std::ios_base::scientific, std::ios_base::floatfield);
62  return str;
63  }
64 }
65 #endif // ANDROID_NDK_MAJOR
66 
std::stoT
T stoT(const std::string &value)
Definition: android_helpers.h:24
std::to_string
std::string to_string(T value)
Definition: android_helpers.h:16
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
std::stof
float stof(const std::string &value)
Definition: android_helpers.h:47
read_bag_example.str
str
Definition: read_bag_example.py:21
value
GLfloat value
Definition: glad/glad/glad.h:2099
std::hexfloat
std::ios_base & hexfloat(std::ios_base &str)
Definition: android_helpers.h:59
std::stod
double stod(const std::string &value)
Definition: android_helpers.h:53
std::stoi
int stoi(const std::string &value)
Definition: android_helpers.h:42
std
Definition: android_helpers.h:13
x
GLdouble x
Definition: glad/glad/glad.h:2279
std::stoll
long long stoll(const std::string &value)
Definition: android_helpers.h:32
std::stoul
unsigned long stoul(const std::string &value)
Definition: android_helpers.h:37


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Mon Apr 22 2024 02:12:55