Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7001)

Unified Diff: base/string_util.h

Issue 7461141: Rename BASE_API to BASE_EXPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/string_split.h ('k') | base/stringprintf.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_util.h
===================================================================
--- base/string_util.h (revision 95578)
+++ base/string_util.h (working copy)
@@ -14,7 +14,7 @@
#include <string>
#include <vector>
-#include "base/base_api.h"
+#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/string16.h"
@@ -93,8 +93,8 @@
// 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.
-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);
+BASE_EXPORT size_t strlcpy(char* dst, const char* src, size_t dst_size);
+BASE_EXPORT 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
@@ -117,7 +117,7 @@
// working with wprintf.
//
// This function is intended to be called from base::vswprintf.
-BASE_API bool IsWprintfFormatPortable(const wchar_t* format);
+BASE_EXPORT 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.
@@ -168,43 +168,43 @@
// 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.
-BASE_API const std::string& EmptyString();
-BASE_API const std::wstring& EmptyWString();
-BASE_API const string16& EmptyString16();
+BASE_EXPORT const std::string& EmptyString();
+BASE_EXPORT const std::wstring& EmptyWString();
+BASE_EXPORT const string16& EmptyString16();
-BASE_API extern const wchar_t kWhitespaceWide[];
-BASE_API extern const char16 kWhitespaceUTF16[];
-BASE_API extern const char kWhitespaceASCII[];
+BASE_EXPORT extern const wchar_t kWhitespaceWide[];
+BASE_EXPORT extern const char16 kWhitespaceUTF16[];
+BASE_EXPORT extern const char kWhitespaceASCII[];
-BASE_API extern const char kUtf8ByteOrderMark[];
+BASE_EXPORT 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.
-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);
+BASE_EXPORT bool RemoveChars(const string16& input,
+ const char16 remove_chars[],
+ string16* output);
+BASE_EXPORT 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.
-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);
+BASE_EXPORT bool TrimString(const std::wstring& input,
+ const wchar_t trim_chars[],
+ std::wstring* output);
+BASE_EXPORT bool TrimString(const string16& input,
+ const char16 trim_chars[],
+ string16* output);
+BASE_EXPORT 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.
-BASE_API void TruncateUTF8ToByteSize(const std::string& input,
- const size_t byte_size,
- std::string* output);
+BASE_EXPORT 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,18 +219,18 @@
TRIM_TRAILING = 1 << 1,
TRIM_ALL = TRIM_LEADING | TRIM_TRAILING,
};
-BASE_API TrimPositions TrimWhitespace(const string16& input,
- TrimPositions positions,
- string16* output);
-BASE_API TrimPositions TrimWhitespaceASCII(const std::string& input,
- TrimPositions positions,
- std::string* output);
+BASE_EXPORT TrimPositions TrimWhitespace(const string16& input,
+ TrimPositions positions,
+ string16* output);
+BASE_EXPORT TrimPositions TrimWhitespaceASCII(const std::string& input,
+ TrimPositions positions,
+ std::string* output);
// Deprecated. This function is only for backward compatibility and calls
// TrimWhitespaceASCII().
-BASE_API TrimPositions TrimWhitespace(const std::string& input,
- TrimPositions positions,
- std::string* output);
+BASE_EXPORT 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
@@ -240,35 +240,38 @@
// (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.
-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);
+BASE_EXPORT std::wstring CollapseWhitespace(
+ const std::wstring& text,
+ bool trim_sequences_with_line_breaks);
+BASE_EXPORT string16 CollapseWhitespace(
+ const string16& text,
+ bool trim_sequences_with_line_breaks);
+BASE_EXPORT 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.
-BASE_API bool ContainsOnlyWhitespaceASCII(const std::string& str);
-BASE_API bool ContainsOnlyWhitespace(const string16& str);
+BASE_EXPORT bool ContainsOnlyWhitespaceASCII(const std::string& str);
+BASE_EXPORT bool ContainsOnlyWhitespace(const string16& str);
// Returns true if |input| is empty or contains only characters found in
// |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);
+BASE_EXPORT bool ContainsOnlyChars(const std::wstring& input,
+ const std::wstring& characters);
+BASE_EXPORT bool ContainsOnlyChars(const string16& input,
+ const string16& characters);
+BASE_EXPORT 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.
-BASE_API std::string WideToASCII(const std::wstring& wide);
-BASE_API std::string UTF16ToASCII(const string16& utf16);
+BASE_EXPORT std::string WideToASCII(const std::wstring& wide);
+BASE_EXPORT 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.
-BASE_API bool WideToLatin1(const std::wstring& wide, std::string* latin1);
+BASE_EXPORT 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
@@ -281,10 +284,10 @@
// 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.
-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);
+BASE_EXPORT bool IsStringUTF8(const std::string& str);
+BASE_EXPORT bool IsStringASCII(const std::wstring& str);
+BASE_EXPORT bool IsStringASCII(const base::StringPiece& str);
+BASE_EXPORT 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.
@@ -318,55 +321,55 @@
// 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.
-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);
+BASE_EXPORT bool LowerCaseEqualsASCII(const std::string& a, const char* b);
+BASE_EXPORT bool LowerCaseEqualsASCII(const std::wstring& a, const char* b);
+BASE_EXPORT bool LowerCaseEqualsASCII(const string16& a, const char* b);
// Same thing, but with string iterators instead.
-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);
+BASE_EXPORT bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
+ std::string::const_iterator a_end,
+ const char* b);
+BASE_EXPORT bool LowerCaseEqualsASCII(std::wstring::const_iterator a_begin,
+ std::wstring::const_iterator a_end,
+ const char* b);
+BASE_EXPORT bool LowerCaseEqualsASCII(string16::const_iterator a_begin,
+ string16::const_iterator a_end,
+ const char* b);
+BASE_EXPORT bool LowerCaseEqualsASCII(const char* a_begin,
+ const char* a_end,
+ const char* b);
+BASE_EXPORT bool LowerCaseEqualsASCII(const wchar_t* a_begin,
+ const wchar_t* a_end,
+ const char* b);
+BASE_EXPORT 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.
-BASE_API bool EqualsASCII(const string16& a, const base::StringPiece& b);
+BASE_EXPORT bool EqualsASCII(const string16& a, const base::StringPiece& b);
// Returns true if str starts with search, or false otherwise.
-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);
+BASE_EXPORT bool StartsWithASCII(const std::string& str,
+ const std::string& search,
+ bool case_sensitive);
+BASE_EXPORT bool StartsWith(const std::wstring& str,
+ const std::wstring& search,
+ bool case_sensitive);
+BASE_EXPORT bool StartsWith(const string16& str,
+ const string16& search,
+ bool case_sensitive);
// Returns true if str ends with search, or false otherwise.
-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);
+BASE_EXPORT bool EndsWith(const std::string& str,
+ const std::string& search,
+ bool case_sensitive);
+BASE_EXPORT bool EndsWith(const std::wstring& str,
+ const std::wstring& search,
+ bool case_sensitive);
+BASE_EXPORT bool EndsWith(const string16& str,
+ const string16& search,
+ bool case_sensitive);
// Determines the type of ASCII character, independent of locale (the C
@@ -412,15 +415,16 @@
// appropriate for use in any UI; use of FormatBytes and friends in ui/base is
// highly recommended instead. TODO(avi): Figure out how to get callers to use
// FormatBytes instead; remove this.
-BASE_API string16 FormatBytesUnlocalized(int64 bytes);
+BASE_EXPORT string16 FormatBytesUnlocalized(int64 bytes);
// Starting at |start_offset| (usually 0), replace the first instance of
// |find_this| with |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(
+BASE_EXPORT void ReplaceFirstSubstringAfterOffset(
+ string16* str,
+ string16::size_type start_offset,
+ const string16& find_this,
+ const string16& replace_with);
+BASE_EXPORT void ReplaceFirstSubstringAfterOffset(
std::string* str,
std::string::size_type start_offset,
const std::string& find_this,
@@ -432,14 +436,16 @@
// This does entire substrings; use std::replace in <algorithm> for single
// characters, for example:
// std::replace(str.begin(), str.end(), 'a', 'b');
-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);
+BASE_EXPORT void ReplaceSubstringsAfterOffset(
+ string16* str,
+ string16::size_type start_offset,
+ const string16& find_this,
+ const string16& replace_with);
+BASE_EXPORT 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
@@ -469,49 +475,51 @@
// 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.
-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);
+BASE_EXPORT size_t Tokenize(const std::wstring& str,
+ const std::wstring& delimiters,
+ std::vector<std::wstring>* tokens);
+BASE_EXPORT size_t Tokenize(const string16& str,
+ const string16& delimiters,
+ std::vector<string16>* tokens);
+BASE_EXPORT size_t Tokenize(const std::string& str,
+ const std::string& delimiters,
+ std::vector<std::string>* tokens);
+BASE_EXPORT size_t Tokenize(const base::StringPiece& str,
+ const base::StringPiece& delimiters,
+ std::vector<base::StringPiece>* tokens);
// Does the opposite of SplitString().
-BASE_API string16 JoinString(const std::vector<string16>& parts, char16 s);
-BASE_API std::string JoinString(const std::vector<std::string>& parts, char s);
+BASE_EXPORT string16 JoinString(const std::vector<string16>& parts, char16 s);
+BASE_EXPORT 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.
-BASE_API string16 ReplaceStringPlaceholders(const string16& format_string,
- const std::vector<string16>& subst,
- std::vector<size_t>* offsets);
+BASE_EXPORT string16 ReplaceStringPlaceholders(
+ const string16& format_string,
+ const std::vector<string16>& subst,
+ std::vector<size_t>* offsets);
-BASE_API std::string ReplaceStringPlaceholders(
+BASE_EXPORT 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.
-BASE_API string16 ReplaceStringPlaceholders(const string16& format_string,
- const string16& a,
- size_t* offset);
+BASE_EXPORT 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.
-BASE_API bool MatchPattern(const base::StringPiece& string,
- const base::StringPiece& pattern);
-BASE_API bool MatchPattern(const string16& string, const string16& pattern);
+BASE_EXPORT bool MatchPattern(const base::StringPiece& string,
+ const base::StringPiece& pattern);
+BASE_EXPORT 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
« no previous file with comments | « base/string_split.h ('k') | base/stringprintf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698