![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
Utility functions for string manipulation and validation. More...
Functions | |
std::string | validateIdentifier (const std::string &identifier) |
Validate that a string is a valid protocol identifier. | |
template<typename T > | |
T | fromString (const std::string &str) |
Convert a string to a value of type T. | |
std::string | trim (const std::string &s) |
Remove leading and trailing whitespace from a string. | |
Utility functions for string manipulation and validation.
Provides low-level helpers for validating protocol identifiers, converting strings to typed values, and trimming whitespace. These functions underpin the protocol parsing logic and ensure consistent input validation and error handling.
T irsol::protocol::utils::fromString | ( | const std::string & | str | ) |
Convert a string to a value of type T.
Parses the input string str
and converts it to the requested type T
. Supported types:
Throws std::invalid_argument
if the string contains extraneous characters after the parsed value or if conversion fails.
T | The desired output type. |
str | The string to convert. |
std::invalid_argument | on parsing errors. |
Definition at line 87 of file utils.hpp.
|
inline |
Remove leading and trailing whitespace from a string.
Trims spaces, tabs, carriage returns, and newline characters from both ends of the input string s
.
s | The input string to trim. |
s
with leading and trailing whitespace removed.Definition at line 122 of file utils.hpp.
|
inline |
Validate that a string is a valid protocol identifier.
Checks that the given identifier
string meets the following rules:
[number]
(e.g., param[0]
).If validation fails, logs an error and throws std::invalid_argument
.
identifier | The string to validate as an identifier. |
std::invalid_argument | if the string is not a valid identifier. |
Definition at line 55 of file utils.hpp.