xpcom/string/public/nsPrintfCString.h
author B2G Bumper Bot <release+b2gbumper@mozilla.com>
Thu, 03 Jul 2014 12:45:48 -0700
changeset 228688 bf28e868def9317c9b5e4833a9312ad3778603e1
parent 185144 eb3b772bac41bcc5d684bdf10a12d12e5ccbf54f
child 190641 645ad2c2411421798c8e815bcd74aa8092aa066f
permissions -rw-r--r--
Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-2_0/rev/8536587e8be9 Author: Ryan VanderMeulen <rvandermeulen@mozilla.com> Desc: Merge pull request #21354 from justindarc/bug1031012-v2.0 Bug 1031012 - [B2G][Camera]Self-timer cannot be canceled ======== https://hg.mozilla.org/integration/gaia-2_0/rev/5cd63a65a51e Author: Justin D'Arcangelo <justindarc@gmail.com> Desc: Bug 1031012 - [B2G][Camera]Self-timer cannot be canceled

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsPrintfCString_h___
#define nsPrintfCString_h___

#include "nsString.h"

/**
 * nsPrintfCString lets you create a nsCString using a printf-style format
 * string.  For example:
 *
 *   NS_WARNING(nsPrintfCString("Unexpected value: %f", 13.917).get());
 *
 * nsPrintfCString has a small built-in auto-buffer.  For larger strings, it
 * will allocate on the heap.
 *
 * See also nsCString::AppendPrintf().
 */
class nsPrintfCString : public nsFixedCString
{
  typedef nsCString string_type;

public:
  explicit nsPrintfCString(const char_type* aFormat, ...)
    : nsFixedCString(mLocalBuffer, kLocalBufferSize, 0)
  {
    va_list ap;
    va_start(ap, aFormat);
    AppendPrintf(aFormat, ap);
    va_end(ap);
  }

private:
  static const uint32_t kLocalBufferSize = 16;
  char_type mLocalBuffer[kLocalBufferSize];
};

#endif // !defined(nsPrintfCString_h___)