Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsPrintfCString.h
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef nsPrintfCString_h___
8
#define nsPrintfCString_h___
9
10
#include "nsString.h"
11
12
/**
13
 * nsPrintfCString lets you create a nsCString using a printf-style format
14
 * string.  For example:
15
 *
16
 *   NS_WARNING(nsPrintfCString("Unexpected value: %f", 13.917).get());
17
 *
18
 * nsPrintfCString has a small built-in auto-buffer.  For larger strings, it
19
 * will allocate on the heap.
20
 *
21
 * See also nsCString::AppendPrintf().
22
 */
23
class nsPrintfCString : public nsAutoCStringN<16>
24
{
25
  typedef nsCString string_type;
26
27
public:
28
  explicit nsPrintfCString(const char_type* aFormat, ...) MOZ_FORMAT_PRINTF(2, 3)
29
4.00k
  {
30
4.00k
    va_list ap;
31
4.00k
    va_start(ap, aFormat);
32
4.00k
    AppendPrintf(aFormat, ap);
33
4.00k
    va_end(ap);
34
4.00k
  }
35
};
36
37
#endif // !defined(nsPrintfCString_h___)