GPBDuration.pbobjc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. // source: google/protobuf/duration.proto
  3. #import "GPBDescriptor.h"
  4. #import "GPBMessage.h"
  5. #import "GPBRootObject.h"
  6. #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
  7. #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
  8. #endif
  9. #if 30004 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
  10. #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
  11. #endif
  12. // @@protoc_insertion_point(imports)
  13. #pragma clang diagnostic push
  14. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  15. CF_EXTERN_C_BEGIN
  16. NS_ASSUME_NONNULL_BEGIN
  17. #pragma mark - GPBDurationRoot
  18. /**
  19. * Exposes the extension registry for this file.
  20. *
  21. * The base class provides:
  22. * @code
  23. * + (GPBExtensionRegistry *)extensionRegistry;
  24. * @endcode
  25. * which is a @c GPBExtensionRegistry that includes all the extensions defined by
  26. * this file and all files that it depends on.
  27. **/
  28. GPB_FINAL @interface GPBDurationRoot : GPBRootObject
  29. @end
  30. #pragma mark - GPBDuration
  31. typedef GPB_ENUM(GPBDuration_FieldNumber) {
  32. GPBDuration_FieldNumber_Seconds = 1,
  33. GPBDuration_FieldNumber_Nanos = 2,
  34. };
  35. /**
  36. * A Duration represents a signed, fixed-length span of time represented
  37. * as a count of seconds and fractions of seconds at nanosecond
  38. * resolution. It is independent of any calendar and concepts like "day"
  39. * or "month". It is related to Timestamp in that the difference between
  40. * two Timestamp values is a Duration and it can be added or subtracted
  41. * from a Timestamp. Range is approximately +-10,000 years.
  42. *
  43. * # Examples
  44. *
  45. * Example 1: Compute Duration from two Timestamps in pseudo code.
  46. *
  47. * Timestamp start = ...;
  48. * Timestamp end = ...;
  49. * Duration duration = ...;
  50. *
  51. * duration.seconds = end.seconds - start.seconds;
  52. * duration.nanos = end.nanos - start.nanos;
  53. *
  54. * if (duration.seconds < 0 && duration.nanos > 0) {
  55. * duration.seconds += 1;
  56. * duration.nanos -= 1000000000;
  57. * } else if (duration.seconds > 0 && duration.nanos < 0) {
  58. * duration.seconds -= 1;
  59. * duration.nanos += 1000000000;
  60. * }
  61. *
  62. * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
  63. *
  64. * Timestamp start = ...;
  65. * Duration duration = ...;
  66. * Timestamp end = ...;
  67. *
  68. * end.seconds = start.seconds + duration.seconds;
  69. * end.nanos = start.nanos + duration.nanos;
  70. *
  71. * if (end.nanos < 0) {
  72. * end.seconds -= 1;
  73. * end.nanos += 1000000000;
  74. * } else if (end.nanos >= 1000000000) {
  75. * end.seconds += 1;
  76. * end.nanos -= 1000000000;
  77. * }
  78. *
  79. * Example 3: Compute Duration from datetime.timedelta in Python.
  80. *
  81. * td = datetime.timedelta(days=3, minutes=10)
  82. * duration = Duration()
  83. * duration.FromTimedelta(td)
  84. *
  85. * # JSON Mapping
  86. *
  87. * In JSON format, the Duration type is encoded as a string rather than an
  88. * object, where the string ends in the suffix "s" (indicating seconds) and
  89. * is preceded by the number of seconds, with nanoseconds expressed as
  90. * fractional seconds. For example, 3 seconds with 0 nanoseconds should be
  91. * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
  92. * be expressed in JSON format as "3.000000001s", and 3 seconds and 1
  93. * microsecond should be expressed in JSON format as "3.000001s".
  94. **/
  95. GPB_FINAL @interface GPBDuration : GPBMessage
  96. /**
  97. * Signed seconds of the span of time. Must be from -315,576,000,000
  98. * to +315,576,000,000 inclusive. Note: these bounds are computed from:
  99. * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
  100. **/
  101. @property(nonatomic, readwrite) int64_t seconds;
  102. /**
  103. * Signed fractions of a second at nanosecond resolution of the span
  104. * of time. Durations less than one second are represented with a 0
  105. * `seconds` field and a positive or negative `nanos` field. For durations
  106. * of one second or more, a non-zero value for the `nanos` field must be
  107. * of the same sign as the `seconds` field. Must be from -999,999,999
  108. * to +999,999,999 inclusive.
  109. **/
  110. @property(nonatomic, readwrite) int32_t nanos;
  111. @end
  112. NS_ASSUME_NONNULL_END
  113. CF_EXTERN_C_END
  114. #pragma clang diagnostic pop
  115. // @@protoc_insertion_point(global_scope)