/* -*- 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/. */
/* * This code was copied from xpcom/ds/nsTextFormatter r1.3 * Memory model and Frozen linkage changes only. * -- Prasad <prasad@medhas.org>
*/
#ifdef XPCOM_GLUE # error \ "nsTextFormatter is not available in the standalone glue due to NSPR dependencies." #endif
class nsTextFormatter { public: /* * sprintf into a fixed size buffer. Guarantees that the buffer is null * terminated. Returns the length of the written output, NOT including the * null terminator, or (uint32_t)-1 if an error occurs.
*/ template <typename... T> static uint32_t snprintf(char16_t* aOut, uint32_t aOutLen, const char16_t* aFmt, T... aArgs) {
BoxedValue values[] = {BoxedValue(aArgs)...}; return vsnprintf(aOut, aOutLen, aFmt,
mozilla::Span(values, sizeof...(aArgs)));
}
/* * sprintf into an existing nsAString, overwriting any contents it already * has. Infallible.
*/ template <typename... T> staticvoid ssprintf(nsAString& aOut, const char16_t* aFmt, T... aArgs) {
BoxedValue values[] = {BoxedValue(aArgs)...};
vssprintf(aOut, aFmt, mozilla::Span(values, sizeof...(aArgs)));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.