blob: 13124d29256e64b57c5b948f8e2a8883b9e017b4 [file] [log] [blame]
henrikaf0dc5c52020-04-09 16:46:001/*
2 * Copyright 2020 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef RTC_BASE_STRINGS_STRING_FORMAT_H_
12#define RTC_BASE_STRINGS_STRING_FORMAT_H_
13
14#include <string>
15
16namespace rtc {
17
18#if defined(__GNUC__)
19#define RTC_PRINTF_FORMAT(format_param, dots_param) \
20 __attribute__((format(printf, format_param, dots_param)))
21#else
22#define RTC_PRINTF_FORMAT(format_param, dots_param)
23#endif
24
25// Return a C++ string given printf-like input.
26// Based on base::StringPrintf() in Chrome but without its fancy dynamic memory
27// allocation for any size of the input buffer.
28std::string StringFormat(const char* fmt, ...) RTC_PRINTF_FORMAT(1, 2);
29} // namespace rtc
30
31#endif // RTC_BASE_STRINGS_STRING_FORMAT_H_