1c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Copyright 2005, Google Inc.
2c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// All rights reserved.
3c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
4c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Redistribution and use in source and binary forms, with or without
5c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// modification, are permitted provided that the following conditions are
6c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// met:
7c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
8c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//     * Redistributions of source code must retain the above copyright
9c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// notice, this list of conditions and the following disclaimer.
10c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//     * Redistributions in binary form must reproduce the above
11c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// copyright notice, this list of conditions and the following disclaimer
12c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// in the documentation and/or other materials provided with the
13c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// distribution.
14c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//     * Neither the name of Google Inc. nor the names of its
15c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// contributors may be used to endorse or promote products derived from
16c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// this software without specific prior written permission.
17c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
18c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
30c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Author: wan@google.com (Zhanyong Wan)
31c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
32c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// The Google C++ Testing Framework (Google Test)
33c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
34c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// This header file defines the Message class.
35c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
36c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
37c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// leave some internal implementation details in this header file.
38c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// They are clearly marked by comments like this:
39c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
40c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
41c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
42c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Such code is NOT meant to be used by a user directly, and is subject
43c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
44c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// program!
45c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
46c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
47c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
48c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
49c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include <gtest/internal/gtest-string.h>
50c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include <gtest/internal/gtest-internal.h>
51c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
52c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottnamespace testing {
53c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
54c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// The Message class works like an ostream repeater.
55c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
56c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Typical usage:
57c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
58c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//   1. You stream a bunch of values to a Message object.
59c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//      It will remember the text in a StrStream.
60c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//   2. Then you stream the Message object to an ostream.
61c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//      This causes the text in the Message to be streamed
62c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//      to the ostream.
63c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
64c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// For example;
65c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
66c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//   testing::Message foo;
67c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//   foo << 1 << " != " << 2;
68c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//   std::cout << foo;
69c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
70c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// will print "1 != 2".
71c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
72c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Message is not intended to be inherited from.  In particular, its
73c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// destructor is not virtual.
74c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott//
75c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Note that StrStream behaves differently in gcc and in MSVC.  You
76c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// can stream a NULL char pointer to it in the former, but not in the
77c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// latter (it causes an access violation if you do).  The Message
78c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// class hides this difference by treating a NULL char pointer as
79c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// "(null)".
80c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottclass Message {
81c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott private:
82c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // The type of basic IO manipulators (endl, ends, and flush) for
83c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // narrow streams.
84c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
85c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
86c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott public:
87c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Constructs an empty Message.
88c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // We allocate the StrStream separately because it otherwise each use of
89c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
90c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // stack frame leading to huge stack frames in some cases; gcc does not reuse
91c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // the stack space.
92c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message() : ss_(new internal::StrStream) {}
93c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
94c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Copy constructor.
95c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message(const Message& msg) : ss_(new internal::StrStream) {  // NOLINT
96c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    *ss_ << msg.GetString();
97c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
98c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
99c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Constructs a Message from a C-string.
100c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  explicit Message(const char* str) : ss_(new internal::StrStream) {
101c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    *ss_ << str;
102c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
103c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
104c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  ~Message() { delete ss_; }
105c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifdef __SYMBIAN32__
106c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Streams a value (either a pointer or not) to this object.
107c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  template <typename T>
108c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  inline Message& operator <<(const T& value) {
109c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    StreamHelper(typename internal::is_pointer<T>::type(), value);
110c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return *this;
111c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
112c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#else
113c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Streams a non-pointer value to this object.
114c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  template <typename T>
115c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  inline Message& operator <<(const T& val) {
116c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    ::GTestStreamToHelper(ss_, val);
117c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return *this;
118c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
119c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
120c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Streams a pointer value to this object.
121c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  //
122c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // This function is an overload of the previous one.  When you
123c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // stream a pointer to a Message, this definition will be used as it
124c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // is more specialized.  (The C++ Standard, section
125c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // [temp.func.order].)  If you stream a non-pointer, then the
126c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // previous definition will be used.
127c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  //
128c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // The reason for this overload is that streaming a NULL pointer to
129c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // ostream is undefined behavior.  Depending on the compiler, you
130c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // may get "0", "(nil)", "(null)", or an access violation.  To
131c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // ensure consistent result across compilers, we always treat NULL
132c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // as "(null)".
133c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  template <typename T>
134c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  inline Message& operator <<(T* const& pointer) {  // NOLINT
135c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if (pointer == NULL) {
136c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott      *ss_ << "(null)";
137c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    } else {
138c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott      ::GTestStreamToHelper(ss_, pointer);
139c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
140c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return *this;
141c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
142c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif  // __SYMBIAN32__
143c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
144c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Since the basic IO manipulators are overloaded for both narrow
145c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // and wide streams, we have to provide this specialized definition
146c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // of operator <<, even though its body is the same as the
147c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // templatized version above.  Without this definition, streaming
148c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // endl or other basic IO manipulators to Message will confuse the
149c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // compiler.
150c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message& operator <<(BasicNarrowIoManip val) {
151c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    *ss_ << val;
152c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return *this;
153c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
154c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
155c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Instead of 1/0, we want to see true/false for bool values.
156c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message& operator <<(bool b) {
157c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return *this << (b ? "true" : "false");
158c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
159c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
160c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // These two overloads allow streaming a wide C string to a Message
161c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // using the UTF-8 encoding.
162c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message& operator <<(const wchar_t* wide_c_str) {
163c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return *this << internal::String::ShowWideCString(wide_c_str);
164c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
165c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message& operator <<(wchar_t* wide_c_str) {
166c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return *this << internal::String::ShowWideCString(wide_c_str);
167c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
168c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
169c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#if GTEST_HAS_STD_WSTRING
170c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Converts the given wide string to a narrow string using the UTF-8
171c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // encoding, and streams the result to this Message object.
172c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message& operator <<(const ::std::wstring& wstr);
173c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif  // GTEST_HAS_STD_WSTRING
174c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
175c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#if GTEST_HAS_GLOBAL_WSTRING
176c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Converts the given wide string to a narrow string using the UTF-8
177c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // encoding, and streams the result to this Message object.
178c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  Message& operator <<(const ::wstring& wstr);
179c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif  // GTEST_HAS_GLOBAL_WSTRING
180c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
181c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Gets the text streamed to this object so far as a String.
182c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // Each '\0' character in the buffer is replaced with "\\0".
183c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  //
184c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
185c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  internal::String GetString() const {
186c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    return internal::StrStreamToString(ss_);
187c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
188c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
189c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott private:
190c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifdef __SYMBIAN32__
191c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // These are needed as the Nokia Symbian Compiler cannot decide between
192c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // const T& and const T* in a function template. The Nokia compiler _can_
193c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // decide between class template specializations for T and T*, so a
194c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // tr1::type_traits-like is_pointer works, and we can overload on that.
195c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  template <typename T>
196c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  inline void StreamHelper(internal::true_type dummy, T* pointer) {
197c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    if (pointer == NULL) {
198c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott      *ss_ << "(null)";
199c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    } else {
200c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott      ::GTestStreamToHelper(ss_, pointer);
201c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    }
202c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
203c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  template <typename T>
204c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  inline void StreamHelper(internal::false_type dummy, const T& value) {
205c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott    ::GTestStreamToHelper(ss_, value);
206c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  }
207c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif  // __SYMBIAN32__
208c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
209c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // We'll hold the text streamed to this object here.
210c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  internal::StrStream* const ss_;
211c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
212c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // We declare (but don't implement) this to prevent the compiler
213c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  // from implementing the assignment operator.
214c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  void operator=(const Message&);
215c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott};
216c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
217c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Streams a Message to an ostream.
218c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottinline std::ostream& operator <<(std::ostream& os, const Message& sb) {
219c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  return os << sb.GetString();
220c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott}
221c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
222c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott}  // namespace testing
223c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
224c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif  // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
225