Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d22e943 authored by Casey Dahlin's avatar Casey Dahlin Committed by android-build-merger
Browse files

Merge "Make Join support string delimiters"

am: 46776e74

* commit '46776e74':
  Make Join support string delimiters
parents dcaf6932 46776e74
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@ std::vector<std::string> Split(const std::string& s,
std::string Trim(const std::string& s);

// Joins a container of things into a single string, using the given separator.
template <typename ContainerT>
std::string Join(const ContainerT& things, char separator) {
template <typename ContainerT, typename SeparatorT>
std::string Join(const ContainerT& things, SeparatorT separator) {
  if (things.empty()) {
    return "";
  }
@@ -53,6 +53,8 @@ std::string Join(const ContainerT& things, char separator) {
// We instantiate the common cases in strings.cpp.
extern template std::string Join(const std::vector<std::string>&, char);
extern template std::string Join(const std::vector<const char*>&, char);
extern template std::string Join(const std::vector<std::string>&, const std::string&);
extern template std::string Join(const std::vector<const char*>&, const std::string&);

// Tests whether 's' starts with 'prefix'.
bool StartsWith(const std::string& s, const char* prefix);
+2 −0
Original line number Diff line number Diff line
@@ -83,6 +83,8 @@ std::string Trim(const std::string& s) {
// aid compile time and binary size.
template std::string Join(const std::vector<std::string>&, char);
template std::string Join(const std::vector<const char*>&, char);
template std::string Join(const std::vector<std::string>&, const std::string&);
template std::string Join(const std::vector<const char*>&, const std::string&);

bool StartsWith(const std::string& s, const char* prefix) {
  return s.compare(0, strlen(prefix), prefix) == 0;