summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/benchmark/src/string_util.h
blob: b89fef5ff3653c380370d84e9769a38f8058973d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef BENCHMARK_STRING_UTIL_H_
#define BENCHMARK_STRING_UTIL_H_

#include <string>
#include <sstream>
#include <utility>
#include "internal_macros.h"

namespace benchmark {

void AppendHumanReadable(int n, std::string* str);

std::string HumanReadableNumber(double n);

std::string StringPrintF(const char* format, ...);

inline std::ostream&
StringCatImp(std::ostream& out) BENCHMARK_NOEXCEPT
{
  return out;
}

template <class First, class ...Rest>
inline std::ostream&
StringCatImp(std::ostream& out, First&& f, Rest&&... rest)
{
  out << std::forward<First>(f);
  return StringCatImp(out, std::forward<Rest>(rest)...);
}

template<class ...Args>
inline std::string StrCat(Args&&... args)
{
  std::ostringstream ss;
  StringCatImp(ss, std::forward<Args>(args)...);
  return ss.str();
}

void ReplaceAll(std::string* str, const std::string& from,
                const std::string& to);

} // end namespace benchmark

#endif // BENCHMARK_STRING_UTIL_H_