BoosterSeat  0.1
A C++ library that includes common utilities that are used in other projects.
string_utils.hpp
Go to the documentation of this file.
1 #ifndef STRING_UTILS_HPP_
2 #define STRING_UTILS_HPP_
3 
4 #include <string>
5 
6 namespace bst {
7 
16 inline bool containsSubstring(const std::string &str, const std::string &sub) {
17  return str.find(sub) != std::string::npos;
18 }
19 
28 inline bool containsPrefix(const std::string &str, const std::string &prefix) {
29  return str.find(prefix) == 0;
30 }
31 
40 inline bool containsSuffix(const std::string &str, const std::string &suffix) {
41  return str.rfind(suffix) == str.size() - suffix.size();
42 }
43 
44 } // namespace bst
45 
46 #endif /* STRING_UTILS_HPP_ */
Definition: filesystem.cpp:34
bool containsPrefix(const std::string &str, const std::string &prefix)
Checks if a string contains a prefix.
Definition: string_utils.hpp:28
bool containsSubstring(const std::string &str, const std::string &sub)
Checks if a string contains a substring.
Definition: string_utils.hpp:16
bool containsSuffix(const std::string &str, const std::string &suffix)
Checks if a string contains a suffix.
Definition: string_utils.hpp:40