GPBDuration.pbobjc.h 4.4 KB

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