Index: third_party/protobuf/src/google/protobuf/stubs/time.h |
diff --git a/third_party/protobuf/src/google/protobuf/repeated_field.cc b/third_party/protobuf/src/google/protobuf/stubs/time.h |
similarity index 55% |
copy from third_party/protobuf/src/google/protobuf/repeated_field.cc |
copy to third_party/protobuf/src/google/protobuf/stubs/time.h |
index 2c1f74c58a40e226ab1763f8637bd7e341e4af37..20a6b56d91c489734a0bf2b433632a3729ff0d1f 100644 |
--- a/third_party/protobuf/src/google/protobuf/repeated_field.cc |
+++ b/third_party/protobuf/src/google/protobuf/stubs/time.h |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// http://code.google.com/p/protobuf/ |
+// https://developers.google.com/protocol-buffers/ |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -27,61 +27,49 @@ |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+#ifndef GOOGLE_PROTOBUF_STUBS_TIME_H_ |
+#define GOOGLE_PROTOBUF_STUBS_TIME_H_ |
-// Author: kenton@google.com (Kenton Varda) |
-// Based on original Protocol Buffers design by |
-// Sanjay Ghemawat, Jeff Dean, and others. |
- |
-#include <algorithm> |
- |
-#include <google/protobuf/repeated_field.h> |
#include <google/protobuf/stubs/common.h> |
namespace google { |
namespace protobuf { |
- |
namespace internal { |
-void RepeatedPtrFieldBase::Reserve(int new_size) { |
- if (total_size_ >= new_size) return; |
- |
- void** old_elements = elements_; |
- total_size_ = max(kMinRepeatedFieldAllocationSize, |
- max(total_size_ * 2, new_size)); |
- elements_ = new void*[total_size_]; |
- if (old_elements != NULL) { |
- memcpy(elements_, old_elements, allocated_size_ * sizeof(elements_[0])); |
- delete [] old_elements; |
- } |
-} |
- |
-void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) { |
- if (this == other) return; |
- void** swap_elements = elements_; |
- int swap_current_size = current_size_; |
- int swap_allocated_size = allocated_size_; |
- int swap_total_size = total_size_; |
+struct DateTime { |
+ int year; |
+ int month; |
+ int day; |
+ int hour; |
+ int minute; |
+ int second; |
+}; |
- elements_ = other->elements_; |
- current_size_ = other->current_size_; |
- allocated_size_ = other->allocated_size_; |
- total_size_ = other->total_size_; |
+// Converts a timestamp (seconds elapsed since 1970-01-01T00:00:00, could be |
+// negative to represent time before 1970-01-01) to DateTime. Returns false |
+// if the timestamp is not in the range between 0001-01-01T00:00:00 and |
+// 9999-12-31T23:59:59. |
+bool LIBPROTOBUF_EXPORT SecondsToDateTime(int64 seconds, DateTime* time); |
+// Converts DateTime to a timestamp (seconds since 1970-01-01T00:00:00). |
+// Returns false if the DateTime is not valid or is not in the valid range. |
+bool LIBPROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, int64* seconds); |
- other->elements_ = swap_elements; |
- other->current_size_ = swap_current_size; |
- other->allocated_size_ = swap_allocated_size; |
- other->total_size_ = swap_total_size; |
-} |
+void LIBPROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos); |
-string* StringTypeHandlerBase::New() { |
- return new string; |
-} |
-void StringTypeHandlerBase::Delete(string* value) { |
- delete value; |
-} |
+// Formats a time string in RFC3339 fromat. |
+// |
+// For example, "2015-05-20T13:29:35.120Z". For nanos, 0, 3, 6 or 9 fractional |
+// digits will be used depending on how many are required to represent the exact |
+// value. |
+// |
+// Note that "nanos" must in the range of [0, 999999999]. |
+string LIBPROTOBUF_EXPORT FormatTime(int64 seconds, int32 nanos); |
+// Parses a time string. This method accepts RFC3339 date/time string with UTC |
+// offset. For example, "2015-05-20T13:29:35.120-08:00". |
+bool LIBPROTOBUF_EXPORT ParseTime(const string& vaule, int64* seconds, int32* nanos); |
} // namespace internal |
- |
- |
} // namespace protobuf |
} // namespace google |
+ |
+#endif // GOOGLE_PROTOBUF_STUBS_TIME_H_ |