Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame^] | 1 | #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 | |
| 9 | namespace benchmark { |
| 10 | |
| 11 | void AppendHumanReadable(int n, std::string* str); |
| 12 | |
| 13 | std::string HumanReadableNumber(double n); |
| 14 | |
| 15 | std::string StringPrintF(const char* format, ...); |
| 16 | |
| 17 | inline std::ostream& |
| 18 | StringCatImp(std::ostream& out) BENCHMARK_NOEXCEPT |
| 19 | { |
| 20 | return out; |
| 21 | } |
| 22 | |
| 23 | template <class First, class ...Rest> |
| 24 | inline std::ostream& |
| 25 | StringCatImp(std::ostream& out, First&& f, Rest&&... rest) |
| 26 | { |
| 27 | out << std::forward<First>(f); |
| 28 | return StringCatImp(out, std::forward<Rest>(rest)...); |
| 29 | } |
| 30 | |
| 31 | template<class ...Args> |
| 32 | inline std::string StrCat(Args&&... args) |
| 33 | { |
| 34 | std::ostringstream ss; |
| 35 | StringCatImp(ss, std::forward<Args>(args)...); |
| 36 | return ss.str(); |
| 37 | } |
| 38 | |
| 39 | void 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_ |