2018-12-12 02:17:40 +00:00
|
|
|
#ifndef LLARP_STR_HPP
|
|
|
|
#define LLARP_STR_HPP
|
|
|
|
|
2020-05-01 19:51:15 +00:00
|
|
|
#include <string_view>
|
2020-03-13 20:44:56 +00:00
|
|
|
#include <sstream>
|
2020-03-20 04:38:27 +00:00
|
|
|
#include <vector>
|
2019-07-02 21:28:28 +00:00
|
|
|
|
2018-12-12 02:17:40 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
StrEq(const char* s1, const char* s2);
|
2018-12-12 02:17:40 +00:00
|
|
|
|
|
|
|
bool
|
2020-05-01 19:51:15 +00:00
|
|
|
IsFalseValue(std::string_view str);
|
2019-07-02 21:28:28 +00:00
|
|
|
|
2020-02-22 19:21:08 +00:00
|
|
|
struct CaselessLessThan
|
2019-07-02 21:28:28 +00:00
|
|
|
{
|
|
|
|
bool
|
2020-05-01 19:51:15 +00:00
|
|
|
operator()(std::string_view lhs, std::string_view rhs) const;
|
2019-07-02 21:28:28 +00:00
|
|
|
};
|
2019-07-02 09:06:29 +00:00
|
|
|
|
2018-12-12 02:17:40 +00:00
|
|
|
bool
|
2020-05-01 19:51:15 +00:00
|
|
|
IsTrueValue(std::string_view str);
|
2018-12-12 02:17:40 +00:00
|
|
|
|
2020-02-23 02:23:19 +00:00
|
|
|
/// Trim leading and trailing (ascii) whitespace from the given string;
|
2020-05-01 19:51:15 +00:00
|
|
|
/// returns a std::string_view of the trimmed part of the string.
|
2020-05-12 19:42:35 +00:00
|
|
|
[[nodiscard]] std::string_view
|
2020-05-01 19:51:15 +00:00
|
|
|
TrimWhitespace(std::string_view str);
|
2020-02-22 19:55:53 +00:00
|
|
|
|
2020-04-07 20:41:11 +00:00
|
|
|
template <typename... T>
|
|
|
|
std::string
|
|
|
|
stringify(T&&... stuff)
|
2020-03-13 20:44:56 +00:00
|
|
|
{
|
|
|
|
std::ostringstream o;
|
|
|
|
(o << ... << std::forward<T>(stuff));
|
|
|
|
return o.str();
|
|
|
|
}
|
|
|
|
|
2020-03-20 04:38:27 +00:00
|
|
|
/// Split a string on a given delimiter
|
|
|
|
//
|
|
|
|
/// @param str is the string to split
|
|
|
|
/// @param delimiter is the character to split on
|
2020-05-01 19:51:15 +00:00
|
|
|
/// @return a vector of std::string_views with the split words, excluding the delimeter
|
|
|
|
std::vector<std::string_view>
|
2020-05-21 14:26:51 +00:00
|
|
|
split(const std::string_view str, char delimiter);
|
2020-03-20 04:38:27 +00:00
|
|
|
|
2018-12-12 02:17:40 +00:00
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|