security/sandbox/chromium/base/strings/stringprintf.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/chromium/base/strings/stringprintf.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +// Copyright 2013 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef BASE_STRINGS_STRINGPRINTF_H_
     1.9 +#define BASE_STRINGS_STRINGPRINTF_H_
    1.10 +
    1.11 +#include <stdarg.h>   // va_list
    1.12 +
    1.13 +#include <string>
    1.14 +
    1.15 +#include "base/base_export.h"
    1.16 +#include "base/compiler_specific.h"
    1.17 +
    1.18 +namespace base {
    1.19 +
    1.20 +// Return a C++ string given printf-like input.
    1.21 +BASE_EXPORT std::string StringPrintf(const char* format, ...)
    1.22 +    PRINTF_FORMAT(1, 2);
    1.23 +// OS_ANDROID's libc does not support wchar_t, so several overloads are omitted.
    1.24 +#if !defined(OS_ANDROID)
    1.25 +BASE_EXPORT std::wstring StringPrintf(const wchar_t* format, ...)
    1.26 +    WPRINTF_FORMAT(1, 2);
    1.27 +#endif
    1.28 +
    1.29 +// Return a C++ string given vprintf-like input.
    1.30 +BASE_EXPORT std::string StringPrintV(const char* format, va_list ap)
    1.31 +    PRINTF_FORMAT(1, 0);
    1.32 +
    1.33 +// Store result into a supplied string and return it.
    1.34 +BASE_EXPORT const std::string& SStringPrintf(std::string* dst,
    1.35 +                                             const char* format, ...)
    1.36 +    PRINTF_FORMAT(2, 3);
    1.37 +#if !defined(OS_ANDROID)
    1.38 +BASE_EXPORT const std::wstring& SStringPrintf(std::wstring* dst,
    1.39 +                                              const wchar_t* format, ...)
    1.40 +    WPRINTF_FORMAT(2, 3);
    1.41 +#endif
    1.42 +
    1.43 +// Append result to a supplied string.
    1.44 +BASE_EXPORT void StringAppendF(std::string* dst, const char* format, ...)
    1.45 +    PRINTF_FORMAT(2, 3);
    1.46 +#if !defined(OS_ANDROID)
    1.47 +// TODO(evanm): this is only used in a few places in the code;
    1.48 +// replace with string16 version.
    1.49 +BASE_EXPORT void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
    1.50 +    WPRINTF_FORMAT(2, 3);
    1.51 +#endif
    1.52 +
    1.53 +// Lower-level routine that takes a va_list and appends to a specified
    1.54 +// string.  All other routines are just convenience wrappers around it.
    1.55 +BASE_EXPORT void StringAppendV(std::string* dst, const char* format, va_list ap)
    1.56 +    PRINTF_FORMAT(2, 0);
    1.57 +#if !defined(OS_ANDROID)
    1.58 +BASE_EXPORT void StringAppendV(std::wstring* dst,
    1.59 +                               const wchar_t* format, va_list ap)
    1.60 +    WPRINTF_FORMAT(2, 0);
    1.61 +#endif
    1.62 +
    1.63 +}  // namespace base
    1.64 +
    1.65 +#endif  // BASE_STRINGS_STRINGPRINTF_H_

mercurial