PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
string_utility.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_DETAIL_STRING_UTILITY_HPP_
13 #define PLSSVM_DETAIL_STRING_UTILITY_HPP_
14 #pragma once
15 
16 #include <string> // std::string
17 #include <string_view> // std::string_view
18 #include <vector> // std::vector
19 
20 namespace plssvm::detail {
21 
28 [[nodiscard]] bool starts_with(std::string_view str, std::string_view sv) noexcept;
35 [[nodiscard]] bool starts_with(std::string_view str, char c) noexcept;
42 [[nodiscard]] bool ends_with(std::string_view str, std::string_view sv) noexcept;
49 [[nodiscard]] bool ends_with(std::string_view str, char c) noexcept;
56 [[nodiscard]] bool contains(std::string_view str, std::string_view sv) noexcept;
63 [[nodiscard]] bool contains(std::string_view str, char c) noexcept;
64 
70 [[nodiscard]] std::string_view trim_left(std::string_view str) noexcept;
76 [[nodiscard]] std::string_view trim_right(std::string_view str) noexcept;
82 [[nodiscard]] std::string_view trim(std::string_view str) noexcept;
83 
91 std::string &replace_all(std::string &str, std::string_view what, std::string_view with);
92 
98 std::string &to_lower_case(std::string &str);
99 
106 [[nodiscard]] std::string as_lower_case(std::string_view str);
107 
113 std::string &to_upper_case(std::string &str);
114 
121 [[nodiscard]] std::string as_upper_case(std::string_view str);
122 
129 [[nodiscard]] std::vector<std::string_view> split(std::string_view str, char delim = ' ');
130 
131 } // namespace plssvm::detail
132 
133 #endif // PLSSVM_DETAIL_STRING_UTILITY_HPP_
Namespace containing implementation details. Should not directly be used by users.
Definition: csvm.hpp:27
bool starts_with(std::string_view str, std::string_view sv) noexcept
Checks if the string str starts with the prefix sv.
std::string as_upper_case(std::string_view str)
Return a new string with the same content as str but all upper case.
std::string & to_upper_case(std::string &str)
Convert the string str to its all upper case representation.
std::string_view trim(std::string_view str) noexcept
Returns a new std::string_view equal to str where all leading and trailing whitespaces are removed.
std::string_view trim_left(std::string_view str) noexcept
Returns a new std::string_view equal to str where all leading whitespaces are removed.
bool ends_with(std::string_view str, std::string_view sv) noexcept
Checks if the string str ends with the suffix sv.
std::string_view trim_right(std::string_view str) noexcept
Returns a new std::string_view equal to str where all trailing whitespaces are removed.
std::vector< std::string_view > split(std::string_view str, char delim=' ')
Split the string str at the positions with delimiter delim and return the sub-strings.
bool contains(std::string_view str, std::string_view sv) noexcept
Checks if the string str contains the string sv.
std::string as_lower_case(std::string_view str)
Return a new string with the same content as str but all lower case.
std::string & to_lower_case(std::string &str)
Convert the string str to its all lower case representation.
std::string & replace_all(std::string &str, std::string_view what, std::string_view with)
Replaces all occurrences of what with with in the string str.