feat/update_config #10
@ -75,11 +75,11 @@ include(cmake/BuildInfo.cmake)
|
||||
check_symbol_exists("getifaddrs" "ifaddrs.h" TILE_HAVE_GETIFADDRS)
|
||||
check_symbol_exists("freeifaddrs" "ifaddrs.h" TILE_HAVE_FREEIFADDRS)
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
get_git_commit_hash(GIT_COMMIT_HASH)
|
||||
get_git_commit_date(GIT_COMMIT_DATE)
|
||||
get_git_commit_subject(GIT_COMMIT_SUBJECT)
|
||||
# find_package(Git REQUIRED)
|
||||
#
|
||||
# get_git_commit_hash(GIT_COMMIT_HASH)
|
||||
# get_git_commit_date(GIT_COMMIT_DATE)
|
||||
# get_git_commit_subject(GIT_COMMIT_SUBJECT)
|
||||
|
||||
set(THIRD_PARTY_INCLUDE_DIRS
|
||||
# "third_party/json" "third_party/inja"
|
||||
|
@ -139,26 +139,6 @@ Trim(Slice s, Slice cutset)
|
||||
return Trim(s, [&cutset](char c) { return cutset.find(Slice(&c, 1)) != Slice::npos; });
|
||||
}
|
||||
|
||||
Slice
|
||||
TrimLeft(Slice s, std::function<bool(char)> pred)
|
||||
{
|
||||
while (!s.empty() && pred(s[0])) { s.RemovePrefix(1); }
|
||||
return s;
|
||||
}
|
||||
|
||||
Slice
|
||||
TrimRight(Slice s, std::function<bool(char)> pred)
|
||||
{
|
||||
while (!s.empty() && pred(s[s.size() - 1])) { s.RemoveSuffix(1); }
|
||||
return s;
|
||||
}
|
||||
|
||||
Slice
|
||||
Trim(Slice s, std::function<bool(char)> pred)
|
||||
{
|
||||
return TrimRight(TrimLeft(s, pred), pred);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
JoinImpl(const T &parts, Slice delim, std::string *result)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "tile/base/optional.h"
|
||||
#include "tile/base/slice.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -41,9 +42,29 @@ std::string Replace(Slice str, Slice from, Slice to, std::size_t count = std::nu
|
||||
Slice TrimLeft(Slice s, Slice cutset);
|
||||
Slice TrimRight(Slice s, Slice cutset);
|
||||
Slice Trim(Slice s, Slice cutset);
|
||||
Slice TrimLeft(Slice s, std::function<bool(char)> pred = isspace);
|
||||
Slice TrimRight(Slice s, std::function<bool(char)> pred = isspace);
|
||||
Slice Trim(Slice s, std::function<bool(char)> pred = isspace);
|
||||
|
||||
template<typename Pred = decltype(isspace)>
|
||||
Slice
|
||||
TrimLeft(Slice s, Pred pred = isspace)
|
||||
{
|
||||
while (!s.empty() && pred(s[0])) { s.RemovePrefix(1); }
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename Pred = decltype(isspace)>
|
||||
Slice
|
||||
TrimRight(Slice s, Pred pred = isspace)
|
||||
{
|
||||
while (!s.empty() && pred(s[s.size() - 1])) { s.RemoveSuffix(1); }
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename Pred = decltype(isspace)>
|
||||
Slice
|
||||
Trim(Slice s, Pred pred = isspace)
|
||||
{
|
||||
return TrimRight(TrimLeft(s, pred), pred);
|
||||
}
|
||||
|
||||
std::vector<Slice> Split(Slice s,
|
||||
char delim,
|
||||
|
Loading…
Reference in New Issue
Block a user