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

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 // Copyright 2013 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef BASE_STRINGS_STRINGPRINTF_H_
michael@0 6 #define BASE_STRINGS_STRINGPRINTF_H_
michael@0 7
michael@0 8 #include <stdarg.h> // va_list
michael@0 9
michael@0 10 #include <string>
michael@0 11
michael@0 12 #include "base/base_export.h"
michael@0 13 #include "base/compiler_specific.h"
michael@0 14
michael@0 15 namespace base {
michael@0 16
michael@0 17 // Return a C++ string given printf-like input.
michael@0 18 BASE_EXPORT std::string StringPrintf(const char* format, ...)
michael@0 19 PRINTF_FORMAT(1, 2);
michael@0 20 // OS_ANDROID's libc does not support wchar_t, so several overloads are omitted.
michael@0 21 #if !defined(OS_ANDROID)
michael@0 22 BASE_EXPORT std::wstring StringPrintf(const wchar_t* format, ...)
michael@0 23 WPRINTF_FORMAT(1, 2);
michael@0 24 #endif
michael@0 25
michael@0 26 // Return a C++ string given vprintf-like input.
michael@0 27 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap)
michael@0 28 PRINTF_FORMAT(1, 0);
michael@0 29
michael@0 30 // Store result into a supplied string and return it.
michael@0 31 BASE_EXPORT const std::string& SStringPrintf(std::string* dst,
michael@0 32 const char* format, ...)
michael@0 33 PRINTF_FORMAT(2, 3);
michael@0 34 #if !defined(OS_ANDROID)
michael@0 35 BASE_EXPORT const std::wstring& SStringPrintf(std::wstring* dst,
michael@0 36 const wchar_t* format, ...)
michael@0 37 WPRINTF_FORMAT(2, 3);
michael@0 38 #endif
michael@0 39
michael@0 40 // Append result to a supplied string.
michael@0 41 BASE_EXPORT void StringAppendF(std::string* dst, const char* format, ...)
michael@0 42 PRINTF_FORMAT(2, 3);
michael@0 43 #if !defined(OS_ANDROID)
michael@0 44 // TODO(evanm): this is only used in a few places in the code;
michael@0 45 // replace with string16 version.
michael@0 46 BASE_EXPORT void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
michael@0 47 WPRINTF_FORMAT(2, 3);
michael@0 48 #endif
michael@0 49
michael@0 50 // Lower-level routine that takes a va_list and appends to a specified
michael@0 51 // string. All other routines are just convenience wrappers around it.
michael@0 52 BASE_EXPORT void StringAppendV(std::string* dst, const char* format, va_list ap)
michael@0 53 PRINTF_FORMAT(2, 0);
michael@0 54 #if !defined(OS_ANDROID)
michael@0 55 BASE_EXPORT void StringAppendV(std::wstring* dst,
michael@0 56 const wchar_t* format, va_list ap)
michael@0 57 WPRINTF_FORMAT(2, 0);
michael@0 58 #endif
michael@0 59
michael@0 60 } // namespace base
michael@0 61
michael@0 62 #endif // BASE_STRINGS_STRINGPRINTF_H_

mercurial