feat/update_config #10
@ -75,11 +75,11 @@ include(cmake/BuildInfo.cmake)
|
|||||||
check_symbol_exists("getifaddrs" "ifaddrs.h" TILE_HAVE_GETIFADDRS)
|
check_symbol_exists("getifaddrs" "ifaddrs.h" TILE_HAVE_GETIFADDRS)
|
||||||
check_symbol_exists("freeifaddrs" "ifaddrs.h" TILE_HAVE_FREEIFADDRS)
|
check_symbol_exists("freeifaddrs" "ifaddrs.h" TILE_HAVE_FREEIFADDRS)
|
||||||
|
|
||||||
find_package(Git REQUIRED)
|
# find_package(Git REQUIRED)
|
||||||
|
#
|
||||||
get_git_commit_hash(GIT_COMMIT_HASH)
|
# get_git_commit_hash(GIT_COMMIT_HASH)
|
||||||
get_git_commit_date(GIT_COMMIT_DATE)
|
# get_git_commit_date(GIT_COMMIT_DATE)
|
||||||
get_git_commit_subject(GIT_COMMIT_SUBJECT)
|
# get_git_commit_subject(GIT_COMMIT_SUBJECT)
|
||||||
|
|
||||||
set(THIRD_PARTY_INCLUDE_DIRS
|
set(THIRD_PARTY_INCLUDE_DIRS
|
||||||
# "third_party/json" "third_party/inja"
|
# "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; });
|
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>
|
template<typename T>
|
||||||
void
|
void
|
||||||
JoinImpl(const T &parts, Slice delim, std::string *result)
|
JoinImpl(const T &parts, Slice delim, std::string *result)
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "tile/base/optional.h"
|
#include "tile/base/optional.h"
|
||||||
#include "tile/base/slice.h"
|
#include "tile/base/slice.h"
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#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 TrimLeft(Slice s, Slice cutset);
|
||||||
Slice TrimRight(Slice s, Slice cutset);
|
Slice TrimRight(Slice s, Slice cutset);
|
||||||
Slice Trim(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);
|
template<typename Pred = decltype(isspace)>
|
||||||
Slice Trim(Slice s, std::function<bool(char)> pred = 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,
|
std::vector<Slice> Split(Slice s,
|
||||||
char delim,
|
char delim,
|
||||||
|
Loading…
Reference in New Issue
Block a user