2023-01-07 11:24:02 -05:00
|
|
|
#pragma once
|
|
|
|
|
2022-11-29 19:22:22 -05:00
|
|
|
#include <string>
|
2023-01-07 11:24:02 -05:00
|
|
|
#include <vector>
|
2022-11-29 19:22:22 -05:00
|
|
|
|
|
|
|
namespace str_util {
|
2023-01-02 09:45:38 -05:00
|
|
|
bool contains(const std::string& s, const std::string& substr);
|
2022-11-29 19:22:22 -05:00
|
|
|
bool starts_with(const std::string& s, const std::string& prefix);
|
2023-05-21 17:24:23 -04:00
|
|
|
bool ends_with(const std::string& s, const std::string& suffix);
|
2023-06-18 17:19:35 -04:00
|
|
|
std::string ltrim_newlines(const std::string& s);
|
2022-11-29 19:22:22 -05:00
|
|
|
std::string ltrim(const std::string& s);
|
|
|
|
std::string rtrim(const std::string& s);
|
|
|
|
std::string trim(const std::string& s);
|
2023-01-15 11:33:39 -05:00
|
|
|
/// Given a string with new-lines, split and trim the leading whitespace from each line
|
|
|
|
/// then return the string with the new-lines back in place.
|
|
|
|
std::string trim_newline_indents(const std::string& s);
|
2022-12-22 13:41:33 -05:00
|
|
|
int line_count(const std::string& str);
|
2023-01-02 09:45:38 -05:00
|
|
|
bool valid_regex(const std::string& regex);
|
2023-01-07 11:24:02 -05:00
|
|
|
std::string diff(const std::string& lhs, const std::string& rhs);
|
|
|
|
/// Default splits on \n characters
|
2024-01-18 20:32:30 -05:00
|
|
|
/// DEPRECATED - stop using it, limited as it only takes a char
|
2023-01-07 11:24:02 -05:00
|
|
|
std::vector<std::string> split(const ::std::string& str, char delimiter = '\n');
|
2024-01-18 20:32:30 -05:00
|
|
|
std::vector<std::string> split_string(const std::string& str, const std::string& delimiter = "\n");
|
2023-01-15 11:33:39 -05:00
|
|
|
std::string join(const std::vector<std::string>& strs, const std::string& join_with);
|
2023-02-20 19:49:37 -05:00
|
|
|
std::vector<std::string> regex_get_capture_groups(const std::string& str, const std::string& regex);
|
2023-04-24 23:46:55 -04:00
|
|
|
bool replace(std::string& str, const std::string& from, const std::string& to);
|
2023-06-07 20:04:16 -04:00
|
|
|
std::string lower(const std::string& str);
|
2023-05-21 17:24:23 -04:00
|
|
|
std::string uuid();
|
2023-05-28 13:22:00 -04:00
|
|
|
std::string repeat(size_t n, const std::string& str);
|
2023-06-04 15:34:37 -04:00
|
|
|
std::string current_local_timestamp();
|
|
|
|
std::string current_local_timestamp_no_colons();
|
|
|
|
std::string current_isotimestamp();
|
|
|
|
std::string to_upper(const std::string& str);
|
|
|
|
std::string to_lower(const std::string& str);
|
2023-07-08 21:53:39 -04:00
|
|
|
/// Is this a valid character for a hex number?
|
|
|
|
bool hex_char(char c);
|
2023-09-23 15:08:13 -04:00
|
|
|
std::string titlize(const std::string& str);
|
2024-02-27 20:12:44 -05:00
|
|
|
std::string pad_right(const std::string& input, const int width, const char padding_char);
|
2022-11-29 19:22:22 -05:00
|
|
|
} // namespace str_util
|