GPBDuration.pbobjc.h 4.4 KB

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