diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/glog/stl_logging.h.in | 45 | ||||
-rw-r--r-- | src/stl_logging_unittest.cc | 21 | ||||
-rwxr-xr-x | src/windows/glog/stl_logging.h | 45 |
3 files changed, 94 insertions, 17 deletions
diff --git a/src/glog/stl_logging.h.in b/src/glog/stl_logging.h.in index 30836de..600945d 100644 --- a/src/glog/stl_logging.h.in +++ b/src/glog/stl_logging.h.in @@ -34,6 +34,15 @@ // LOG(INFO) << "data: " << x; // vector<int> v1, v2; // CHECK_EQ(v1, v2); +// +// If you want to use this header file with hash maps or slist, you +// need to define macros before including this file: +// +// - GLOG_STL_LOGGING_FOR_UNORDERED - <unordered_map> and <unordered_set> +// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - <tr1/unordered_(map|set)> +// - GLOG_STL_LOGGING_FOR_EXT_HASH - <ext/hash_(map|set)> +// - GLOG_STL_LOGGING_FOR_EXT_SLIST - <ext/slist> +// #ifndef UTIL_GTL_STL_LOGGING_INL_H_ #define UTIL_GTL_STL_LOGGING_INL_H_ @@ -50,9 +59,21 @@ #include <utility> #include <vector> -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +# include <unordered_map> +# include <unordered_set> +#endif + +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +# include <tr1/unordered_map> +# include <tr1/unordered_set> +#endif + +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH # include <ext/hash_set> # include <ext/hash_map> +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST # include <ext/slist> #endif @@ -80,7 +101,7 @@ inline std::ostream& operator<<(std::ostream& out, \ OUTPUT_TWO_ARG_CONTAINER(std::vector) OUTPUT_TWO_ARG_CONTAINER(std::deque) OUTPUT_TWO_ARG_CONTAINER(std::list) -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist) #endif @@ -109,7 +130,15 @@ inline std::ostream& operator<<(std::ostream& out, \ OUTPUT_FOUR_ARG_CONTAINER(std::map) OUTPUT_FOUR_ARG_CONTAINER(std::multimap) -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set) OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset) #endif @@ -124,7 +153,15 @@ inline std::ostream& operator<<(std::ostream& out, \ return out; \ } -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map) OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap) #endif diff --git a/src/stl_logging_unittest.cc b/src/stl_logging_unittest.cc index 5dcbc44..fcae9ad 100644 --- a/src/stl_logging_unittest.cc +++ b/src/stl_logging_unittest.cc @@ -31,6 +31,14 @@ #ifdef HAVE_USING_OPERATOR +#ifdef __GNUC__ +// C++0x isn't enabled by default. +// # define GLOG_STL_LOGGING_FOR_UNORDERED +# define GLOG_STL_LOGGING_FOR_TR1_UNORDERED +# define GLOG_STL_LOGGING_FOR_EXT_HASH +# define GLOG_STL_LOGGING_FOR_EXT_SLIST +#endif + #include "glog/stl_logging.h" #include <iostream> @@ -39,16 +47,11 @@ #include <string> #include <vector> -#ifdef __GNUC__ -# include <ext/hash_map> -# include <ext/hash_set> -#endif - #include "glog/logging.h" #include "googletest.h" using namespace std; -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH using namespace __gnu_cxx; #endif @@ -83,7 +86,7 @@ void TestSTLLogging() { CHECK_EQ(m, copied_m); // This must compile. } -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH { // Test a hashed simple associative container. hash_set<int> hs; @@ -98,7 +101,7 @@ void TestSTLLogging() { } #endif -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH { // Test a hashed pair associative container. hash_map<int, string> hm; @@ -145,7 +148,7 @@ void TestSTLLogging() { CHECK_EQ(m, copied_m); // This must compile. } -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH { // Test a hashed simple associative container. // Use a user defined hash function. diff --git a/src/windows/glog/stl_logging.h b/src/windows/glog/stl_logging.h index d2e7495..a97a908 100755 --- a/src/windows/glog/stl_logging.h +++ b/src/windows/glog/stl_logging.h @@ -38,6 +38,15 @@ // LOG(INFO) << "data: " << x; // vector<int> v1, v2; // CHECK_EQ(v1, v2); +// +// If you want to use this header file with hash_compare maps or slist, you +// need to define macros before including this file: +// +// - GLOG_STL_LOGGING_FOR_UNORDERED - <unordered_map> and <unordered_set> +// - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - <tr1/unordered_(map|set)> +// - GLOG_STL_LOGGING_FOR_EXT_HASH - <ext/hash_(map|set)> +// - GLOG_STL_LOGGING_FOR_EXT_SLIST - <ext/slist> +// #ifndef UTIL_GTL_STL_LOGGING_INL_H_ #define UTIL_GTL_STL_LOGGING_INL_H_ @@ -54,9 +63,21 @@ #include <utility> #include <vector> -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +# include <unordered_map> +# include <unordered_set> +#endif + +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +# include <tr1/unordered_map> +# include <tr1/unordered_set> +#endif + +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH # include <ext/hash_set> # include <ext/hash_map> +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST # include <ext/slist> #endif @@ -84,7 +105,7 @@ inline std::ostream& operator<<(std::ostream& out, \ OUTPUT_TWO_ARG_CONTAINER(std::vector) OUTPUT_TWO_ARG_CONTAINER(std::deque) OUTPUT_TWO_ARG_CONTAINER(std::list) -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist) #endif @@ -113,7 +134,15 @@ inline std::ostream& operator<<(std::ostream& out, \ OUTPUT_FOUR_ARG_CONTAINER(std::map) OUTPUT_FOUR_ARG_CONTAINER(std::multimap) -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set) +OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set) OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset) #endif @@ -128,7 +157,15 @@ inline std::ostream& operator<<(std::ostream& out, \ return out; \ } -#ifdef __GNUC__ +#ifdef GLOG_STL_LOGGING_FOR_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map) +OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap) +#endif +#ifdef GLOG_STL_LOGGING_FOR_EXT_HASH OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map) OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap) #endif |