/thirdparty/breakpad/third_party/glog/src/glog/stl_logging.h.in

http://github.com/tomahawk-player/tomahawk · Autoconf · 154 lines · 101 code · 21 blank · 32 comment · 11 complexity · 2206e2b9266134ce4a5f63bc7cddf1a0 MD5 · raw file

  1. // Copyright (c) 2003, Google Inc.
  2. // All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are
  6. // met:
  7. //
  8. // * Redistributions of source code must retain the above copyright
  9. // notice, this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above
  11. // copyright notice, this list of conditions and the following disclaimer
  12. // in the documentation and/or other materials provided with the
  13. // distribution.
  14. // * Neither the name of Google Inc. nor the names of its
  15. // contributors may be used to endorse or promote products derived from
  16. // this software without specific prior written permission.
  17. //
  18. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. //
  30. // Stream output operators for STL containers; to be used for logging *only*.
  31. // Inclusion of this file lets you do:
  32. //
  33. // list<string> x;
  34. // LOG(INFO) << "data: " << x;
  35. // vector<int> v1, v2;
  36. // CHECK_EQ(v1, v2);
  37. //
  38. // Note that if you want to use these operators from the non-global namespace,
  39. // you may get an error since they are not in namespace std (and they are not
  40. // in namespace std since that would result in undefined behavior). You may
  41. // need to write
  42. //
  43. // using ::operator<<;
  44. //
  45. // to fix these errors.
  46. #ifndef UTIL_GTL_STL_LOGGING_INL_H_
  47. #define UTIL_GTL_STL_LOGGING_INL_H_
  48. #if !@ac_cv_cxx_using_operator@
  49. # error We do not support stl_logging for this compiler
  50. #endif
  51. #include <deque>
  52. #include <list>
  53. #include <map>
  54. #include <ostream>
  55. #include <set>
  56. #include <utility>
  57. #include <vector>
  58. #ifdef __GNUC__
  59. # include <ext/hash_set>
  60. # include <ext/hash_map>
  61. # include <ext/slist>
  62. #endif
  63. template<class First, class Second>
  64. inline std::ostream& operator<<(std::ostream& out,
  65. const std::pair<First, Second>& p) {
  66. out << '(' << p.first << ", " << p.second << ')';
  67. return out;
  68. }
  69. @ac_google_start_namespace@
  70. template<class Iter>
  71. inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
  72. using ::operator<<;
  73. // Output at most 100 elements -- appropriate if used for logging.
  74. for (int i = 0; begin != end && i < 100; ++i, ++begin) {
  75. if (i > 0) out << ' ';
  76. out << *begin;
  77. }
  78. if (begin != end) {
  79. out << " ...";
  80. }
  81. }
  82. @ac_google_end_namespace@
  83. #define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
  84. template<class T1, class T2> \
  85. inline std::ostream& operator<<(std::ostream& out, \
  86. const Sequence<T1, T2>& seq) { \
  87. @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
  88. return out; \
  89. }
  90. OUTPUT_TWO_ARG_CONTAINER(std::vector)
  91. OUTPUT_TWO_ARG_CONTAINER(std::deque)
  92. OUTPUT_TWO_ARG_CONTAINER(std::list)
  93. #ifdef __GNUC__
  94. OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
  95. #endif
  96. #undef OUTPUT_TWO_ARG_CONTAINER
  97. #define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
  98. template<class T1, class T2, class T3> \
  99. inline std::ostream& operator<<(std::ostream& out, \
  100. const Sequence<T1, T2, T3>& seq) { \
  101. @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
  102. return out; \
  103. }
  104. OUTPUT_THREE_ARG_CONTAINER(std::set)
  105. OUTPUT_THREE_ARG_CONTAINER(std::multiset)
  106. #undef OUTPUT_THREE_ARG_CONTAINER
  107. #define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
  108. template<class T1, class T2, class T3, class T4> \
  109. inline std::ostream& operator<<(std::ostream& out, \
  110. const Sequence<T1, T2, T3, T4>& seq) { \
  111. @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
  112. return out; \
  113. }
  114. OUTPUT_FOUR_ARG_CONTAINER(std::map)
  115. OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
  116. #ifdef __GNUC__
  117. OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
  118. OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
  119. #endif
  120. #undef OUTPUT_FOUR_ARG_CONTAINER
  121. #define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
  122. template<class T1, class T2, class T3, class T4, class T5> \
  123. inline std::ostream& operator<<(std::ostream& out, \
  124. const Sequence<T1, T2, T3, T4, T5>& seq) { \
  125. @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
  126. return out; \
  127. }
  128. #ifdef __GNUC__
  129. OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
  130. OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
  131. #endif
  132. #undef OUTPUT_FIVE_ARG_CONTAINER
  133. #endif // UTIL_GTL_STL_LOGGING_INL_H_