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 | |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 4 | #include <sstream> |
Eric Fiselier | fbc9ff2 | 2016-11-05 00:30:27 +0000 | [diff] [blame] | 5 | #include <string> |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 6 | #include <utility> |
| 7 | #include "internal_macros.h" |
| 8 | |
| 9 | namespace benchmark { |
| 10 | |
| 11 | void AppendHumanReadable(int n, std::string* str); |
| 12 | |
Eric Fiselier | 1903976 | 2018-01-18 04:23:01 +0000 | [diff] [blame] | 13 | std::string HumanReadableNumber(double n, double one_k = 1024.0); |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 14 | |
| 15 | std::string StringPrintF(const char* format, ...); |
| 16 | |
Eric Fiselier | fbc9ff2 | 2016-11-05 00:30:27 +0000 | [diff] [blame] | 17 | inline std::ostream& StringCatImp(std::ostream& out) BENCHMARK_NOEXCEPT { |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 18 | return out; |
| 19 | } |
| 20 | |
Eric Fiselier | fbc9ff2 | 2016-11-05 00:30:27 +0000 | [diff] [blame] | 21 | template <class First, class... Rest> |
| 22 | inline std::ostream& StringCatImp(std::ostream& out, First&& f, |
| 23 | Rest&&... rest) { |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 24 | out << std::forward<First>(f); |
| 25 | return StringCatImp(out, std::forward<Rest>(rest)...); |
| 26 | } |
| 27 | |
Eric Fiselier | fbc9ff2 | 2016-11-05 00:30:27 +0000 | [diff] [blame] | 28 | template <class... Args> |
| 29 | inline std::string StrCat(Args&&... args) { |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 30 | std::ostringstream ss; |
| 31 | StringCatImp(ss, std::forward<Args>(args)...); |
| 32 | return ss.str(); |
| 33 | } |
| 34 | |
| 35 | void ReplaceAll(std::string* str, const std::string& from, |
| 36 | const std::string& to); |
| 37 | |
Eric Fiselier | fbc9ff2 | 2016-11-05 00:30:27 +0000 | [diff] [blame] | 38 | } // end namespace benchmark |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 39 | |
Eric Fiselier | fbc9ff2 | 2016-11-05 00:30:27 +0000 | [diff] [blame] | 40 | #endif // BENCHMARK_STRING_UTIL_H_ |