blob: b89fef5ff3653c380370d84e9769a38f8058973d [file] [log] [blame]
Eric Fiselierb08d8b12016-07-19 23:07:03 +00001#ifndef BENCHMARK_STRING_UTIL_H_
2#define BENCHMARK_STRING_UTIL_H_
3
4#include <string>
5#include <sstream>
6#include <utility>
7#include "internal_macros.h"
8
9namespace benchmark {
10
11void AppendHumanReadable(int n, std::string* str);
12
13std::string HumanReadableNumber(double n);
14
15std::string StringPrintF(const char* format, ...);
16
17inline std::ostream&
18StringCatImp(std::ostream& out) BENCHMARK_NOEXCEPT
19{
20 return out;
21}
22
23template <class First, class ...Rest>
24inline std::ostream&
25StringCatImp(std::ostream& out, First&& f, Rest&&... rest)
26{
27 out << std::forward<First>(f);
28 return StringCatImp(out, std::forward<Rest>(rest)...);
29}
30
31template<class ...Args>
32inline std::string StrCat(Args&&... args)
33{
34 std::ostringstream ss;
35 StringCatImp(ss, std::forward<Args>(args)...);
36 return ss.str();
37}
38
39void ReplaceAll(std::string* str, const std::string& from,
40 const std::string& to);
41
42} // end namespace benchmark
43
44#endif // BENCHMARK_STRING_UTIL_H_