mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-30 20:06:52 -05:00
Rework string utils, more test cases
This commit is contained in:
parent
107a3acf95
commit
3a45be4cd8
8 changed files with 371 additions and 206 deletions
99
src/str.hpp
99
src/str.hpp
|
|
@ -20,92 +20,101 @@
|
|||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace str
|
||||
{
|
||||
void
|
||||
split(const std::string_view str,
|
||||
const char delimiter,
|
||||
std::vector<std::string> *result);
|
||||
[[nodiscard]]
|
||||
std::vector<std::string>
|
||||
split(const std::string_view str,
|
||||
const char delimiter);
|
||||
|
||||
void
|
||||
split(const std::string_view str,
|
||||
const char delimiter,
|
||||
std::set<std::string> *result);
|
||||
[[nodiscard]]
|
||||
std::set<std::string>
|
||||
split_to_set(const std::string_view str,
|
||||
const char delimiter);
|
||||
|
||||
void
|
||||
split_on_null(const std::string_view str,
|
||||
std::vector<std::string> *result);
|
||||
[[nodiscard]]
|
||||
std::vector<std::string>
|
||||
split_on_null(const std::string_view str);
|
||||
|
||||
void
|
||||
lsplit1(const std::string_view &str,
|
||||
const char delimiter,
|
||||
std::vector<std::string> *result);
|
||||
[[nodiscard]]
|
||||
std::vector<std::string>
|
||||
lsplit1(const std::string_view str,
|
||||
const char delimiter);
|
||||
|
||||
void
|
||||
rsplit1(const std::string_view &str,
|
||||
const char delimiter,
|
||||
std::vector<std::string> *result);
|
||||
[[nodiscard]]
|
||||
std::vector<std::string>
|
||||
rsplit1(const std::string_view str,
|
||||
const char delimiter);
|
||||
|
||||
void
|
||||
splitkv(const std::string_view str,
|
||||
const char delimiter,
|
||||
std::string *key,
|
||||
std::string *value);
|
||||
[[nodiscard]]
|
||||
std::pair<std::string, std::string>
|
||||
splitkv(const std::string_view str,
|
||||
const char delimiter);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
join(const std::vector<std::string> &vec,
|
||||
const size_t substridx,
|
||||
const char sep);
|
||||
const size_t substridx,
|
||||
const char sep);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
join(const std::vector<std::string> &vec,
|
||||
const char sep);
|
||||
const char sep);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
join(const std::set<std::string> &s,
|
||||
const char sep);
|
||||
const char sep);
|
||||
|
||||
[[nodiscard]]
|
||||
size_t
|
||||
longest_common_prefix_index(const std::vector<std::string> &vec);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
longest_common_prefix(const std::vector<std::string> &vec);
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
remove_common_prefix_and_join(const std::vector<std::string> &vec,
|
||||
const char sep);
|
||||
const char sep);
|
||||
|
||||
void
|
||||
erase_fnmatches(const std::vector<std::string> &pattern,
|
||||
std::vector<std::string> &strs);
|
||||
erase_fnmatches(const std::vector<std::string> &patterns,
|
||||
std::vector<std::string> &strs);
|
||||
|
||||
[[nodiscard]]
|
||||
bool
|
||||
isprefix(const std::string &s0,
|
||||
const std::string &s1);
|
||||
|
||||
bool
|
||||
startswith(const std::string &str_,
|
||||
const std::string &prefix_);
|
||||
startswith(const std::string_view str,
|
||||
const std::string_view prefix) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
bool
|
||||
startswith(const char *str,
|
||||
const char *prefix);
|
||||
const char *prefix) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
bool
|
||||
endswith(const std::string &str_,
|
||||
const std::string &suffix_);
|
||||
endswith(const std::string_view str,
|
||||
const std::string_view suffix) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
trim(const std::string &str);
|
||||
trim(const std::string_view str);
|
||||
|
||||
[[nodiscard]]
|
||||
bool
|
||||
eq(const char *s0,
|
||||
const char *s1);
|
||||
const char *s1) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
std::string
|
||||
replace(const std::string &s,
|
||||
const char src,
|
||||
const char dst);
|
||||
replace(const std::string_view str,
|
||||
const char src,
|
||||
const char dst);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue