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>
16  inline std::string to_string(T value)
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 
float stof(const std::string &value)
T stoT(const std::string &value)
GLfloat value
GLdouble x
long long stoll(const std::string &value)
double stod(const std::string &value)
int stoi(const std::string &value)
std::ios_base & hexfloat(std::ios_base &str)
unsigned long stoul(const std::string &value)
std::string to_string(T value)


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Thu Dec 22 2022 03:41:41