string_utilities.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // © Copyright 2020, Septentrio NV/SA.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // 3. Neither the name of the copyright holder nor the names of its
14 // contributors may be used to endorse or promote products derived
15 // from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 // *****************************************************************************
30 
31 #ifndef STRING_UTILITIES_H
32 #define STRING_UTILITIES_H
33 
34 // C and C++ library includes
35 #include <cstdint>
36 #include <locale> // Merely for "isdigit()" function, also available in <cctype.h> C header..
37 #include <string>
38 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
54 namespace string_utilities {
65  bool toDouble(const std::string& string, double& value);
66 
79  bool toFloat(const std::string& string, float& value);
80 
94  bool toInt32(const std::string& string, int32_t& value, int32_t base = 10);
95 
109  bool toUInt32(const std::string& string, uint32_t& value, int32_t base = 10);
110 
123  int8_t toInt8(const std::string& string, int8_t& value, int32_t base = 10);
124 
137  uint8_t toUInt8(const std::string& string, uint8_t& value, int32_t base = 10);
138 
144  std::string trimDecimalPlaces(double num);
145 
151  bool containsSpace(const std::string str);
152 } // namespace string_utilities
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif // STRING_UTILITIES_H
bool toFloat(const std::string &string, float &value)
Interprets the contents of "string" as a floating point number of type float.
bool toDouble(const std::string &string, double &value)
Interprets the contents of "string" as a floating point number of type double It stores the "string"&#39;...
uint8_t toUInt8(const std::string &string, uint8_t &value, int32_t base=10)
Interprets the contents of "string" as a floating point number of whatever unsigned integer type your...
bool containsSpace(const std::string str)
Checks if a string contains spaces.
bool toUInt32(const std::string &string, uint32_t &value, int32_t base=10)
Interprets the contents of "string" as a floating point number of whatever unsigned integer type your...
std::string trimDecimalPlaces(double num)
Trims decimal places to two.
int8_t toInt8(const std::string &string, int8_t &value, int32_t base=10)
Interprets the contents of "string" as a floating point number of whatever integer type your system h...
bool toInt32(const std::string &string, int32_t &value, int32_t base=10)
Interprets the contents of "string" as a floating point number of whatever integer type your system h...


septentrio_gnss_driver
Author(s): Tibor Dome
autogenerated on Sat Mar 11 2023 03:12:56