诸暨麻将添加redis
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

242 wiersze
8.9 KiB

  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #ifndef GOOGLE_PROTOBUF_STUBS_LOGGING_H_
  31. #define GOOGLE_PROTOBUF_STUBS_LOGGING_H_
  32. #include <google/protobuf/stubs/macros.h>
  33. #include <google/protobuf/stubs/port.h>
  34. #include <google/protobuf/port_def.inc>
  35. // ===================================================================
  36. // emulates google3/base/logging.h
  37. namespace google {
  38. namespace protobuf {
  39. enum LogLevel {
  40. LOGLEVEL_INFO, // Informational. This is never actually used by
  41. // libprotobuf.
  42. LOGLEVEL_WARNING, // Warns about issues that, although not technically a
  43. // problem now, could cause problems in the future. For
  44. // example, a // warning will be printed when parsing a
  45. // message that is near the message size limit.
  46. LOGLEVEL_ERROR, // An error occurred which should never happen during
  47. // normal use.
  48. LOGLEVEL_FATAL, // An error occurred from which the library cannot
  49. // recover. This usually indicates a programming error
  50. // in the code which calls the library, especially when
  51. // compiled in debug mode.
  52. #ifdef NDEBUG
  53. LOGLEVEL_DFATAL = LOGLEVEL_ERROR
  54. #else
  55. LOGLEVEL_DFATAL = LOGLEVEL_FATAL
  56. #endif
  57. };
  58. class StringPiece;
  59. namespace util {
  60. class Status;
  61. }
  62. class uint128;
  63. namespace internal {
  64. class LogFinisher;
  65. class PROTOBUF_EXPORT LogMessage {
  66. public:
  67. LogMessage(LogLevel level, const char* filename, int line);
  68. ~LogMessage();
  69. LogMessage& operator<<(const std::string& value);
  70. LogMessage& operator<<(const char* value);
  71. LogMessage& operator<<(char value);
  72. LogMessage& operator<<(int value);
  73. LogMessage& operator<<(uint value);
  74. LogMessage& operator<<(long value);
  75. LogMessage& operator<<(unsigned long value);
  76. LogMessage& operator<<(long long value);
  77. LogMessage& operator<<(unsigned long long value);
  78. LogMessage& operator<<(double value);
  79. LogMessage& operator<<(void* value);
  80. LogMessage& operator<<(const StringPiece& value);
  81. LogMessage& operator<<(const util::Status& status);
  82. LogMessage& operator<<(const uint128& value);
  83. private:
  84. friend class LogFinisher;
  85. void Finish();
  86. LogLevel level_;
  87. const char* filename_;
  88. int line_;
  89. std::string message_;
  90. };
  91. // Used to make the entire "LOG(BLAH) << etc." expression have a void return
  92. // type and print a newline after each message.
  93. class PROTOBUF_EXPORT LogFinisher {
  94. public:
  95. void operator=(LogMessage& other);
  96. };
  97. template<typename T>
  98. bool IsOk(T status) { return status.ok(); }
  99. template<>
  100. inline bool IsOk(bool status) { return status; }
  101. } // namespace internal
  102. // Undef everything in case we're being mixed with some other Google library
  103. // which already defined them itself. Presumably all Google libraries will
  104. // support the same syntax for these so it should not be a big deal if they
  105. // end up using our definitions instead.
  106. #undef GOOGLE_LOG
  107. #undef GOOGLE_LOG_IF
  108. #undef GOOGLE_CHECK
  109. #undef GOOGLE_CHECK_OK
  110. #undef GOOGLE_CHECK_EQ
  111. #undef GOOGLE_CHECK_NE
  112. #undef GOOGLE_CHECK_LT
  113. #undef GOOGLE_CHECK_LE
  114. #undef GOOGLE_CHECK_GT
  115. #undef GOOGLE_CHECK_GE
  116. #undef GOOGLE_CHECK_NOTNULL
  117. #undef GOOGLE_DLOG
  118. #undef GOOGLE_DCHECK
  119. #undef GOOGLE_DCHECK_OK
  120. #undef GOOGLE_DCHECK_EQ
  121. #undef GOOGLE_DCHECK_NE
  122. #undef GOOGLE_DCHECK_LT
  123. #undef GOOGLE_DCHECK_LE
  124. #undef GOOGLE_DCHECK_GT
  125. #undef GOOGLE_DCHECK_GE
  126. #define GOOGLE_LOG(LEVEL) \
  127. ::google::protobuf::internal::LogFinisher() = \
  128. ::google::protobuf::internal::LogMessage( \
  129. ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__)
  130. #define GOOGLE_LOG_IF(LEVEL, CONDITION) \
  131. !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL)
  132. #define GOOGLE_CHECK(EXPRESSION) \
  133. GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": "
  134. #define GOOGLE_CHECK_OK(A) GOOGLE_CHECK(::google::protobuf::internal::IsOk(A))
  135. #define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B))
  136. #define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B))
  137. #define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B))
  138. #define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B))
  139. #define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B))
  140. #define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B))
  141. namespace internal {
  142. template<typename T>
  143. T* CheckNotNull(const char* /* file */, int /* line */,
  144. const char* name, T* val) {
  145. if (val == nullptr) {
  146. GOOGLE_LOG(FATAL) << name;
  147. }
  148. return val;
  149. }
  150. } // namespace internal
  151. #define GOOGLE_CHECK_NOTNULL(A) \
  152. ::google::protobuf::internal::CheckNotNull( \
  153. __FILE__, __LINE__, "'" #A "' must not be nullptr", (A))
  154. #ifdef NDEBUG
  155. #define GOOGLE_DLOG(LEVEL) GOOGLE_LOG_IF(LEVEL, false)
  156. #define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION)
  157. #define GOOGLE_DCHECK_OK(E) GOOGLE_DCHECK(::google::protobuf::internal::IsOk(E))
  158. #define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B))
  159. #define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B))
  160. #define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B))
  161. #define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B))
  162. #define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B))
  163. #define GOOGLE_DCHECK_GE(A, B) GOOGLE_DCHECK((A) >= (B))
  164. #else // NDEBUG
  165. #define GOOGLE_DLOG GOOGLE_LOG
  166. #define GOOGLE_DCHECK GOOGLE_CHECK
  167. #define GOOGLE_DCHECK_OK GOOGLE_CHECK_OK
  168. #define GOOGLE_DCHECK_EQ GOOGLE_CHECK_EQ
  169. #define GOOGLE_DCHECK_NE GOOGLE_CHECK_NE
  170. #define GOOGLE_DCHECK_LT GOOGLE_CHECK_LT
  171. #define GOOGLE_DCHECK_LE GOOGLE_CHECK_LE
  172. #define GOOGLE_DCHECK_GT GOOGLE_CHECK_GT
  173. #define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE
  174. #endif // !NDEBUG
  175. typedef void LogHandler(LogLevel level, const char* filename, int line,
  176. const std::string& message);
  177. // The protobuf library sometimes writes warning and error messages to
  178. // stderr. These messages are primarily useful for developers, but may
  179. // also help end users figure out a problem. If you would prefer that
  180. // these messages be sent somewhere other than stderr, call SetLogHandler()
  181. // to set your own handler. This returns the old handler. Set the handler
  182. // to nullptr to ignore log messages (but see also LogSilencer, below).
  183. //
  184. // Obviously, SetLogHandler is not thread-safe. You should only call it
  185. // at initialization time, and probably not from library code. If you
  186. // simply want to suppress log messages temporarily (e.g. because you
  187. // have some code that tends to trigger them frequently and you know
  188. // the warnings are not important to you), use the LogSilencer class
  189. // below.
  190. PROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func);
  191. // Create a LogSilencer if you want to temporarily suppress all log
  192. // messages. As long as any LogSilencer objects exist, non-fatal
  193. // log messages will be discarded (the current LogHandler will *not*
  194. // be called). Constructing a LogSilencer is thread-safe. You may
  195. // accidentally suppress log messages occurring in another thread, but
  196. // since messages are generally for debugging purposes only, this isn't
  197. // a big deal. If you want to intercept log messages, use SetLogHandler().
  198. class PROTOBUF_EXPORT LogSilencer {
  199. public:
  200. LogSilencer();
  201. ~LogSilencer();
  202. };
  203. } // namespace protobuf
  204. } // namespace google
  205. #include <google/protobuf/port_undef.inc>
  206. #endif // GOOGLE_PROTOBUF_STUBS_LOGGING_H_