From 9a71ce8e677cdd1bff4c8fd21666a074d1e893b7 Mon Sep 17 00:00:00 2001 From: Rich Gowman Date: Fri, 2 Feb 2018 13:54:39 -0500 Subject: Import "well-known" protos (and generated nanopb files) For use by nanopb (which otherwise doesn't know what to do with these.) --- Firestore/Protos/build-protos.sh | 4 + .../Protos/nanopb/google/protobuf/struct.pb.c | 87 ++++++++++++++ .../Protos/nanopb/google/protobuf/struct.pb.h | 117 ++++++++++++++++++ .../Protos/nanopb/google/protobuf/timestamp.pb.c | 36 ++++++ .../Protos/nanopb/google/protobuf/timestamp.pb.h | 69 +++++++++++ .../Protos/protos/google/protobuf/struct.proto | 96 +++++++++++++++ .../Protos/protos/google/protobuf/timestamp.proto | 133 +++++++++++++++++++++ 7 files changed, 542 insertions(+) create mode 100644 Firestore/Protos/nanopb/google/protobuf/struct.pb.c create mode 100644 Firestore/Protos/nanopb/google/protobuf/struct.pb.h create mode 100644 Firestore/Protos/nanopb/google/protobuf/timestamp.pb.c create mode 100644 Firestore/Protos/nanopb/google/protobuf/timestamp.pb.h create mode 100644 Firestore/Protos/protos/google/protobuf/struct.proto create mode 100644 Firestore/Protos/protos/google/protobuf/timestamp.proto (limited to 'Firestore/Protos') diff --git a/Firestore/Protos/build-protos.sh b/Firestore/Protos/build-protos.sh index 5c3aa53..ced0ee5 100755 --- a/Firestore/Protos/build-protos.sh +++ b/Firestore/Protos/build-protos.sh @@ -27,6 +27,10 @@ pod update --nanopb_out="--options-file=protos/%s.options:nanopb" \ `find protos -name *.proto -print | xargs` +# Remove "well-known" protos from objc. (We get these for free. We only need +# them for nanopb.) +rm -rf objc/google/protobuf/ + # If a proto uses a field named 'delete', nanopb happily uses that in the # message definition. Works fine for C; not so much for C++. Rename uses of this # to delete_ (which is how protoc does it for c++ files.) diff --git a/Firestore/Protos/nanopb/google/protobuf/struct.pb.c b/Firestore/Protos/nanopb/google/protobuf/struct.pb.c new file mode 100644 index 0000000..b0ed35c --- /dev/null +++ b/Firestore/Protos/nanopb/google/protobuf/struct.pb.c @@ -0,0 +1,87 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.3.9 at Tue Jan 30 18:12:08 2018. */ + +#include "struct.pb.h" + +/* @@protoc_insertion_point(includes) */ +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + + + +const pb_field_t google_protobuf_Struct_fields[2] = { + PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_protobuf_Struct, fields, fields, &google_protobuf_Struct_FieldsEntry_fields), + PB_LAST_FIELD +}; + +const pb_field_t google_protobuf_Struct_FieldsEntry_fields[3] = { + PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, google_protobuf_Struct_FieldsEntry, key, key, 0), + PB_FIELD( 2, MESSAGE , SINGULAR, STATIC , OTHER, google_protobuf_Struct_FieldsEntry, value, key, &google_protobuf_Value_fields), + PB_LAST_FIELD +}; + +const pb_field_t google_protobuf_Value_fields[7] = { + PB_FIELD( 1, UENUM , SINGULAR, STATIC , FIRST, google_protobuf_Value, null_value, null_value, 0), + PB_FIELD( 2, DOUBLE , SINGULAR, STATIC , OTHER, google_protobuf_Value, number_value, null_value, 0), + PB_FIELD( 3, STRING , SINGULAR, CALLBACK, OTHER, google_protobuf_Value, string_value, number_value, 0), + PB_FIELD( 4, BOOL , SINGULAR, STATIC , OTHER, google_protobuf_Value, bool_value, string_value, 0), + PB_FIELD( 5, MESSAGE , SINGULAR, STATIC , OTHER, google_protobuf_Value, struct_value, bool_value, &google_protobuf_Struct_fields), + PB_FIELD( 6, MESSAGE , SINGULAR, STATIC , OTHER, google_protobuf_Value, list_value, struct_value, &google_protobuf_ListValue_fields), + PB_LAST_FIELD +}; + +const pb_field_t google_protobuf_ListValue_fields[2] = { + PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_protobuf_ListValue, values, values, &google_protobuf_Value_fields), + PB_LAST_FIELD +}; + + + +/* Check that field information fits in pb_field_t */ +#if !defined(PB_FIELD_32BIT) +/* If you get an error here, it means that you need to define PB_FIELD_32BIT + * compile-time option. You can do that in pb.h or on compiler command line. + * + * The reason you need to do this is that some of your messages contain tag + * numbers or field sizes that are larger than what can fit in 8 or 16 bit + * field descriptors. + */ +PB_STATIC_ASSERT((pb_membersize(google_protobuf_Struct_FieldsEntry, value) < 65536 && pb_membersize(google_protobuf_Value, struct_value) < 65536 && pb_membersize(google_protobuf_Value, list_value) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_protobuf_Struct_google_protobuf_Struct_FieldsEntry_google_protobuf_Value_google_protobuf_ListValue) +#endif + +#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) +/* If you get an error here, it means that you need to define PB_FIELD_16BIT + * compile-time option. You can do that in pb.h or on compiler command line. + * + * The reason you need to do this is that some of your messages contain tag + * numbers or field sizes that are larger than what can fit in the default + * 8 bit descriptors. + */ +PB_STATIC_ASSERT((pb_membersize(google_protobuf_Struct_FieldsEntry, value) < 256 && pb_membersize(google_protobuf_Value, struct_value) < 256 && pb_membersize(google_protobuf_Value, list_value) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_protobuf_Struct_google_protobuf_Struct_FieldsEntry_google_protobuf_Value_google_protobuf_ListValue) +#endif + + +/* On some platforms (such as AVR), double is really float. + * These are not directly supported by nanopb, but see example_avr_double. + * To get rid of this error, remove any double fields from your .proto. + */ +PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES) + +/* @@protoc_insertion_point(eof) */ diff --git a/Firestore/Protos/nanopb/google/protobuf/struct.pb.h b/Firestore/Protos/nanopb/google/protobuf/struct.pb.h new file mode 100644 index 0000000..1871f0e --- /dev/null +++ b/Firestore/Protos/nanopb/google/protobuf/struct.pb.h @@ -0,0 +1,117 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.3.9 at Tue Jan 30 18:12:08 2018. */ + +#ifndef PB_GOOGLE_PROTOBUF_STRUCT_PB_H_INCLUDED +#define PB_GOOGLE_PROTOBUF_STRUCT_PB_H_INCLUDED +#include + +/* @@protoc_insertion_point(includes) */ +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Enum definitions */ +typedef enum _google_protobuf_NullValue { + google_protobuf_NullValue_NULL_VALUE = 0 +} google_protobuf_NullValue; +#define _google_protobuf_NullValue_MIN google_protobuf_NullValue_NULL_VALUE +#define _google_protobuf_NullValue_MAX google_protobuf_NullValue_NULL_VALUE +#define _google_protobuf_NullValue_ARRAYSIZE ((google_protobuf_NullValue)(google_protobuf_NullValue_NULL_VALUE+1)) + +/* Struct definitions */ +typedef struct _google_protobuf_ListValue { + pb_callback_t values; +/* @@protoc_insertion_point(struct:google_protobuf_ListValue) */ +} google_protobuf_ListValue; + +typedef struct _google_protobuf_Struct { + pb_callback_t fields; +/* @@protoc_insertion_point(struct:google_protobuf_Struct) */ +} google_protobuf_Struct; + +typedef struct _google_protobuf_Value { + google_protobuf_NullValue null_value; + double number_value; + pb_callback_t string_value; + bool bool_value; + google_protobuf_Struct struct_value; + google_protobuf_ListValue list_value; +/* @@protoc_insertion_point(struct:google_protobuf_Value) */ +} google_protobuf_Value; + +typedef struct _google_protobuf_Struct_FieldsEntry { + pb_callback_t key; + google_protobuf_Value value; +/* @@protoc_insertion_point(struct:google_protobuf_Struct_FieldsEntry) */ +} google_protobuf_Struct_FieldsEntry; + +/* Default values for struct fields */ + +/* Initializer values for message structs */ +#define google_protobuf_Struct_init_default {{{NULL}, NULL}} +#define google_protobuf_Struct_FieldsEntry_init_default {{{NULL}, NULL}, google_protobuf_Value_init_default} +#define google_protobuf_Value_init_default {(google_protobuf_NullValue)0, 0, {{NULL}, NULL}, 0, google_protobuf_Struct_init_default, google_protobuf_ListValue_init_default} +#define google_protobuf_ListValue_init_default {{{NULL}, NULL}} +#define google_protobuf_Struct_init_zero {{{NULL}, NULL}} +#define google_protobuf_Struct_FieldsEntry_init_zero {{{NULL}, NULL}, google_protobuf_Value_init_zero} +#define google_protobuf_Value_init_zero {(google_protobuf_NullValue)0, 0, {{NULL}, NULL}, 0, google_protobuf_Struct_init_zero, google_protobuf_ListValue_init_zero} +#define google_protobuf_ListValue_init_zero {{{NULL}, NULL}} + +/* Field tags (for use in manual encoding/decoding) */ +#define google_protobuf_ListValue_values_tag 1 +#define google_protobuf_Struct_fields_tag 1 +#define google_protobuf_Value_null_value_tag 1 +#define google_protobuf_Value_number_value_tag 2 +#define google_protobuf_Value_string_value_tag 3 +#define google_protobuf_Value_bool_value_tag 4 +#define google_protobuf_Value_struct_value_tag 5 +#define google_protobuf_Value_list_value_tag 6 +#define google_protobuf_Struct_FieldsEntry_key_tag 1 +#define google_protobuf_Struct_FieldsEntry_value_tag 2 + +/* Struct field encoding specification for nanopb */ +extern const pb_field_t google_protobuf_Struct_fields[2]; +extern const pb_field_t google_protobuf_Struct_FieldsEntry_fields[3]; +extern const pb_field_t google_protobuf_Value_fields[7]; +extern const pb_field_t google_protobuf_ListValue_fields[2]; + +/* Maximum encoded size of messages (where known) */ +/* google_protobuf_Struct_size depends on runtime parameters */ +/* google_protobuf_Struct_FieldsEntry_size depends on runtime parameters */ +/* google_protobuf_Value_size depends on runtime parameters */ +/* google_protobuf_ListValue_size depends on runtime parameters */ + +/* Message IDs (where set with "msgid" option) */ +#ifdef PB_MSGID + +#define STRUCT_MESSAGES \ + + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif +/* @@protoc_insertion_point(eof) */ + +#endif diff --git a/Firestore/Protos/nanopb/google/protobuf/timestamp.pb.c b/Firestore/Protos/nanopb/google/protobuf/timestamp.pb.c new file mode 100644 index 0000000..0ad8cd7 --- /dev/null +++ b/Firestore/Protos/nanopb/google/protobuf/timestamp.pb.c @@ -0,0 +1,36 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.3.9 at Tue Jan 30 18:12:08 2018. */ + +#include "timestamp.pb.h" + +/* @@protoc_insertion_point(includes) */ +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + + + +const pb_field_t google_protobuf_Timestamp_fields[3] = { + PB_FIELD( 1, INT64 , SINGULAR, STATIC , FIRST, google_protobuf_Timestamp, seconds, seconds, 0), + PB_FIELD( 2, INT32 , SINGULAR, STATIC , OTHER, google_protobuf_Timestamp, nanos, seconds, 0), + PB_LAST_FIELD +}; + + +/* @@protoc_insertion_point(eof) */ diff --git a/Firestore/Protos/nanopb/google/protobuf/timestamp.pb.h b/Firestore/Protos/nanopb/google/protobuf/timestamp.pb.h new file mode 100644 index 0000000..84dd444 --- /dev/null +++ b/Firestore/Protos/nanopb/google/protobuf/timestamp.pb.h @@ -0,0 +1,69 @@ +/* + * Copyright 2018 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.3.9 at Tue Jan 30 18:12:08 2018. */ + +#ifndef PB_GOOGLE_PROTOBUF_TIMESTAMP_PB_H_INCLUDED +#define PB_GOOGLE_PROTOBUF_TIMESTAMP_PB_H_INCLUDED +#include + +/* @@protoc_insertion_point(includes) */ +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Struct definitions */ +typedef struct _google_protobuf_Timestamp { + int64_t seconds; + int32_t nanos; +/* @@protoc_insertion_point(struct:google_protobuf_Timestamp) */ +} google_protobuf_Timestamp; + +/* Default values for struct fields */ + +/* Initializer values for message structs */ +#define google_protobuf_Timestamp_init_default {0, 0} +#define google_protobuf_Timestamp_init_zero {0, 0} + +/* Field tags (for use in manual encoding/decoding) */ +#define google_protobuf_Timestamp_seconds_tag 1 +#define google_protobuf_Timestamp_nanos_tag 2 + +/* Struct field encoding specification for nanopb */ +extern const pb_field_t google_protobuf_Timestamp_fields[3]; + +/* Maximum encoded size of messages (where known) */ +#define google_protobuf_Timestamp_size 22 + +/* Message IDs (where set with "msgid" option) */ +#ifdef PB_MSGID + +#define TIMESTAMP_MESSAGES \ + + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif +/* @@protoc_insertion_point(eof) */ + +#endif diff --git a/Firestore/Protos/protos/google/protobuf/struct.proto b/Firestore/Protos/protos/google/protobuf/struct.proto new file mode 100644 index 0000000..7d7808e --- /dev/null +++ b/Firestore/Protos/protos/google/protobuf/struct.proto @@ -0,0 +1,96 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// 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 +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// 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. + +syntax = "proto3"; + +package google.protobuf; + +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; +option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "StructProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; + + +// `Struct` represents a structured data value, consisting of fields +// which map to dynamically typed values. In some languages, `Struct` +// might be supported by a native representation. For example, in +// scripting languages like JS a struct is represented as an +// object. The details of that representation are described together +// with the proto support for the language. +// +// The JSON representation for `Struct` is JSON object. +message Struct { + // Unordered map of dynamically typed values. + map fields = 1; +} + +// `Value` represents a dynamically typed value which can be either +// null, a number, a string, a boolean, a recursive struct value, or a +// list of values. A producer of value is expected to set one of that +// variants, absence of any variant indicates an error. +// +// The JSON representation for `Value` is JSON value. +message Value { + // The kind of value. + oneof kind { + // Represents a null value. + NullValue null_value = 1; + // Represents a double value. + double number_value = 2; + // Represents a string value. + string string_value = 3; + // Represents a boolean value. + bool bool_value = 4; + // Represents a structured value. + Struct struct_value = 5; + // Represents a repeated `Value`. + ListValue list_value = 6; + } +} + +// `NullValue` is a singleton enumeration to represent the null value for the +// `Value` type union. +// +// The JSON representation for `NullValue` is JSON `null`. +enum NullValue { + // Null value. + NULL_VALUE = 0; +} + +// `ListValue` is a wrapper around a repeated field of values. +// +// The JSON representation for `ListValue` is JSON array. +message ListValue { + // Repeated field of dynamically typed values. + repeated Value values = 1; +} diff --git a/Firestore/Protos/protos/google/protobuf/timestamp.proto b/Firestore/Protos/protos/google/protobuf/timestamp.proto new file mode 100644 index 0000000..b7cbd17 --- /dev/null +++ b/Firestore/Protos/protos/google/protobuf/timestamp.proto @@ -0,0 +1,133 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// 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 +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// 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. + +syntax = "proto3"; + +package google.protobuf; + +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; +option go_package = "github.com/golang/protobuf/ptypes/timestamp"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "TimestampProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; + +// A Timestamp represents a point in time independent of any time zone +// or calendar, represented as seconds and fractions of seconds at +// nanosecond resolution in UTC Epoch time. It is encoded using the +// Proleptic Gregorian Calendar which extends the Gregorian calendar +// backwards to year one. It is encoded assuming all minutes are 60 +// seconds long, i.e. leap seconds are "smeared" so that no leap second +// table is needed for interpretation. Range is from +// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. +// By restricting to that range, we ensure that we can convert to +// and from RFC 3339 date strings. +// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). +// +// # Examples +// +// Example 1: Compute Timestamp from POSIX `time()`. +// +// Timestamp timestamp; +// timestamp.set_seconds(time(NULL)); +// timestamp.set_nanos(0); +// +// Example 2: Compute Timestamp from POSIX `gettimeofday()`. +// +// struct timeval tv; +// gettimeofday(&tv, NULL); +// +// Timestamp timestamp; +// timestamp.set_seconds(tv.tv_sec); +// timestamp.set_nanos(tv.tv_usec * 1000); +// +// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. +// +// FILETIME ft; +// GetSystemTimeAsFileTime(&ft); +// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; +// +// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z +// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. +// Timestamp timestamp; +// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); +// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); +// +// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. +// +// long millis = System.currentTimeMillis(); +// +// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) +// .setNanos((int) ((millis % 1000) * 1000000)).build(); +// +// +// Example 5: Compute Timestamp from current time in Python. +// +// timestamp = Timestamp() +// timestamp.GetCurrentTime() +// +// # JSON Mapping +// +// In JSON format, the Timestamp type is encoded as a string in the +// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the +// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" +// where {year} is always expressed using four digits while {month}, {day}, +// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional +// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), +// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone +// is required, though only UTC (as indicated by "Z") is presently supported. +// +// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past +// 01:30 UTC on January 15, 2017. +// +// In JavaScript, one can convert a Date object to this format using the +// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] +// method. In Python, a standard `datetime.datetime` object can be converted +// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) +// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one +// can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( +// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) +// to obtain a formatter capable of generating timestamps in this format. +// +// +message Timestamp { + + // Represents seconds of UTC time since Unix epoch + // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + // 9999-12-31T23:59:59Z inclusive. + int64 seconds = 1; + + // Non-negative fractions of a second at nanosecond resolution. Negative + // second values with fractions must still have non-negative nanos values + // that count forward in time. Must be from 0 to 999,999,999 + // inclusive. + int32 nanos = 2; +} -- cgit v1.2.3