123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
- #include <limits>
- #include <memory>
- #include <sstream>
- #include "gtest/internal/gtest-port.h"
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- void operator<<(const testing::internal::Secret&, int);
- namespace testing {
- class GTEST_API_ Message {
- private:
-
-
- typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
- public:
-
- Message();
-
- Message(const Message& msg) : ss_(new ::std::stringstream) {
- *ss_ << msg.GetString();
- }
-
- explicit Message(const char* str) : ss_(new ::std::stringstream) {
- *ss_ << str;
- }
-
- template <typename T>
- inline Message& operator <<(const T& val) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- using ::operator <<;
- *ss_ << val;
- return *this;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <typename T>
- inline Message& operator <<(T* const& pointer) {
- if (pointer == nullptr) {
- *ss_ << "(null)";
- } else {
- *ss_ << pointer;
- }
- return *this;
- }
-
-
-
-
-
-
- Message& operator <<(BasicNarrowIoManip val) {
- *ss_ << val;
- return *this;
- }
-
- Message& operator <<(bool b) {
- return *this << (b ? "true" : "false");
- }
-
-
- Message& operator <<(const wchar_t* wide_c_str);
- Message& operator <<(wchar_t* wide_c_str);
- #if GTEST_HAS_STD_WSTRING
-
-
- Message& operator <<(const ::std::wstring& wstr);
- #endif
-
-
-
-
- std::string GetString() const;
- private:
-
- const std::unique_ptr< ::std::stringstream> ss_;
-
-
- void operator=(const Message&);
- };
- inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
- return os << sb.GetString();
- }
- namespace internal {
- template <typename T>
- std::string StreamableToString(const T& streamable) {
- return (Message() << streamable).GetString();
- }
- }
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
|