ADTF  3.18.3
strings_convert_decl.h
Go to the documentation of this file.
1 
15 #ifndef A_UTIL_UTIL_STRINGS_STRINGS_CONVERT_DECL_HEADER_INCLUDED
16 #define A_UTIL_UTIL_STRINGS_STRINGS_CONVERT_DECL_HEADER_INCLUDED
17 
18 #include <string>
19 #include <cstdint>
20 
21 namespace a_util {
22 namespace strings {
32 bool toBool(const std::string& from, bool& to);
33 
42 bool toInt8(const std::string& from, std::int8_t& to);
44 bool toInt16(const std::string& from, std::int16_t& to);
46 bool toInt32(const std::string& from, std::int32_t& to);
48 bool toInt64(const std::string& from, std::int64_t& to);
50 bool toUInt8(const std::string& from, std::uint8_t& to);
52 bool toUInt16(const std::string& from, std::uint16_t& to);
54 bool toUInt32(const std::string& from, std::uint32_t& to);
56 bool toUInt64(const std::string& from, std::uint64_t& to);
58 bool toFloat(const std::string& from, float& to);
60 bool toDouble(const std::string& from, double& to);
61 
63 bool toBool(const char* from, bool& to);
65 bool toInt8(const char* from, std::int8_t& to);
67 bool toInt16(const char* from, std::int16_t& to);
69 bool toInt32(const char* from, std::int32_t& to);
71 bool toInt64(const char* from, std::int64_t& to);
73 bool toUInt8(const char* from, std::uint8_t& to);
75 bool toUInt16(const char* from, std::uint16_t& to);
77 bool toUInt32(const char* from, std::uint32_t& to);
79 bool toUInt64(const char* from, std::uint64_t& to);
81 bool toFloat(const char* from, float& to);
83 bool toDouble(const char* from, double& to);
84 
92 bool toBool(const std::string& from);
93 
100 std::int8_t toInt8(const std::string& from);
102 std::int16_t toInt16(const std::string& from);
104 std::int32_t toInt32(const std::string& from);
106 std::int64_t toInt64(const std::string& from);
108 std::uint8_t toUInt8(const std::string& from);
110 std::uint16_t toUInt16(const std::string& from);
112 std::uint32_t toUInt32(const std::string& from);
114 std::uint64_t toUInt64(const std::string& from);
116 float toFloat(const std::string& from);
118 double toDouble(const std::string& from);
119 
121 bool toBool(const char* from);
123 std::int8_t toInt8(const char* from);
125 std::int16_t toInt16(const char* from);
127 std::int32_t toInt32(const char* from);
129 std::int64_t toInt64(const char* from);
131 std::uint8_t toUInt8(const char* from);
133 std::uint16_t toUInt16(const char* from);
135 std::uint32_t toUInt32(const char* from);
137 std::uint64_t toUInt64(const char* from);
139 float toFloat(const char* from);
141 double toDouble(const char* from);
142 
156  static bool convert(const char* from, bool& to);
165  static bool convert(const char* from, std::int8_t& to);
167  static bool convert(const char* from, std::int16_t& to);
169  static bool convert(const char* from, std::int32_t& to);
171  static bool convert(const char* from, std::int64_t& to);
173  static bool convert(const char* from, std::uint8_t& to);
175  static bool convert(const char* from, std::uint16_t& to);
177  static bool convert(const char* from, std::uint32_t& to);
179  static bool convert(const char* from, std::uint64_t& to);
181  static bool convert(const char* from, float& to);
183  static bool convert(const char* from, double& to);
184 };
185 
195 template <typename Numeric>
196 bool toNumeric(const std::string& from, Numeric& to);
197 
199 template <typename Numeric>
200 bool toNumeric(const char* from, Numeric& to);
201 
209 template <typename Numeric>
210 Numeric toNumeric(const std::string& from);
211 
213 template <typename Numeric>
214 Numeric toNumeric(const char* from);
215 
216 } // namespace strings
217 } // namespace a_util
218 
223 #endif // A_UTIL_UTIL_STRINGS_STRINGS_CONVERT_DECL_HEADER_INCLUDED
bool toInt8(const std::string &from, std::int8_t &to)
Safely convert a string to a numeric value.
bool toNumeric(const char *from, Numeric &to)
Safely convert a string to a value of type Numeric in a generic manner.
bool toFloat(const std::string &from, float &to)
Safely convert a string to a numeric value.
bool toInt32(const std::string &from, std::int32_t &to)
Safely convert a string to a numeric value.
bool toUInt16(const std::string &from, std::uint16_t &to)
Safely convert a string to a numeric value.
bool toUInt32(const std::string &from, std::uint32_t &to)
Safely convert a string to a numeric value.
bool toInt16(const std::string &from, std::int16_t &to)
Safely convert a string to a numeric value.
bool toDouble(const std::string &from, double &to)
Safely convert a string to a numeric value.
bool toUInt8(const std::string &from, std::uint8_t &to)
Safely convert a string to a numeric value.
bool toInt64(const std::string &from, std::int64_t &to)
Safely convert a string to a numeric value.
bool toUInt64(const std::string &from, std::uint64_t &to)
Safely convert a string to a numeric value.
bool toBool(const std::string &from, bool &to)
Safely convert a string to a boolean value.
Serves as the root component, with common functionality documented in core functionality.
Definition: base.h:24
Private implementation for string conversion functions.
Safe convenience string-to-numeric conversion methods for generic programming.
static bool convert(const char *from, std::int8_t &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, double &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, std::uint64_t &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, std::uint32_t &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, std::int16_t &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, std::uint16_t &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, std::uint8_t &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, bool &to)
Safely convert a string to a boolean value.
static bool convert(const char *from, float &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, std::int32_t &to)
Safely convert a string to a numeric value.
static bool convert(const char *from, std::int64_t &to)
Safely convert a string to a numeric value.