string_utilities.hpp
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 #pragma once
32 
33 // C and C++ library includes
34 #include <cstdint>
35 #include <locale> // Merely for "isdigit()" function, also available in <cctype.h> C header..
36 #include <string>
37 
49 namespace string_utilities {
60  [[nodiscard]] bool toDouble(const std::string& string, double& value);
61 
74  [[nodiscard]] bool toFloat(const std::string& string, float& value);
75 
89  [[nodiscard]] bool toInt32(const std::string& string, int32_t& value, int32_t base = 10);
90 
104  [[nodiscard]] bool toUInt32(const std::string& string, uint32_t& value, int32_t base = 10);
105 
118  [[nodiscard]] int8_t toInt8(const std::string& string, int8_t& value, int32_t base = 10);
119 
132  [[nodiscard]] uint8_t toUInt8(const std::string& string, uint8_t& value, int32_t base = 10);
133 
139  [[nodiscard]] std::string trimDecimalPlaces(double num);
140 
146  [[nodiscard]] bool containsSpace(const std::string str);
147 } // namespace string_utilities
string_utilities::toInt32
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...
Definition: string_utilities.cpp:104
string_utilities::toDouble
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"'...
Definition: string_utilities.cpp:53
string_utilities
string_utilities::trimDecimalPlaces
std::string trimDecimalPlaces(double num)
Trims decimal places to three.
Definition: string_utilities.cpp:190
string_utilities::toUInt8
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...
Definition: string_utilities.cpp:179
string_utilities::toUInt32
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...
Definition: string_utilities.cpp:136
string_utilities::containsSpace
bool containsSpace(const std::string str)
Checks if a string contains spaces.
Definition: string_utilities.cpp:201
string_utilities::toInt8
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...
Definition: string_utilities.cpp:165
string_utilities::toFloat
bool toFloat(const std::string &string, float &value)
Interprets the contents of "string" as a floating point number of type float.
Definition: string_utilities.cpp:79


septentrio_gnss_driver
Author(s): Tibor Dome
autogenerated on Wed Nov 22 2023 04:04:27