PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 47#ifndef UTIL_GTL_STL_LOGGING_INL_H_
 48#define UTIL_GTL_STL_LOGGING_INL_H_
 49
 50#if !@ac_cv_cxx_using_operator@
 51# error We do not support stl_logging for this compiler
 52#endif
 53
 54#include <deque>
 55#include <list>
 56#include <map>
 57#include <ostream>
 58#include <set>
 59#include <utility>
 60#include <vector>
 61
 62#ifdef __GNUC__
 63# include <ext/hash_set>
 64# include <ext/hash_map>
 65# include <ext/slist>
 66#endif
 67
 68template<class First, class Second>
 69inline std::ostream& operator<<(std::ostream& out,
 70                                const std::pair<First, Second>& p) {
 71  out << '(' << p.first << ", " << p.second << ')';
 72  return out;
 73}
 74
 75@ac_google_start_namespace@
 76
 77template<class Iter>
 78inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
 79  using ::operator<<;
 80  // Output at most 100 elements -- appropriate if used for logging.
 81  for (int i = 0; begin != end && i < 100; ++i, ++begin) {
 82    if (i > 0) out << ' ';
 83    out << *begin;
 84  }
 85  if (begin != end) {
 86    out << " ...";
 87  }
 88}
 89
 90@ac_google_end_namespace@
 91
 92#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
 93template<class T1, class T2> \
 94inline std::ostream& operator<<(std::ostream& out, \
 95                                const Sequence<T1, T2>& seq) { \
 96  @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
 97  return out; \
 98}
 99
100OUTPUT_TWO_ARG_CONTAINER(std::vector)
101OUTPUT_TWO_ARG_CONTAINER(std::deque)
102OUTPUT_TWO_ARG_CONTAINER(std::list)
103#ifdef __GNUC__
104OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
105#endif
106
107#undef OUTPUT_TWO_ARG_CONTAINER
108
109#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
110template<class T1, class T2, class T3> \
111inline std::ostream& operator<<(std::ostream& out, \
112                                const Sequence<T1, T2, T3>& seq) { \
113  @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
114  return out; \
115}
116
117OUTPUT_THREE_ARG_CONTAINER(std::set)
118OUTPUT_THREE_ARG_CONTAINER(std::multiset)
119
120#undef OUTPUT_THREE_ARG_CONTAINER
121
122#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
123template<class T1, class T2, class T3, class T4> \
124inline std::ostream& operator<<(std::ostream& out, \
125                                const Sequence<T1, T2, T3, T4>& seq) { \
126  @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
127  return out; \
128}
129
130OUTPUT_FOUR_ARG_CONTAINER(std::map)
131OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
132#ifdef __GNUC__
133OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
134OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
135#endif
136
137#undef OUTPUT_FOUR_ARG_CONTAINER
138
139#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
140template<class T1, class T2, class T3, class T4, class T5> \
141inline std::ostream& operator<<(std::ostream& out, \
142                                const Sequence<T1, T2, T3, T4, T5>& seq) { \
143  @ac_google_namespace@::PrintSequence(out, seq.begin(), seq.end()); \
144  return out; \
145}
146
147#ifdef __GNUC__
148OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
149OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
150#endif
151
152#undef OUTPUT_FIVE_ARG_CONTAINER
153
154#endif  // UTIL_GTL_STL_LOGGING_INL_H_