The SqlError exception and small string helpers used everywhere.
More...
#include <optional>
#include <stdexcept>
#include <string>
#include <string_view>
Go to the source code of this file.
|
| std::string_view | tinysql::trimRight (std::string_view text) |
| | Removes trailing spaces, tabs and line ends.
|
| |
| std::string_view | tinysql::trim (std::string_view text) |
| | Removes leading and trailing spaces, tabs and line ends.
|
| |
| std::string | tinysql::toUpper (std::string_view text) |
| | Converts ASCII letters to upper case.
|
| |
| bool | tinysql::equalsIgnoreCase (std::string_view a, std::string_view b) |
| | Compares two strings, ignoring the case of ASCII letters.
|
| |
| bool | tinysql::matchesLike (std::string_view text, std::string_view pattern) |
| | Matches text against an SQL LIKE pattern, ignoring the case of ASCII letters.
|
| |
| std::optional< long long > | tinysql::parseInteger (std::string_view text) |
| | Parses a whole string as a base-10 integer.
|
| |
The SqlError exception and small string helpers used everywhere.
Definition in file Util.hpp.
◆ equalsIgnoreCase()
| bool tinysql::equalsIgnoreCase |
( |
std::string_view |
a, |
|
|
std::string_view |
b |
|
) |
| |
Compares two strings, ignoring the case of ASCII letters.
- Parameters
-
| a | First string. |
| b | Second string. |
- Returns
- True if
a and b are equal apart from upper/lower case.
Definition at line 49 of file Util.cpp.
◆ matchesLike()
| bool tinysql::matchesLike |
( |
std::string_view |
text, |
|
|
std::string_view |
pattern |
|
) |
| |
Matches text against an SQL LIKE pattern, ignoring the case of ASCII letters.
In the pattern, % stands for any text (also none) and _ for exactly one character; every other character must match itself. For example fran% matches "Francesco" and "FRANCO", and _uigi matches "Luigi". Characters are counted in bytes, so _ does not match an accented letter such as ò, which takes 2 bytes in UTF-8; use % there.
- Parameters
-
| text | The text to test. |
| pattern | The pattern. |
- Returns
- True if the whole text matches the whole pattern.
Definition at line 54 of file Util.cpp.
◆ parseInteger()
| std::optional< long long > tinysql::parseInteger |
( |
std::string_view |
text | ) |
|
Parses a whole string as a base-10 integer.
- Parameters
-
| text | The text to parse; surrounding whitespace and a leading + are allowed. |
- Returns
- The number, or
std::nullopt if text is not exactly one integer.
Definition at line 82 of file Util.cpp.
◆ toUpper()
| std::string tinysql::toUpper |
( |
std::string_view |
text | ) |
|
Converts ASCII letters to upper case.
- Parameters
-
- Returns
- An upper-case copy of
text.
Definition at line 42 of file Util.cpp.
◆ trim()
| std::string_view tinysql::trim |
( |
std::string_view |
text | ) |
|
Removes leading and trailing spaces, tabs and line ends.
- Parameters
-
| text | The text to trim; it is not copied. |
- Returns
- A view of
text without whitespace at either end.
Definition at line 34 of file Util.cpp.
◆ trimRight()
| std::string_view tinysql::trimRight |
( |
std::string_view |
text | ) |
|
Removes trailing spaces, tabs and line ends.
- Parameters
-
| text | The text to trim; it is not copied. |
- Returns
- A view of
text without its trailing whitespace.
Definition at line 26 of file Util.cpp.