summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 22:11:08 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 22:11:08 +0000
commitf53121d2c69801353feb2531446a1b1b93e576d4 (patch)
treeed081a0331dcb0df724fab00d043a1e5837e0857 /base
parenta75573d945926b844f7b1932b11088dd3956577d (diff)
downloadchromium_src-f53121d2c69801353feb2531446a1b1b93e576d4.zip
chromium_src-f53121d2c69801353feb2531446a1b1b93e576d4.tar.gz
chromium_src-f53121d2c69801353feb2531446a1b1b93e576d4.tar.bz2
Base: First pass at having base.dll: definition of
BASE_API and a few files that use it. BUG=76996 TEST=none Review URL: http://codereview.chromium.org/6725001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/at_exit.h3
-rw-r--r--base/base.gypi1
-rw-r--r--base/base64.h8
-rw-r--r--base/base_api.h23
-rw-r--r--base/lazy_instance.h5
-rw-r--r--base/ref_counted.h7
-rw-r--r--base/string_number_conversions.h85
-rw-r--r--base/string_piece.h5
-rw-r--r--base/string_util.h307
-rw-r--r--base/stringprintf.h27
-rw-r--r--base/synchronization/lock.h3
-rw-r--r--base/synchronization/lock_impl.h3
-rw-r--r--base/synchronization/waitable_event.h3
-rw-r--r--base/utf_string_conversions.h38
14 files changed, 285 insertions, 233 deletions
diff --git a/base/at_exit.h b/base/at_exit.h
index 15dcfc8..06214d1 100644
--- a/base/at_exit.h
+++ b/base/at_exit.h
@@ -8,6 +8,7 @@
#include <stack>
+#include "base/base_api.h"
#include "base/basictypes.h"
#include "base/synchronization/lock.h"
@@ -27,7 +28,7 @@ namespace base {
// When the exit_manager object goes out of scope, all the registered
// callbacks and singleton destructors will be called.
-class AtExitManager {
+class BASE_API AtExitManager {
public:
typedef void (*AtExitCallbackType)(void*);
diff --git a/base/base.gypi b/base/base.gypi
index 0472ae8..f48646d 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -26,6 +26,7 @@
'atomicops.h',
'atomicops_internals_x86_gcc.cc',
'atomicops_internals_x86_msvc.h',
+ 'base_api.h',
'base_paths.cc',
'base_paths.h',
'base_paths_mac.h',
diff --git a/base/base64.h b/base/base64.h
index 39cebfb..294fb83 100644
--- a/base/base64.h
+++ b/base/base64.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,15 +8,17 @@
#include <string>
+#include "base/base_api.h"
+
namespace base {
// Encodes the input string in base64. Returns true if successful and false
// otherwise. The output string is only modified if successful.
-bool Base64Encode(const std::string& input, std::string* output);
+BASE_API bool Base64Encode(const std::string& input, std::string* output);
// Decodes the base64 input string. Returns true if successful and false
// otherwise. The output string is only modified if successful.
-bool Base64Decode(const std::string& input, std::string* output);
+BASE_API bool Base64Decode(const std::string& input, std::string* output);
} // namespace base
diff --git a/base/base_api.h b/base/base_api.h
new file mode 100644
index 0000000..e3cfd28
--- /dev/null
+++ b/base/base_api.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_BASE_API_H_
+#define BASE_BASE_API_H_
+#pragma once
+
+#if !defined(BASE_IMPLEMENTATION)
+#define BASE_IMPLEMENTATION 0
+#endif
+
+#if defined(WIN32) && defined(BASE_DLL)
+#if BASE_IMPLEMENTATION
+#define BASE_API __declspec(dllexport)
+#else
+#define BASE_API __declspec(dllimport)
+#endif
+#else
+#define BASE_API
+#endif
+
+#endif // BASE_BASE_API_H_
diff --git a/base/lazy_instance.h b/base/lazy_instance.h
index a22dbf3..7b1bdc4 100644
--- a/base/lazy_instance.h
+++ b/base/lazy_instance.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -39,6 +39,7 @@
#include <new> // For placement new.
#include "base/atomicops.h"
+#include "base/base_api.h"
#include "base/basictypes.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/threading/thread_restrictions.h"
@@ -80,7 +81,7 @@ void (*LeakyLazyInstanceTraits<Type>::Delete)(void* instance) = NULL;
// We pull out some of the functionality into a non-templated base, so that we
// can implement the more complicated pieces out of line in the .cc file.
-class LazyInstanceHelper {
+class BASE_API LazyInstanceHelper {
protected:
enum {
STATE_EMPTY = 0,
diff --git a/base/ref_counted.h b/base/ref_counted.h
index 4c3aeb8..a6ebfb7 100644
--- a/base/ref_counted.h
+++ b/base/ref_counted.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,13 +7,14 @@
#pragma once
#include "base/atomic_ref_count.h"
+#include "base/base_api.h"
#include "base/threading/thread_collision_warner.h"
namespace base {
namespace subtle {
-class RefCountedBase {
+class BASE_API RefCountedBase {
public:
static bool ImplementsThreadSafeReferenceCounting() { return false; }
@@ -39,7 +40,7 @@ class RefCountedBase {
DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
};
-class RefCountedThreadSafeBase {
+class BASE_API RefCountedThreadSafeBase {
public:
static bool ImplementsThreadSafeReferenceCounting() { return true; }
diff --git a/base/string_number_conversions.h b/base/string_number_conversions.h
index c3d79b6..a4b6e3e 100644
--- a/base/string_number_conversions.h
+++ b/base/string_number_conversions.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/base_api.h"
#include "base/basictypes.h"
#include "base/string16.h"
@@ -27,21 +28,21 @@ namespace base {
// Number -> string conversions ------------------------------------------------
-std::string IntToString(int value);
-string16 IntToString16(int value);
+BASE_API std::string IntToString(int value);
+BASE_API string16 IntToString16(int value);
-std::string UintToString(unsigned value);
-string16 UintToString16(unsigned value);
+BASE_API std::string UintToString(unsigned value);
+BASE_API string16 UintToString16(unsigned value);
-std::string Int64ToString(int64 value);
-string16 Int64ToString16(int64 value);
+BASE_API std::string Int64ToString(int64 value);
+BASE_API string16 Int64ToString16(int64 value);
-std::string Uint64ToString(uint64 value);
-string16 Uint64ToString16(uint64 value);
+BASE_API std::string Uint64ToString(uint64 value);
+BASE_API string16 Uint64ToString16(uint64 value);
// DoubleToString converts the double to a string format that ignores the
// locale. If you want to use locale specific formatting, use ICU.
-std::string DoubleToString(double value);
+BASE_API std::string DoubleToString(double value);
// String -> number conversions ------------------------------------------------
@@ -57,29 +58,30 @@ std::string DoubleToString(double value);
// - No characters parseable as a number at the beginning of the string.
// |*output| will be set to 0.
// - Empty string. |*output| will be set to 0.
-bool StringToInt(const std::string& input, int* output);
-bool StringToInt(std::string::const_iterator begin,
- std::string::const_iterator end,
- int* output);
-bool StringToInt(const char* begin, const char* end, int* output);
-
-bool StringToInt(const string16& input, int* output);
-bool StringToInt(string16::const_iterator begin,
- string16::const_iterator end,
- int* output);
-bool StringToInt(const char16* begin, const char16* end, int* output);
-
-bool StringToInt64(const std::string& input, int64* output);
-bool StringToInt64(std::string::const_iterator begin,
- std::string::const_iterator end,
- int64* output);
-bool StringToInt64(const char* begin, const char* end, int64* output);
-
-bool StringToInt64(const string16& input, int64* output);
-bool StringToInt64(string16::const_iterator begin,
- string16::const_iterator end,
- int64* output);
-bool StringToInt64(const char16* begin, const char16* end, int64* output);
+BASE_API bool StringToInt(const std::string& input, int* output);
+BASE_API bool StringToInt(std::string::const_iterator begin,
+ std::string::const_iterator end,
+ int* output);
+BASE_API bool StringToInt(const char* begin, const char* end, int* output);
+
+BASE_API bool StringToInt(const string16& input, int* output);
+BASE_API bool StringToInt(string16::const_iterator begin,
+ string16::const_iterator end,
+ int* output);
+BASE_API bool StringToInt(const char16* begin, const char16* end, int* output);
+
+BASE_API bool StringToInt64(const std::string& input, int64* output);
+BASE_API bool StringToInt64(std::string::const_iterator begin,
+ std::string::const_iterator end,
+ int64* output);
+BASE_API bool StringToInt64(const char* begin, const char* end, int64* output);
+
+BASE_API bool StringToInt64(const string16& input, int64* output);
+BASE_API bool StringToInt64(string16::const_iterator begin,
+ string16::const_iterator end,
+ int64* output);
+BASE_API bool StringToInt64(const char16* begin, const char16* end,
+ int64* output);
// For floating-point conversions, only conversions of input strings in decimal
// form are defined to work. Behavior with strings representing floating-point
@@ -87,7 +89,7 @@ bool StringToInt64(const char16* begin, const char16* end, int64* output);
// NaN and inf) is undefined. Otherwise, these behave the same as the integral
// variants. This expects the input string to NOT be specific to the locale.
// If your input is locale specific, use ICU to read the number.
-bool StringToDouble(const std::string& input, double* output);
+BASE_API bool StringToDouble(const std::string& input, double* output);
// Hex encoding ----------------------------------------------------------------
@@ -97,20 +99,21 @@ bool StringToDouble(const std::string& input, double* output);
// you suspect that the data you want to format might be large, the absolute
// max size for |size| should be is
// std::numeric_limits<size_t>::max() / 2
-std::string HexEncode(const void* bytes, size_t size);
+BASE_API std::string HexEncode(const void* bytes, size_t size);
// Best effort conversion, see StringToInt above for restrictions.
-bool HexStringToInt(const std::string& input, int* output);
-bool HexStringToInt(std::string::const_iterator begin,
- std::string::const_iterator end,
- int* output);
-bool HexStringToInt(const char* begin, const char* end, int* output);
+BASE_API bool HexStringToInt(const std::string& input, int* output);
+BASE_API bool HexStringToInt(std::string::const_iterator begin,
+ std::string::const_iterator end,
+ int* output);
+BASE_API bool HexStringToInt(const char* begin, const char* end, int* output);
// Similar to the previous functions, except that output is a vector of bytes.
// |*output| will contain as many bytes as were successfully parsed prior to the
// error. There is no overflow, but input.size() must be evenly divisible by 2.
// Leading 0x or +/- are not allowed.
-bool HexStringToBytes(const std::string& input, std::vector<uint8>* output);
+BASE_API bool HexStringToBytes(const std::string& input,
+ std::vector<uint8>* output);
} // namespace base
diff --git a/base/string_piece.h b/base/string_piece.h
index 64326e1..60380b1 100644
--- a/base/string_piece.h
+++ b/base/string_piece.h
@@ -21,11 +21,12 @@
#include <string>
+#include "base/base_api.h"
#include "base/basictypes.h"
namespace base {
-class StringPiece {
+class BASE_API StringPiece {
public:
// standard STL container boilerplate
typedef size_t size_type;
@@ -163,7 +164,7 @@ class StringPiece {
size_type length_;
};
-bool operator==(const StringPiece& x, const StringPiece& y);
+BASE_API bool operator==(const StringPiece& x, const StringPiece& y);
inline bool operator!=(const StringPiece& x, const StringPiece& y) {
return !(x == y);
diff --git a/base/string_util.h b/base/string_util.h
index ed7adec..81d31d3 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -13,6 +13,7 @@
#include <string>
#include <vector>
+#include "base/base_api.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/string16.h"
@@ -35,28 +36,30 @@ namespace base {
// Compares the two strings s1 and s2 without regard to case using
// the current locale; returns 0 if they are equal, 1 if s1 > s2, and -1 if
// s2 > s1 according to a lexicographic comparison.
-int strcasecmp(const char* s1, const char* s2);
+BASE_API int strcasecmp(const char* s1, const char* s2);
// Compares up to count characters of s1 and s2 without regard to case using
// the current locale; returns 0 if they are equal, 1 if s1 > s2, and -1 if
// s2 > s1 according to a lexicographic comparison.
-int strncasecmp(const char* s1, const char* s2, size_t count);
+BASE_API int strncasecmp(const char* s1, const char* s2, size_t count);
// Same as strncmp but for char16 strings.
-int strncmp16(const char16* s1, const char16* s2, size_t count);
+BASE_API int strncmp16(const char16* s1, const char16* s2, size_t count);
// Wrapper for vsnprintf that always null-terminates and always returns the
// number of characters that would be in an untruncated formatted
// string, even when truncation occurs.
-int vsnprintf(char* buffer, size_t size, const char* format, va_list arguments)
+BASE_API int vsnprintf(char* buffer, size_t size, const char* format,
+ va_list arguments)
PRINTF_FORMAT(3, 0);
// vswprintf always null-terminates, but when truncation occurs, it will either
// return -1 or the number of characters that would be in an untruncated
// formatted string. The actual return value depends on the underlying
// C library's vswprintf implementation.
-int vswprintf(wchar_t* buffer, size_t size,
- const wchar_t* format, va_list arguments) WPRINTF_FORMAT(3, 0);
+BASE_API int vswprintf(wchar_t* buffer, size_t size,
+ const wchar_t* format, va_list arguments)
+ WPRINTF_FORMAT(3, 0);
// Some of these implementations need to be inlined.
@@ -90,8 +93,8 @@ inline int swprintf(wchar_t* buffer, size_t size, const wchar_t* format, ...) {
// long as |dst_size| is not 0. Returns the length of |src| in characters.
// If the return value is >= dst_size, then the output was truncated.
// NOTE: All sizes are in number of characters, NOT in bytes.
-size_t strlcpy(char* dst, const char* src, size_t dst_size);
-size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size);
+BASE_API size_t strlcpy(char* dst, const char* src, size_t dst_size);
+BASE_API size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size);
// Scan a wprintf format string to determine whether it's portable across a
// variety of systems. This function only checks that the conversion
@@ -114,7 +117,7 @@ size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size);
// working with wprintf.
//
// This function is intended to be called from base::vswprintf.
-bool IsWprintfFormatPortable(const wchar_t* format);
+BASE_API bool IsWprintfFormatPortable(const wchar_t* format);
// ASCII-specific tolower. The standard library's tolower is locale sensitive,
// so we don't want to use it here.
@@ -165,9 +168,9 @@ template<typename Char> struct CaseInsensitiveCompareASCII {
// have an empty string to use (e.g. in an error case). These should not be
// used as initializers, function arguments, or return values for functions
// which return by value or outparam.
-const std::string& EmptyString();
-const std::wstring& EmptyWString();
-const string16& EmptyString16();
+BASE_API const std::string& EmptyString();
+BASE_API const std::wstring& EmptyWString();
+BASE_API const string16& EmptyString16();
extern const wchar_t kWhitespaceWide[];
extern const char16 kWhitespaceUTF16[];
@@ -178,33 +181,33 @@ extern const char kUtf8ByteOrderMark[];
// Removes characters in remove_chars from anywhere in input. Returns true if
// any characters were removed.
// NOTE: Safe to use the same variable for both input and output.
-bool RemoveChars(const std::wstring& input,
- const wchar_t remove_chars[],
- std::wstring* output);
-bool RemoveChars(const string16& input,
- const char16 remove_chars[],
- string16* output);
-bool RemoveChars(const std::string& input,
- const char remove_chars[],
- std::string* output);
+BASE_API bool RemoveChars(const std::wstring& input,
+ const wchar_t remove_chars[],
+ std::wstring* output);
+BASE_API bool RemoveChars(const string16& input,
+ const char16 remove_chars[],
+ string16* output);
+BASE_API bool RemoveChars(const std::string& input,
+ const char remove_chars[],
+ std::string* output);
// Removes characters in trim_chars from the beginning and end of input.
// NOTE: Safe to use the same variable for both input and output.
-bool TrimString(const std::wstring& input,
- const wchar_t trim_chars[],
- std::wstring* output);
-bool TrimString(const string16& input,
- const char16 trim_chars[],
- string16* output);
-bool TrimString(const std::string& input,
- const char trim_chars[],
- std::string* output);
+BASE_API bool TrimString(const std::wstring& input,
+ const wchar_t trim_chars[],
+ std::wstring* output);
+BASE_API bool TrimString(const string16& input,
+ const char16 trim_chars[],
+ string16* output);
+BASE_API bool TrimString(const std::string& input,
+ const char trim_chars[],
+ std::string* output);
// Truncates a string to the nearest UTF-8 character that will leave
// the string less than or equal to the specified byte size.
-void TruncateUTF8ToByteSize(const std::string& input,
- const size_t byte_size,
- std::string* output);
+BASE_API void TruncateUTF8ToByteSize(const std::string& input,
+ const size_t byte_size,
+ std::string* output);
// Trims any whitespace from either end of the input string. Returns where
// whitespace was found.
@@ -219,21 +222,21 @@ enum TrimPositions {
TRIM_TRAILING = 1 << 1,
TRIM_ALL = TRIM_LEADING | TRIM_TRAILING,
};
-TrimPositions TrimWhitespace(const std::wstring& input,
- TrimPositions positions,
- std::wstring* output);
-TrimPositions TrimWhitespace(const string16& input,
- TrimPositions positions,
- string16* output);
-TrimPositions TrimWhitespaceASCII(const std::string& input,
- TrimPositions positions,
- std::string* output);
+BASE_API TrimPositions TrimWhitespace(const std::wstring& input,
+ TrimPositions positions,
+ std::wstring* output);
+BASE_API TrimPositions TrimWhitespace(const string16& input,
+ TrimPositions positions,
+ string16* output);
+BASE_API TrimPositions TrimWhitespaceASCII(const std::string& input,
+ TrimPositions positions,
+ std::string* output);
// Deprecated. This function is only for backward compatibility and calls
// TrimWhitespaceASCII().
-TrimPositions TrimWhitespace(const std::string& input,
- TrimPositions positions,
- std::string* output);
+BASE_API TrimPositions TrimWhitespace(const std::string& input,
+ TrimPositions positions,
+ std::string* output);
// Searches for CR or LF characters. Removes all contiguous whitespace
// strings that contain them. This is useful when trying to deal with text
@@ -243,33 +246,35 @@ TrimPositions TrimWhitespace(const std::string& input,
// (2) If |trim_sequences_with_line_breaks| is true, any other whitespace
// sequences containing a CR or LF are trimmed.
// (3) All other whitespace sequences are converted to single spaces.
-std::wstring CollapseWhitespace(const std::wstring& text,
- bool trim_sequences_with_line_breaks);
-string16 CollapseWhitespace(const string16& text,
- bool trim_sequences_with_line_breaks);
-std::string CollapseWhitespaceASCII(const std::string& text,
- bool trim_sequences_with_line_breaks);
+BASE_API std::wstring CollapseWhitespace(const std::wstring& text,
+ bool trim_sequences_with_line_breaks);
+BASE_API string16 CollapseWhitespace(const string16& text,
+ bool trim_sequences_with_line_breaks);
+BASE_API std::string CollapseWhitespaceASCII(
+ const std::string& text, bool trim_sequences_with_line_breaks);
// Returns true if the passed string is empty or contains only white-space
// characters.
-bool ContainsOnlyWhitespaceASCII(const std::string& str);
-bool ContainsOnlyWhitespace(const string16& str);
+BASE_API bool ContainsOnlyWhitespaceASCII(const std::string& str);
+BASE_API bool ContainsOnlyWhitespace(const string16& str);
// Returns true if |input| is empty or contains only characters found in
// |characters|.
-bool ContainsOnlyChars(const std::wstring& input,
- const std::wstring& characters);
-bool ContainsOnlyChars(const string16& input, const string16& characters);
-bool ContainsOnlyChars(const std::string& input, const std::string& characters);
+BASE_API bool ContainsOnlyChars(const std::wstring& input,
+ const std::wstring& characters);
+BASE_API bool ContainsOnlyChars(const string16& input,
+ const string16& characters);
+BASE_API bool ContainsOnlyChars(const std::string& input,
+ const std::string& characters);
// Converts to 7-bit ASCII by truncating. The result must be known to be ASCII
// beforehand.
-std::string WideToASCII(const std::wstring& wide);
-std::string UTF16ToASCII(const string16& utf16);
+BASE_API std::string WideToASCII(const std::wstring& wide);
+BASE_API std::string UTF16ToASCII(const string16& utf16);
// Converts the given wide string to the corresponding Latin1. This will fail
// (return false) if any characters are more than 255.
-bool WideToLatin1(const std::wstring& wide, std::string* latin1);
+BASE_API bool WideToLatin1(const std::wstring& wide, std::string* latin1);
// Returns true if the specified string matches the criteria. How can a wide
// string be 8-bit or UTF8? It contains only characters that are < 256 (in the
@@ -282,10 +287,10 @@ bool WideToLatin1(const std::wstring& wide, std::string* latin1);
// to have the maximum 'discriminating' power from other encodings. If
// there's a use case for just checking the structural validity, we have to
// add a new function for that.
-bool IsStringUTF8(const std::string& str);
-bool IsStringASCII(const std::wstring& str);
-bool IsStringASCII(const base::StringPiece& str);
-bool IsStringASCII(const string16& str);
+BASE_API bool IsStringUTF8(const std::string& str);
+BASE_API bool IsStringASCII(const std::wstring& str);
+BASE_API bool IsStringASCII(const base::StringPiece& str);
+BASE_API bool IsStringASCII(const string16& str);
// Converts the elements of the given string. This version uses a pointer to
// clearly differentiate it from the non-pointer variant.
@@ -319,55 +324,55 @@ template <class str> inline str StringToUpperASCII(const str& s) {
// string. This is useful for doing checking if an input string matches some
// token, and it is optimized to avoid intermediate string copies. This API is
// borrowed from the equivalent APIs in Mozilla.
-bool LowerCaseEqualsASCII(const std::string& a, const char* b);
-bool LowerCaseEqualsASCII(const std::wstring& a, const char* b);
-bool LowerCaseEqualsASCII(const string16& a, const char* b);
+BASE_API bool LowerCaseEqualsASCII(const std::string& a, const char* b);
+BASE_API bool LowerCaseEqualsASCII(const std::wstring& a, const char* b);
+BASE_API bool LowerCaseEqualsASCII(const string16& a, const char* b);
// Same thing, but with string iterators instead.
-bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
- std::string::const_iterator a_end,
- const char* b);
-bool LowerCaseEqualsASCII(std::wstring::const_iterator a_begin,
- std::wstring::const_iterator a_end,
- const char* b);
-bool LowerCaseEqualsASCII(string16::const_iterator a_begin,
- string16::const_iterator a_end,
- const char* b);
-bool LowerCaseEqualsASCII(const char* a_begin,
- const char* a_end,
- const char* b);
-bool LowerCaseEqualsASCII(const wchar_t* a_begin,
- const wchar_t* a_end,
- const char* b);
-bool LowerCaseEqualsASCII(const char16* a_begin,
- const char16* a_end,
- const char* b);
+BASE_API bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
+ std::string::const_iterator a_end,
+ const char* b);
+BASE_API bool LowerCaseEqualsASCII(std::wstring::const_iterator a_begin,
+ std::wstring::const_iterator a_end,
+ const char* b);
+BASE_API bool LowerCaseEqualsASCII(string16::const_iterator a_begin,
+ string16::const_iterator a_end,
+ const char* b);
+BASE_API bool LowerCaseEqualsASCII(const char* a_begin,
+ const char* a_end,
+ const char* b);
+BASE_API bool LowerCaseEqualsASCII(const wchar_t* a_begin,
+ const wchar_t* a_end,
+ const char* b);
+BASE_API bool LowerCaseEqualsASCII(const char16* a_begin,
+ const char16* a_end,
+ const char* b);
// Performs a case-sensitive string compare. The behavior is undefined if both
// strings are not ASCII.
-bool EqualsASCII(const string16& a, const base::StringPiece& b);
+BASE_API bool EqualsASCII(const string16& a, const base::StringPiece& b);
// Returns true if str starts with search, or false otherwise.
-bool StartsWithASCII(const std::string& str,
- const std::string& search,
- bool case_sensitive);
-bool StartsWith(const std::wstring& str,
- const std::wstring& search,
- bool case_sensitive);
-bool StartsWith(const string16& str,
- const string16& search,
- bool case_sensitive);
+BASE_API bool StartsWithASCII(const std::string& str,
+ const std::string& search,
+ bool case_sensitive);
+BASE_API bool StartsWith(const std::wstring& str,
+ const std::wstring& search,
+ bool case_sensitive);
+BASE_API bool StartsWith(const string16& str,
+ const string16& search,
+ bool case_sensitive);
// Returns true if str ends with search, or false otherwise.
-bool EndsWith(const std::string& str,
- const std::string& search,
- bool case_sensitive);
-bool EndsWith(const std::wstring& str,
- const std::wstring& search,
- bool case_sensitive);
-bool EndsWith(const string16& str,
- const string16& search,
- bool case_sensitive);
+BASE_API bool EndsWith(const std::string& str,
+ const std::string& search,
+ bool case_sensitive);
+BASE_API bool EndsWith(const std::wstring& str,
+ const std::wstring& search,
+ bool case_sensitive);
+BASE_API bool EndsWith(const string16& str,
+ const string16& search,
+ bool case_sensitive);
// Determines the type of ASCII character, independent of locale (the C
@@ -418,33 +423,34 @@ enum DataUnits {
// Return the unit type that is appropriate for displaying the amount of bytes
// passed in.
-DataUnits GetByteDisplayUnits(int64 bytes);
+BASE_API DataUnits GetByteDisplayUnits(int64 bytes);
// Return a byte string in human-readable format, displayed in units appropriate
// specified by 'units', with an optional unit suffix.
// Ex: FormatBytes(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB"
// Ex: FormatBytes(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1"
-string16 FormatBytes(int64 bytes, DataUnits units, bool show_units);
+BASE_API string16 FormatBytes(int64 bytes, DataUnits units, bool show_units);
// As above, but with "/s" units.
// Ex: FormatSpeed(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB/s"
// Ex: FormatSpeed(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1"
-string16 FormatSpeed(int64 bytes, DataUnits units, bool show_units);
+BASE_API string16 FormatSpeed(int64 bytes, DataUnits units, bool show_units);
// Return a number formated with separators in the user's locale way.
// Ex: FormatNumber(1234567) => 1,234,567
-string16 FormatNumber(int64 number);
+BASE_API string16 FormatNumber(int64 number);
// Starting at |start_offset| (usually 0), replace the first instance of
// |find_this| with |replace_with|.
-void ReplaceFirstSubstringAfterOffset(string16* str,
- string16::size_type start_offset,
- const string16& find_this,
- const string16& replace_with);
-void ReplaceFirstSubstringAfterOffset(std::string* str,
- std::string::size_type start_offset,
- const std::string& find_this,
- const std::string& replace_with);
+BASE_API void ReplaceFirstSubstringAfterOffset(string16* str,
+ string16::size_type start_offset,
+ const string16& find_this,
+ const string16& replace_with);
+BASE_API void ReplaceFirstSubstringAfterOffset(
+ std::string* str,
+ std::string::size_type start_offset,
+ const std::string& find_this,
+ const std::string& replace_with);
// Starting at |start_offset| (usually 0), look through |str| and replace all
// instances of |find_this| with |replace_with|.
@@ -452,14 +458,14 @@ void ReplaceFirstSubstringAfterOffset(std::string* str,
// This does entire substrings; use std::replace in <algorithm> for single
// characters, for example:
// std::replace(str.begin(), str.end(), 'a', 'b');
-void ReplaceSubstringsAfterOffset(string16* str,
- string16::size_type start_offset,
- const string16& find_this,
- const string16& replace_with);
-void ReplaceSubstringsAfterOffset(std::string* str,
- std::string::size_type start_offset,
- const std::string& find_this,
- const std::string& replace_with);
+BASE_API void ReplaceSubstringsAfterOffset(string16* str,
+ string16::size_type start_offset,
+ const string16& find_this,
+ const string16& replace_with);
+BASE_API void ReplaceSubstringsAfterOffset(std::string* str,
+ std::string::size_type start_offset,
+ const std::string& find_this,
+ const std::string& replace_with);
// This is mpcomplete's pattern for saving a string copy when dealing with
// a function that writes results into a wchar_t[] and wanting the result to
@@ -489,48 +495,49 @@ inline typename string_type::value_type* WriteInto(string_type* str,
// Splits a string into its fields delimited by any of the characters in
// |delimiters|. Each field is added to the |tokens| vector. Returns the
// number of tokens found.
-size_t Tokenize(const std::wstring& str,
- const std::wstring& delimiters,
- std::vector<std::wstring>* tokens);
-size_t Tokenize(const string16& str,
- const string16& delimiters,
- std::vector<string16>* tokens);
-size_t Tokenize(const std::string& str,
- const std::string& delimiters,
- std::vector<std::string>* tokens);
-size_t Tokenize(const base::StringPiece& str,
- const base::StringPiece& delimiters,
- std::vector<base::StringPiece>* tokens);
+BASE_API size_t Tokenize(const std::wstring& str,
+ const std::wstring& delimiters,
+ std::vector<std::wstring>* tokens);
+BASE_API size_t Tokenize(const string16& str,
+ const string16& delimiters,
+ std::vector<string16>* tokens);
+BASE_API size_t Tokenize(const std::string& str,
+ const std::string& delimiters,
+ std::vector<std::string>* tokens);
+BASE_API size_t Tokenize(const base::StringPiece& str,
+ const base::StringPiece& delimiters,
+ std::vector<base::StringPiece>* tokens);
// Does the opposite of SplitString().
-string16 JoinString(const std::vector<string16>& parts, char16 s);
-std::string JoinString(const std::vector<std::string>& parts, char s);
+BASE_API string16 JoinString(const std::vector<string16>& parts, char16 s);
+BASE_API std::string JoinString(const std::vector<std::string>& parts, char s);
// Replace $1-$2-$3..$9 in the format string with |a|-|b|-|c|..|i| respectively.
// Additionally, any number of consecutive '$' characters is replaced by that
// number less one. Eg $$->$, $$$->$$, etc. The offsets parameter here can be
// NULL. This only allows you to use up to nine replacements.
-string16 ReplaceStringPlaceholders(const string16& format_string,
- const std::vector<string16>& subst,
- std::vector<size_t>* offsets);
+BASE_API string16 ReplaceStringPlaceholders(const string16& format_string,
+ const std::vector<string16>& subst,
+ std::vector<size_t>* offsets);
-std::string ReplaceStringPlaceholders(const base::StringPiece& format_string,
- const std::vector<std::string>& subst,
- std::vector<size_t>* offsets);
+BASE_API std::string ReplaceStringPlaceholders(
+ const base::StringPiece& format_string,
+ const std::vector<std::string>& subst,
+ std::vector<size_t>* offsets);
// Single-string shortcut for ReplaceStringHolders. |offset| may be NULL.
-string16 ReplaceStringPlaceholders(const string16& format_string,
- const string16& a,
- size_t* offset);
+BASE_API string16 ReplaceStringPlaceholders(const string16& format_string,
+ const string16& a,
+ size_t* offset);
// Returns true if the string passed in matches the pattern. The pattern
// string can contain wildcards like * and ?
// The backslash character (\) is an escape character for * and ?
// We limit the patterns to having a max of 16 * or ? characters.
// ? matches 0 or 1 character, while * matches 0 or more characters.
-bool MatchPattern(const base::StringPiece& string,
- const base::StringPiece& pattern);
-bool MatchPattern(const string16& string, const string16& pattern);
+BASE_API bool MatchPattern(const base::StringPiece& string,
+ const base::StringPiece& pattern);
+BASE_API bool MatchPattern(const string16& string, const string16& pattern);
// Hack to convert any char-like type to its unsigned counterpart.
// For example, it will convert char, signed char and unsigned char to unsigned
diff --git a/base/stringprintf.h b/base/stringprintf.h
index 9170ddd..fb32f20 100644
--- a/base/stringprintf.h
+++ b/base/stringprintf.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,37 +9,42 @@
#include <string>
+#include "base/base_api.h"
#include "base/compiler_specific.h"
namespace base {
// Return a C++ string given printf-like input.
-std::string StringPrintf(const char* format, ...) PRINTF_FORMAT(1, 2);
-std::wstring StringPrintf(const wchar_t* format, ...) WPRINTF_FORMAT(1, 2);
+BASE_API std::string StringPrintf(const char* format, ...) PRINTF_FORMAT(1, 2);
+BASE_API std::wstring StringPrintf(const wchar_t* format, ...)
+ WPRINTF_FORMAT(1, 2);
// Return a C++ string given vprintf-like input.
-std::string StringPrintV(const char* format, va_list ap) PRINTF_FORMAT(1, 0);
+BASE_API std::string StringPrintV(const char* format, va_list ap)
+ PRINTF_FORMAT(1, 0);
// Store result into a supplied string and return it.
-const std::string& SStringPrintf(std::string* dst, const char* format, ...)
+BASE_API const std::string& SStringPrintf(std::string* dst,
+ const char* format, ...)
PRINTF_FORMAT(2, 3);
-const std::wstring& SStringPrintf(std::wstring* dst,
- const wchar_t* format, ...)
+BASE_API const std::wstring& SStringPrintf(std::wstring* dst,
+ const wchar_t* format, ...)
WPRINTF_FORMAT(2, 3);
// Append result to a supplied string.
-void StringAppendF(std::string* dst, const char* format, ...)
+BASE_API void StringAppendF(std::string* dst, const char* format, ...)
PRINTF_FORMAT(2, 3);
// TODO(evanm): this is only used in a few places in the code;
// replace with string16 version.
-void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
+BASE_API void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
WPRINTF_FORMAT(2, 3);
// Lower-level routine that takes a va_list and appends to a specified
// string. All other routines are just convenience wrappers around it.
-void StringAppendV(std::string* dst, const char* format, va_list ap)
+BASE_API void StringAppendV(std::string* dst, const char* format, va_list ap)
PRINTF_FORMAT(2, 0);
-void StringAppendV(std::wstring* dst, const wchar_t* format, va_list ap)
+BASE_API void StringAppendV(std::wstring* dst,
+ const wchar_t* format, va_list ap)
WPRINTF_FORMAT(2, 0);
} // namespace base
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h
index f7c9c49..46d1ab3 100644
--- a/base/synchronization/lock.h
+++ b/base/synchronization/lock.h
@@ -6,6 +6,7 @@
#define BASE_SYNCHRONIZATION_LOCK_H_
#pragma once
+#include "base/base_api.h"
#include "base/synchronization/lock_impl.h"
#include "base/threading/platform_thread.h"
@@ -14,7 +15,7 @@ namespace base {
// A convenient wrapper for an OS specific critical section. The only real
// intelligence in this class is in debug mode for the support for the
// AssertAcquired() method.
-class Lock {
+class BASE_API Lock {
public:
#if defined(NDEBUG) // Optimized wrapper implementation
Lock() : lock_() {}
diff --git a/base/synchronization/lock_impl.h b/base/synchronization/lock_impl.h
index 2994610..79bc147 100644
--- a/base/synchronization/lock_impl.h
+++ b/base/synchronization/lock_impl.h
@@ -14,6 +14,7 @@
#include <pthread.h>
#endif
+#include "base/base_api.h"
#include "base/basictypes.h"
namespace base {
@@ -22,7 +23,7 @@ namespace internal {
// This class implements the underlying platform-specific spin-lock mechanism
// used for the Lock class. Most users should not use LockImpl directly, but
// should instead use Lock.
-class LockImpl {
+class BASE_API LockImpl {
public:
#if defined(OS_WIN)
typedef CRITICAL_SECTION OSLockType;
diff --git a/base/synchronization/waitable_event.h b/base/synchronization/waitable_event.h
index 9f357d1..fe14e23 100644
--- a/base/synchronization/waitable_event.h
+++ b/base/synchronization/waitable_event.h
@@ -6,6 +6,7 @@
#define BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_
#pragma once
+#include "base/base_api.h"
#include "base/basictypes.h"
#if defined(OS_WIN)
@@ -41,7 +42,7 @@ class TimeDelta;
// by a Windows event object. This is intentional. If you are writing Windows
// specific code and you need other features of a Windows event, then you might
// be better off just using an Windows event directly.
-class WaitableEvent {
+class BASE_API WaitableEvent {
public:
// If manual_reset is true, then to set the event state to non-signaled, a
// consumer must call the Reset method. If this parameter is false, then the
diff --git a/base/utf_string_conversions.h b/base/utf_string_conversions.h
index 4aa4d41..9e4af87 100644
--- a/base/utf_string_conversions.h
+++ b/base/utf_string_conversions.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
#include <string>
+#include "base/base_api.h"
#include "base/string16.h"
#include "base/string_piece.h"
@@ -17,20 +18,23 @@
// do the best it can and put the result in the output buffer. The versions that
// return strings ignore this error and just return the best conversion
// possible.
-bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output);
-std::string WideToUTF8(const std::wstring& wide);
-bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output);
-std::wstring UTF8ToWide(const base::StringPiece& utf8);
-
-bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output);
-string16 WideToUTF16(const std::wstring& wide);
-bool UTF16ToWide(const char16* src, size_t src_len, std::wstring* output);
-std::wstring UTF16ToWide(const string16& utf16);
-
-bool UTF8ToUTF16(const char* src, size_t src_len, string16* output);
-string16 UTF8ToUTF16(const base::StringPiece& utf8);
-bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output);
-std::string UTF16ToUTF8(const string16& utf16);
+BASE_API bool WideToUTF8(const wchar_t* src, size_t src_len,
+ std::string* output);
+BASE_API std::string WideToUTF8(const std::wstring& wide);
+BASE_API bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output);
+BASE_API std::wstring UTF8ToWide(const base::StringPiece& utf8);
+
+BASE_API bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output);
+BASE_API string16 WideToUTF16(const std::wstring& wide);
+BASE_API bool UTF16ToWide(const char16* src, size_t src_len,
+ std::wstring* output);
+BASE_API std::wstring UTF16ToWide(const string16& utf16);
+
+BASE_API bool UTF8ToUTF16(const char* src, size_t src_len, string16* output);
+BASE_API string16 UTF8ToUTF16(const base::StringPiece& utf8);
+BASE_API bool UTF16ToUTF8(const char16* src, size_t src_len,
+ std::string* output);
+BASE_API std::string UTF16ToUTF8(const string16& utf16);
// We are trying to get rid of wstring as much as possible, but it's too big
// a mess to do it all at once. These conversions should be used when we
@@ -47,7 +51,7 @@ std::string UTF16ToUTF8(const string16& utf16);
// These convert an ASCII string, typically a hardcoded constant, to a
// UTF16/Wide string.
-std::wstring ASCIIToWide(const base::StringPiece& ascii);
-string16 ASCIIToUTF16(const base::StringPiece& ascii);
+BASE_API std::wstring ASCIIToWide(const base::StringPiece& ascii);
+BASE_API string16 ASCIIToUTF16(const base::StringPiece& ascii);
#endif // BASE_UTF_STRING_CONVERSIONS_H_