2014-08-04 03:50:28 +08:00
|
|
|
/*
|
2016-01-15 05:50:22 +08:00
|
|
|
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2014-08-04 03:50:28 +08:00
|
|
|
*/
|
|
|
|
|
2017-06-30 23:15:20 +08:00
|
|
|
#pragma once
|
2016-12-23 11:46:20 +08:00
|
|
|
|
2020-12-20 04:06:08 +08:00
|
|
|
#include <set>
|
2014-08-04 03:50:28 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace str
|
|
|
|
{
|
2014-11-11 10:01:20 +08:00
|
|
|
void
|
2020-08-17 06:22:25 +08:00
|
|
|
split(const char *str,
|
|
|
|
const char delimiter,
|
|
|
|
std::vector<std::string> *result);
|
2016-01-30 05:54:39 +08:00
|
|
|
void
|
2020-08-17 06:22:25 +08:00
|
|
|
split(const std::string &str,
|
|
|
|
const char delimiter,
|
|
|
|
std::vector<std::string> *result);
|
2014-08-04 03:50:28 +08:00
|
|
|
|
2023-02-12 01:11:45 +08:00
|
|
|
void
|
|
|
|
split(const char *str,
|
|
|
|
const char delimiter,
|
|
|
|
std::set<std::string> *result);
|
|
|
|
void
|
|
|
|
split(const std::string &str,
|
|
|
|
const char delimiter,
|
|
|
|
std::set<std::string> *result);
|
|
|
|
|
2020-08-21 06:47:04 +08:00
|
|
|
void
|
|
|
|
rsplit1(const std::string &str,
|
|
|
|
const char delimiter,
|
|
|
|
std::vector<std::string> *result);
|
|
|
|
|
2019-09-24 22:27:46 +08:00
|
|
|
void
|
|
|
|
splitkv(const std::string &str,
|
|
|
|
const char delimiter,
|
|
|
|
std::string *key,
|
|
|
|
std::string *value);
|
|
|
|
|
2014-11-11 10:01:20 +08:00
|
|
|
std::string
|
|
|
|
join(const std::vector<std::string> &vec,
|
2015-01-23 05:30:12 +08:00
|
|
|
const size_t substridx,
|
2014-11-11 10:01:20 +08:00
|
|
|
const char sep);
|
2015-01-23 05:30:12 +08:00
|
|
|
|
|
|
|
std::string
|
|
|
|
join(const std::vector<std::string> &vec,
|
|
|
|
const char sep);
|
|
|
|
|
2020-12-20 04:06:08 +08:00
|
|
|
std::string
|
|
|
|
join(const std::set<std::string> &s,
|
|
|
|
const char sep);
|
|
|
|
|
2015-01-23 05:30:12 +08:00
|
|
|
size_t
|
|
|
|
longest_common_prefix_index(const std::vector<std::string> &vec);
|
|
|
|
|
|
|
|
std::string
|
|
|
|
longest_common_prefix(const std::vector<std::string> &vec);
|
|
|
|
|
|
|
|
std::string
|
|
|
|
remove_common_prefix_and_join(const std::vector<std::string> &vec,
|
|
|
|
const char sep);
|
2015-02-19 22:09:24 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
erase_fnmatches(const std::vector<std::string> &pattern,
|
|
|
|
std::vector<std::string> &strs);
|
2015-09-04 04:56:54 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
isprefix(const std::string &s0,
|
|
|
|
const std::string &s1);
|
2018-10-21 11:40:02 +08:00
|
|
|
|
|
|
|
bool
|
2019-09-24 22:27:46 +08:00
|
|
|
startswith(const std::string &str_,
|
|
|
|
const std::string &prefix_);
|
|
|
|
|
|
|
|
bool
|
|
|
|
endswith(const std::string &str_,
|
|
|
|
const std::string &suffix_);
|
|
|
|
|
|
|
|
std::string
|
|
|
|
trim(const std::string &str);
|
2014-08-04 03:50:28 +08:00
|
|
|
}
|