诸暨麻将添加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.
 
 
 
 
 
 

90 wiersze
3.8 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. // From: util/task/contrib/status_macros/status_macros.h
  31. #ifndef GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_
  32. #define GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_
  33. #include <google/protobuf/stubs/common.h>
  34. #include <google/protobuf/stubs/status.h>
  35. #include <google/protobuf/stubs/statusor.h>
  36. namespace google {
  37. namespace protobuf {
  38. namespace util {
  39. // Run a command that returns a util::Status. If the called code returns an
  40. // error status, return that status up out of this method too.
  41. //
  42. // Example:
  43. // RETURN_IF_ERROR(DoThings(4));
  44. #define RETURN_IF_ERROR(expr) \
  45. do { \
  46. /* Using _status below to avoid capture problems if expr is "status". */ \
  47. const PROTOBUF_NAMESPACE_ID::util::Status _status = (expr); \
  48. if (PROTOBUF_PREDICT_FALSE(!_status.ok())) return _status; \
  49. } while (0)
  50. // Internal helper for concatenating macro values.
  51. #define STATUS_MACROS_CONCAT_NAME_INNER(x, y) x##y
  52. #define STATUS_MACROS_CONCAT_NAME(x, y) STATUS_MACROS_CONCAT_NAME_INNER(x, y)
  53. template<typename T>
  54. Status DoAssignOrReturn(T& lhs, StatusOr<T> result) {
  55. if (result.ok()) {
  56. lhs = result.ValueOrDie();
  57. }
  58. return result.status();
  59. }
  60. #define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \
  61. Status status = DoAssignOrReturn(lhs, (rexpr)); \
  62. if (PROTOBUF_PREDICT_FALSE(!status.ok())) return status;
  63. // Executes an expression that returns a util::StatusOr, extracting its value
  64. // into the variable defined by lhs (or returning on error).
  65. //
  66. // Example: Assigning to an existing value
  67. // ValueType value;
  68. // ASSIGN_OR_RETURN(value, MaybeGetValue(arg));
  69. //
  70. // WARNING: ASSIGN_OR_RETURN expands into multiple statements; it cannot be used
  71. // in a single statement (e.g. as the body of an if statement without {})!
  72. #define ASSIGN_OR_RETURN(lhs, rexpr) \
  73. ASSIGN_OR_RETURN_IMPL( \
  74. STATUS_MACROS_CONCAT_NAME(_status_or_value, __COUNTER__), lhs, rexpr);
  75. } // namespace util
  76. } // namespace protobuf
  77. } // namespace google
  78. #endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_