aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/add_person.cc
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2017-09-08 15:44:09 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2017-09-08 16:01:49 -0700
commit74bf45f379b35e1d103940f35d7a04545b0235d4 (patch)
treed3fae8b44d416796e0bc36351271bb1379d27091 /examples/add_person.cc
parent2ad5c0a86443f567241e0295c313baf4f0e15379 (diff)
Add bazel support for examples.
The example utilizes native bazel rules (proto_library, cc_proto_library, java_proto_library, java_lite_proto_library) to show how easy it is to build protobuf with bazel's native support. It also makes use of well known types which was not possible until the latest bazel 0.5.4 release and https://github.com/google/protobuf/pull/3594 .
Diffstat (limited to 'examples/add_person.cc')
-rw-r--r--examples/add_person.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/add_person.cc b/examples/add_person.cc
index 9bec4b37..856e90bb 100644
--- a/examples/add_person.cc
+++ b/examples/add_person.cc
@@ -1,11 +1,17 @@
// See README.txt for information and build instructions.
-#include <iostream>
+#include <ctime>
#include <fstream>
+#include <google/protobuf/util/time_util.h>
+#include <iostream>
#include <string>
+
#include "addressbook.pb.h"
+
using namespace std;
+using google::protobuf::util::TimeUtil;
+
// This function fills in a Person message based on user input.
void PromptForAddress(tutorial::Person* person) {
cout << "Enter person ID number: ";
@@ -48,6 +54,7 @@ void PromptForAddress(tutorial::Person* person) {
cout << "Unknown phone type. Using default." << endl;
}
}
+ *person->mutable_last_updated() = TimeUtil::SecondsToTimestamp(time(NULL));
}
// Main function: Reads the entire address book from a file,