26#ifndef HARNESS_STRING_INCLUDED
27#define HARNESS_STRING_INCLUDED
29#include "harness_export.h"
39std::vector<std::string> HARNESS_EXPORT
wrap_string(
const std::string &to_wrap,
41 std::size_t indent_size);
50 const std::string &suffix);
59 const std::string &prefix);
62MY_ATTRIBUTE((format(printf, 1, 2)))
68template <
class Container,
class T>
70 static std::string
impl(Container,
const std::string &);
73template <
class Container>
75 static std::string
impl(Container cont,
const std::string &delim) {
76 if (cont.begin() == cont.end())
return {};
78 std::string o(*(cont.begin()));
83 const size_t delim_size = delim.size();
85 std::accumulate(std::next(cont.begin()), cont.end(), o.size(),
86 [delim_size](
size_t sum,
const std::string &b) {
87 return sum + delim_size + b.size();
95 return std::accumulate(std::next(cont.begin()), cont.end(), o,
96 [&delim](std::string a,
const std::string &b) {
97 return a.append(delim).append(b);
101 auto it = std::next(cont.begin());
102 const auto last = cont.end();
105 for (; it !=
last; ++it) {
116template <
class Container>
117struct Join<Container, const char *> {
118 static std::string
impl(Container cont,
const std::string &delim) {
119 if (cont.begin() == cont.end())
return {};
121 return std::accumulate(std::next(cont.begin()), cont.end(),
122 std::string(*(cont.begin())),
123 [&delim](
const std::string &a,
const char *b) {
124 return a + delim + b;
150template <
class Container>
151std::string
join(Container cont,
const std::string &delim) {
159 if (v == k)
return true;
Header for compiler-dependent features.
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1052
Definition: ut0tuple.h:57
HARNESS_EXPORT std::string string_format(const char *format,...)
Definition: utilities.cc:64
std::vector< std::string > HARNESS_EXPORT wrap_string(const std::string &to_wrap, std::size_t width, std::size_t indent_size)
bool HARNESS_EXPORT ends_with(const std::string &str, const std::string &suffix)
Checks whether string ends with the specified suffix.
Definition: utilities.cc:122
bool HARNESS_EXPORT starts_with(const std::string &str, const std::string &prefix)
Checks whether string starts with the specified prefix.
Definition: utilities.cc:129
constexpr bool str_in_collection(const T &t, const std::string_view &k)
Definition: string.h:157
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:151
Definition: gcs_xcom_synode.h:64
static std::string impl(Container cont, const std::string &delim)
Definition: string.h:118
static std::string impl(Container cont, const std::string &delim)
Definition: string.h:75
static std::string impl(Container, const std::string &)