OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_LOGGING_H_ | 5 #ifndef BASE_LOGGING_H_ |
6 #define BASE_LOGGING_H_ | 6 #define BASE_LOGGING_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <cassert> | 9 #include <cassert> |
10 #include <string> | 10 #include <string> |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 // takes ownership of the returned string. | 462 // takes ownership of the returned string. |
463 template<class t1, class t2> | 463 template<class t1, class t2> |
464 std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { | 464 std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { |
465 std::ostringstream ss; | 465 std::ostringstream ss; |
466 ss << names << " (" << v1 << " vs. " << v2 << ")"; | 466 ss << names << " (" << v1 << " vs. " << v2 << ")"; |
467 std::string* msg = new std::string(ss.str()); | 467 std::string* msg = new std::string(ss.str()); |
468 return msg; | 468 return msg; |
469 } | 469 } |
470 | 470 |
471 // MSVC doesn't like complex extern templates and DLLs. | 471 // MSVC doesn't like complex extern templates and DLLs. |
472 #if !defined(COMPILER_MSVC) && !defined(COMPONENT_BUILD) | 472 #if !defined(COMPILER_MSVC) |
473 // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated | 473 // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated |
474 // in logging.cc. | 474 // in logging.cc. |
475 extern template std::string* MakeCheckOpString<int, int>( | 475 extern template BASE_EXPORT std::string* MakeCheckOpString<int, int>( |
476 const int&, const int&, const char* names); | 476 const int&, const int&, const char* names); |
477 extern template std::string* MakeCheckOpString<unsigned long, unsigned long>( | 477 extern template BASE_EXPORT |
| 478 std::string* MakeCheckOpString<unsigned long, unsigned long>( |
478 const unsigned long&, const unsigned long&, const char* names); | 479 const unsigned long&, const unsigned long&, const char* names); |
479 extern template std::string* MakeCheckOpString<unsigned long, unsigned int>( | 480 extern template BASE_EXPORT |
| 481 std::string* MakeCheckOpString<unsigned long, unsigned int>( |
480 const unsigned long&, const unsigned int&, const char* names); | 482 const unsigned long&, const unsigned int&, const char* names); |
481 extern template std::string* MakeCheckOpString<unsigned int, unsigned long>( | 483 extern template BASE_EXPORT |
| 484 std::string* MakeCheckOpString<unsigned int, unsigned long>( |
482 const unsigned int&, const unsigned long&, const char* names); | 485 const unsigned int&, const unsigned long&, const char* names); |
483 extern template std::string* MakeCheckOpString<std::string, std::string>( | 486 extern template BASE_EXPORT |
| 487 std::string* MakeCheckOpString<std::string, std::string>( |
484 const std::string&, const std::string&, const char* name); | 488 const std::string&, const std::string&, const char* name); |
485 #endif | 489 #endif |
486 | 490 |
487 // Helper macro for binary operators. | 491 // Helper macro for binary operators. |
488 // Don't use this macro directly in your code, use CHECK_EQ et al below. | 492 // Don't use this macro directly in your code, use CHECK_EQ et al below. |
489 // | 493 // |
490 // TODO(akalin): Rewrite this so that constructs like if (...) | 494 // TODO(akalin): Rewrite this so that constructs like if (...) |
491 // CHECK_EQ(...) else { ... } work properly. | 495 // CHECK_EQ(...) else { ... } work properly. |
492 #define CHECK_OP(name, op, val1, val2) \ | 496 #define CHECK_OP(name, op, val1, val2) \ |
493 if (std::string* _result = \ | 497 if (std::string* _result = \ |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 namespace base { | 955 namespace base { |
952 | 956 |
953 class StringPiece; | 957 class StringPiece; |
954 | 958 |
955 // Allows StringPiece to be logged. | 959 // Allows StringPiece to be logged. |
956 BASE_EXPORT std::ostream& operator<<(std::ostream& o, const StringPiece& piece); | 960 BASE_EXPORT std::ostream& operator<<(std::ostream& o, const StringPiece& piece); |
957 | 961 |
958 } // namespace base | 962 } // namespace base |
959 | 963 |
960 #endif // BASE_LOGGING_H_ | 964 #endif // BASE_LOGGING_H_ |
OLD | NEW |