diff options
author | Adam Cozzette <acozzette@google.com> | 2018-01-19 16:46:57 -0800 |
---|---|---|
committer | Adam Cozzette <acozzette@acozzette0.svl.corp.google.com> | 2018-01-26 16:17:14 -0800 |
commit | 39a789e657a52e835c281233b63cc2a6bb387fd4 (patch) | |
tree | 18954017db14eb09c290ddbe0425a212b14d2b28 /src/google/protobuf/stubs | |
parent | c236896ec5a7f9c0b021f14be61ee2e0a2c7a91b (diff) | |
download | protobuf-39a789e657a52e835c281233b63cc2a6bb387fd4.tar.gz protobuf-39a789e657a52e835c281233b63cc2a6bb387fd4.tar.bz2 protobuf-39a789e657a52e835c281233b63cc2a6bb387fd4.zip |
Removed using statements from common.h
These statements pulled a bunch of symbols from the std namespace into
the global namespace. This commit removes all of them except for
std::string, which is a bit trickier to remove.
Diffstat (limited to 'src/google/protobuf/stubs')
-rwxr-xr-x | src/google/protobuf/stubs/common.cc | 6 | ||||
-rw-r--r-- | src/google/protobuf/stubs/common.h | 5 | ||||
-rw-r--r-- | src/google/protobuf/stubs/common_unittest.cc | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/hash.h | 8 | ||||
-rw-r--r-- | src/google/protobuf/stubs/map_util.h | 4 | ||||
-rw-r--r-- | src/google/protobuf/stubs/status.cc | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/status.h | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/stringprintf.cc | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/stringprintf.h | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/strutil.cc | 14 | ||||
-rw-r--r-- | src/google/protobuf/stubs/strutil.h | 20 | ||||
-rw-r--r-- | src/google/protobuf/stubs/strutil_unittest.cc | 2 | ||||
-rw-r--r-- | src/google/protobuf/stubs/type_traits_unittest.cc | 2 |
13 files changed, 33 insertions, 38 deletions
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 73822168..574c7405 100755 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -430,9 +430,9 @@ struct ShutdownData { } } - vector<void (*)()> functions; - vector<const std::string*> strings; - vector<const MessageLite*> messages; + std::vector<void (*)()> functions; + std::vector<const std::string*> strings; + std::vector<const MessageLite*> messages; Mutex mutex; }; diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index d11b8100..04660b81 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -229,12 +229,7 @@ class FatalException : public std::exception { // This is at the end of the file instead of the beginning to work around a bug // in some versions of MSVC. -// TODO(acozzette): remove these using statements -using std::istream; -using std::ostream; -using std::pair; using std::string; -using std::vector; } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/common_unittest.cc b/src/google/protobuf/stubs/common_unittest.cc index f9e2cfd4..798a2a27 100644 --- a/src/google/protobuf/stubs/common_unittest.cc +++ b/src/google/protobuf/stubs/common_unittest.cc @@ -75,7 +75,7 @@ TEST(CommonTest, IntMinMaxConstants) { EXPECT_EQ(0, kuint64max + 1); } -vector<string> captured_messages_; +std::vector<string> captured_messages_; void CaptureLog(LogLevel level, const char* filename, int line, const string& message) { diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h index 218cd948..daf8ec57 100644 --- a/src/google/protobuf/stubs/hash.h +++ b/src/google/protobuf/stubs/hash.h @@ -408,8 +408,8 @@ struct hash<string> { }; template <typename First, typename Second> -struct hash<pair<First, Second> > { - inline size_t operator()(const pair<First, Second>& key) const { +struct hash<std::pair<First, Second> > { + inline size_t operator()(const std::pair<First, Second>& key) const { size_t first_hash = hash<First>()(key.first); size_t second_hash = hash<Second>()(key.second); @@ -420,8 +420,8 @@ struct hash<pair<First, Second> > { static const size_t bucket_size = 4; static const size_t min_buckets = 8; - inline bool operator()(const pair<First, Second>& a, - const pair<First, Second>& b) const { + inline bool operator()(const std::pair<First, Second>& a, + const std::pair<First, Second>& b) const { return a < b; } }; diff --git a/src/google/protobuf/stubs/map_util.h b/src/google/protobuf/stubs/map_util.h index 887f12a6..16cbfac4 100644 --- a/src/google/protobuf/stubs/map_util.h +++ b/src/google/protobuf/stubs/map_util.h @@ -708,7 +708,7 @@ void AppendKeysFromMap(const MapContainer& map_container, // without the complexity of a SFINAE-based solution.) template <class MapContainer, class KeyType> void AppendKeysFromMap(const MapContainer& map_container, - vector<KeyType>* key_container) { + std::vector<KeyType>* key_container) { GOOGLE_CHECK(key_container != NULL); // We now have the opportunity to call reserve(). Calling reserve() every // time is a bad idea for some use cases: libstdc++'s implementation of @@ -752,7 +752,7 @@ void AppendValuesFromMap(const MapContainer& map_container, // without the complexity of a SFINAE-based solution.) template <class MapContainer, class ValueType> void AppendValuesFromMap(const MapContainer& map_container, - vector<ValueType>* value_container) { + std::vector<ValueType>* value_container) { GOOGLE_CHECK(value_container != NULL); // See AppendKeysFromMap for why this is done. if (value_container->empty()) { diff --git a/src/google/protobuf/stubs/status.cc b/src/google/protobuf/stubs/status.cc index dd1bd614..2bfbe0b4 100644 --- a/src/google/protobuf/stubs/status.cc +++ b/src/google/protobuf/stubs/status.cc @@ -124,7 +124,7 @@ string Status::ToString() const { } } -ostream& operator<<(ostream& os, const Status& x) { +std::ostream& operator<<(std::ostream& os, const Status& x) { os << x.ToString(); return os; } diff --git a/src/google/protobuf/stubs/status.h b/src/google/protobuf/stubs/status.h index 614ab994..c5d38f0b 100644 --- a/src/google/protobuf/stubs/status.h +++ b/src/google/protobuf/stubs/status.h @@ -106,7 +106,7 @@ class LIBPROTOBUF_EXPORT Status { }; // Prints a human-readable representation of 'x' to 'os'. -LIBPROTOBUF_EXPORT ostream& operator<<(ostream& os, const Status& x); +LIBPROTOBUF_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x); #define EXPECT_OK(value) EXPECT_TRUE((value).ok()) diff --git a/src/google/protobuf/stubs/stringprintf.cc b/src/google/protobuf/stubs/stringprintf.cc index 83fdfe45..d98b9b87 100644 --- a/src/google/protobuf/stubs/stringprintf.cc +++ b/src/google/protobuf/stubs/stringprintf.cc @@ -137,7 +137,7 @@ const int kStringPrintfVectorMaxArgs = 32; // and we can fix the problem or protect against an attack. static const char string_printf_empty_block[256] = { '\0' }; -string StringPrintfVector(const char* format, const vector<string>& v) { +string StringPrintfVector(const char* format, const std::vector<string>& v) { GOOGLE_CHECK_LE(v.size(), kStringPrintfVectorMaxArgs) << "StringPrintfVector currently only supports up to " << kStringPrintfVectorMaxArgs << " arguments. " diff --git a/src/google/protobuf/stubs/stringprintf.h b/src/google/protobuf/stubs/stringprintf.h index ab1ab558..7183ec6a 100644 --- a/src/google/protobuf/stubs/stringprintf.h +++ b/src/google/protobuf/stubs/stringprintf.h @@ -68,7 +68,7 @@ LIBPROTOBUF_EXPORT extern const int kStringPrintfVectorMaxArgs; // You can use this version when all your arguments are strings, but // you don't know how many arguments you'll have at compile time. // StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs -LIBPROTOBUF_EXPORT extern string StringPrintfVector(const char* format, const vector<string>& v); +LIBPROTOBUF_EXPORT extern string StringPrintfVector(const char* format, const std::vector<string>& v); } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index 1a4d71c8..28bcd3b2 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -226,8 +226,8 @@ void SplitStringToIteratorUsing(const string& full, void SplitStringUsing(const string& full, const char* delim, - vector<string>* result) { - std::back_insert_iterator< vector<string> > it(*result); + std::vector<string>* result) { + std::back_insert_iterator< std::vector<string> > it(*result); SplitStringToIteratorUsing(full, delim, it); } @@ -264,8 +264,8 @@ void SplitStringToIteratorAllowEmpty(const StringType& full, } void SplitStringAllowEmpty(const string& full, const char* delim, - vector<string>* result) { - std::back_insert_iterator<vector<string> > it(*result); + std::vector<string>* result) { + std::back_insert_iterator<std::vector<string> > it(*result); SplitStringToIteratorAllowEmpty(full, delim, 0, it); } @@ -303,7 +303,7 @@ static void JoinStringsIterator(const ITERATOR& start, } } -void JoinStrings(const vector<string>& components, +void JoinStrings(const std::vector<string>& components, const char* delim, string * result) { JoinStringsIterator(components.begin(), components.end(), delim, result); @@ -332,7 +332,7 @@ int UnescapeCEscapeSequences(const char* source, char* dest) { } int UnescapeCEscapeSequences(const char* source, char* dest, - vector<string> *errors) { + std::vector<string> *errors) { GOOGLE_DCHECK(errors == NULL) << "Error reporting not implemented."; char* d = dest; @@ -468,7 +468,7 @@ int UnescapeCEscapeString(const string& src, string* dest) { } int UnescapeCEscapeString(const string& src, string* dest, - vector<string> *errors) { + std::vector<string> *errors) { scoped_array<char> unescaped(new char[src.size() + 1]); int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), errors); GOOGLE_CHECK(dest); diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index df28c94d..a839b8b3 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -213,7 +213,7 @@ LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub, // over all of them. // ---------------------------------------------------------------------- LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim, - vector<string>* res); + std::vector<string>* res); // Split a string using one or more byte delimiters, presented // as a nul-terminated c string. Append the components to 'result'. @@ -225,15 +225,15 @@ LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim, // ---------------------------------------------------------------------- LIBPROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full, const char* delim, - vector<string>* result); + std::vector<string>* result); // ---------------------------------------------------------------------- // Split() // Split a string using a character delimiter. // ---------------------------------------------------------------------- -inline vector<string> Split( +inline std::vector<string> Split( const string& full, const char* delim, bool skip_empty = true) { - vector<string> result; + std::vector<string> result; if (skip_empty) { SplitStringUsing(full, delim, &result); } else { @@ -250,10 +250,10 @@ inline vector<string> Split( // another takes a pointer to the target string. In the latter case the // target string is cleared and overwritten. // ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void JoinStrings(const vector<string>& components, +LIBPROTOBUF_EXPORT void JoinStrings(const std::vector<string>& components, const char* delim, string* result); -inline string JoinStrings(const vector<string>& components, +inline string JoinStrings(const std::vector<string>& components, const char* delim) { string result; JoinStrings(components, delim, &result); @@ -285,15 +285,15 @@ inline string JoinStrings(const vector<string>& components, // // Errors: In the first form of the call, errors are reported with // LOG(ERROR). The same is true for the second form of the call if -// the pointer to the string vector is NULL; otherwise, error -// messages are stored in the vector. In either case, the effect on +// the pointer to the string std::vector is NULL; otherwise, error +// messages are stored in the std::vector. In either case, the effect on // the dest array is not defined, but rest of the source will be // processed. // ---------------------------------------------------------------------- LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest); LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, - vector<string> *errors); + std::vector<string> *errors); // ---------------------------------------------------------------------- // UnescapeCEscapeString() @@ -312,7 +312,7 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest); LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest, - vector<string> *errors); + std::vector<string> *errors); LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src); // ---------------------------------------------------------------------- diff --git a/src/google/protobuf/stubs/strutil_unittest.cc b/src/google/protobuf/stubs/strutil_unittest.cc index 5d62fc4a..6bf0f598 100644 --- a/src/google/protobuf/stubs/strutil_unittest.cc +++ b/src/google/protobuf/stubs/strutil_unittest.cc @@ -782,7 +782,7 @@ TEST(Base64, EscapeAndUnescape) { reinterpret_cast<const unsigned char*>(base64_strings[i].plaintext); int plain_length = strlen(base64_strings[i].plaintext); int cypher_length = strlen(base64_strings[i].cyphertext); - vector<char> buffer(cypher_length+1); + std::vector<char> buffer(cypher_length+1); int encode_length = WebSafeBase64Escape(unsigned_plaintext, plain_length, &buffer[0], diff --git a/src/google/protobuf/stubs/type_traits_unittest.cc b/src/google/protobuf/stubs/type_traits_unittest.cc index 49c10ace..0e54b952 100644 --- a/src/google/protobuf/stubs/type_traits_unittest.cc +++ b/src/google/protobuf/stubs/type_traits_unittest.cc @@ -253,7 +253,7 @@ TEST(TypeTraitsTest, TestIsPointer) { EXPECT_TRUE(is_pointer<const void* volatile>::value); EXPECT_TRUE(is_pointer<char** const volatile>::value); EXPECT_FALSE(is_pointer<const int>::value); - EXPECT_FALSE(is_pointer<volatile vector<int*> >::value); + EXPECT_FALSE(is_pointer<volatile std::vector<int*> >::value); EXPECT_FALSE(is_pointer<const volatile double>::value); } |