1a8c51b3fSopenharmony_ci#ifndef BENCHMARK_STRING_UTIL_H_
2a8c51b3fSopenharmony_ci#define BENCHMARK_STRING_UTIL_H_
3a8c51b3fSopenharmony_ci
4a8c51b3fSopenharmony_ci#include <sstream>
5a8c51b3fSopenharmony_ci#include <string>
6a8c51b3fSopenharmony_ci#include <utility>
7a8c51b3fSopenharmony_ci#include <vector>
8a8c51b3fSopenharmony_ci
9a8c51b3fSopenharmony_ci#include "benchmark/benchmark.h"
10a8c51b3fSopenharmony_ci#include "benchmark/export.h"
11a8c51b3fSopenharmony_ci#include "check.h"
12a8c51b3fSopenharmony_ci#include "internal_macros.h"
13a8c51b3fSopenharmony_ci
14a8c51b3fSopenharmony_cinamespace benchmark {
15a8c51b3fSopenharmony_ci
16a8c51b3fSopenharmony_ciBENCHMARK_EXPORT
17a8c51b3fSopenharmony_cistd::string HumanReadableNumber(double n, Counter::OneK one_k);
18a8c51b3fSopenharmony_ci
19a8c51b3fSopenharmony_ciBENCHMARK_EXPORT
20a8c51b3fSopenharmony_ci#if defined(__MINGW32__)
21a8c51b3fSopenharmony_ci__attribute__((format(__MINGW_PRINTF_FORMAT, 1, 2)))
22a8c51b3fSopenharmony_ci#elif defined(__GNUC__)
23a8c51b3fSopenharmony_ci__attribute__((format(printf, 1, 2)))
24a8c51b3fSopenharmony_ci#endif
25a8c51b3fSopenharmony_cistd::string
26a8c51b3fSopenharmony_ciStrFormat(const char* format, ...);
27a8c51b3fSopenharmony_ci
28a8c51b3fSopenharmony_ciinline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT {
29a8c51b3fSopenharmony_ci  return out;
30a8c51b3fSopenharmony_ci}
31a8c51b3fSopenharmony_ci
32a8c51b3fSopenharmony_citemplate <class First, class... Rest>
33a8c51b3fSopenharmony_ciinline std::ostream& StrCatImp(std::ostream& out, First&& f, Rest&&... rest) {
34a8c51b3fSopenharmony_ci  out << std::forward<First>(f);
35a8c51b3fSopenharmony_ci  return StrCatImp(out, std::forward<Rest>(rest)...);
36a8c51b3fSopenharmony_ci}
37a8c51b3fSopenharmony_ci
38a8c51b3fSopenharmony_citemplate <class... Args>
39a8c51b3fSopenharmony_ciinline std::string StrCat(Args&&... args) {
40a8c51b3fSopenharmony_ci  std::ostringstream ss;
41a8c51b3fSopenharmony_ci  StrCatImp(ss, std::forward<Args>(args)...);
42a8c51b3fSopenharmony_ci  return ss.str();
43a8c51b3fSopenharmony_ci}
44a8c51b3fSopenharmony_ci
45a8c51b3fSopenharmony_ciBENCHMARK_EXPORT
46a8c51b3fSopenharmony_cistd::vector<std::string> StrSplit(const std::string& str, char delim);
47a8c51b3fSopenharmony_ci
48a8c51b3fSopenharmony_ci// Disable lint checking for this block since it re-implements C functions.
49a8c51b3fSopenharmony_ci// NOLINTBEGIN
50a8c51b3fSopenharmony_ci#ifdef BENCHMARK_STL_ANDROID_GNUSTL
51a8c51b3fSopenharmony_ci/*
52a8c51b3fSopenharmony_ci * GNU STL in Android NDK lacks support for some C++11 functions, including
53a8c51b3fSopenharmony_ci * stoul, stoi, stod. We reimplement them here using C functions strtoul,
54a8c51b3fSopenharmony_ci * strtol, strtod. Note that reimplemented functions are in benchmark::
55a8c51b3fSopenharmony_ci * namespace, not std:: namespace.
56a8c51b3fSopenharmony_ci */
57a8c51b3fSopenharmony_ciunsigned long stoul(const std::string& str, size_t* pos = nullptr,
58a8c51b3fSopenharmony_ci                    int base = 10);
59a8c51b3fSopenharmony_ciint stoi(const std::string& str, size_t* pos = nullptr, int base = 10);
60a8c51b3fSopenharmony_cidouble stod(const std::string& str, size_t* pos = nullptr);
61a8c51b3fSopenharmony_ci#else
62a8c51b3fSopenharmony_ciusing std::stod;   // NOLINT(misc-unused-using-decls)
63a8c51b3fSopenharmony_ciusing std::stoi;   // NOLINT(misc-unused-using-decls)
64a8c51b3fSopenharmony_ciusing std::stoul;  // NOLINT(misc-unused-using-decls)
65a8c51b3fSopenharmony_ci#endif
66a8c51b3fSopenharmony_ci// NOLINTEND
67a8c51b3fSopenharmony_ci
68a8c51b3fSopenharmony_ci}  // end namespace benchmark
69a8c51b3fSopenharmony_ci
70a8c51b3fSopenharmony_ci#endif  // BENCHMARK_STRING_UTIL_H_
71