2015-03-09 20:18:10 +00:00
|
|
|
#ifndef BENCHMARK_STRING_UTIL_H_
|
|
|
|
#define BENCHMARK_STRING_UTIL_H_
|
2015-03-06 22:01:05 +00:00
|
|
|
|
|
|
|
#include <sstream>
|
2016-10-07 18:35:03 +00:00
|
|
|
#include <string>
|
2015-03-06 22:01:05 +00:00
|
|
|
#include <utility>
|
2015-04-13 17:45:16 +00:00
|
|
|
#include "internal_macros.h"
|
2015-03-06 22:01:05 +00:00
|
|
|
|
|
|
|
namespace benchmark {
|
|
|
|
|
|
|
|
void AppendHumanReadable(int n, std::string* str);
|
|
|
|
|
2017-08-21 23:05:24 +00:00
|
|
|
std::string HumanReadableNumber(double n, double one_k = 1024.0);
|
2015-03-06 22:01:05 +00:00
|
|
|
|
2018-03-07 11:20:06 +00:00
|
|
|
std::string StrFormat(const char* format, ...);
|
2015-03-06 22:01:05 +00:00
|
|
|
|
2018-03-07 11:20:06 +00:00
|
|
|
inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT {
|
2015-03-06 22:01:05 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2016-10-07 18:35:03 +00:00
|
|
|
template <class First, class... Rest>
|
2018-06-01 10:14:19 +00:00
|
|
|
inline std::ostream& StrCatImp(std::ostream& out, First&& f, Rest&&... rest) {
|
2015-03-06 22:01:05 +00:00
|
|
|
out << std::forward<First>(f);
|
2018-03-07 11:20:06 +00:00
|
|
|
return StrCatImp(out, std::forward<Rest>(rest)...);
|
2015-03-06 22:01:05 +00:00
|
|
|
}
|
|
|
|
|
2016-10-07 18:35:03 +00:00
|
|
|
template <class... Args>
|
|
|
|
inline std::string StrCat(Args&&... args) {
|
2015-03-06 22:01:05 +00:00
|
|
|
std::ostringstream ss;
|
2018-03-07 11:20:06 +00:00
|
|
|
StrCatImp(ss, std::forward<Args>(args)...);
|
2015-03-06 22:01:05 +00:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
2015-03-27 21:06:33 +00:00
|
|
|
void ReplaceAll(std::string* str, const std::string& from,
|
|
|
|
const std::string& to);
|
|
|
|
|
2016-10-07 18:35:03 +00:00
|
|
|
} // end namespace benchmark
|
2015-03-06 22:01:05 +00:00
|
|
|
|
2016-10-07 18:35:03 +00:00
|
|
|
#endif // BENCHMARK_STRING_UTIL_H_
|