Debian Codegraph @

build/clang-plugin/mozsearch-plugin/StringOperations.h

raw
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef StringOperations_h
7 #define StringOperations_h
8
9 #include <memory>
10 #include <string.h>
11 #include <string>
12
13 std::string hash(const std::string &Str);
14
15 template <typename... Args>
16 inline std::string stringFormat(const std::string &Format, Args... ArgList) {
17 size_t Len = snprintf(nullptr, 0, Format.c_str(), ArgList...);
18 std::unique_ptr<char[]> Buf(new char[Len + 1]);
19 snprintf(Buf.get(), Len + 1, Format.c_str(), ArgList...);
20 return std::string(Buf.get(), Buf.get() + Len);
21 }
22
23 std::string toString(int N);
24
25 #endif