diff --git a/cpp/route_guide/Makefile b/cpp/route_guide/Makefile new file mode 100644 index 0000000..b9579e0 --- /dev/null +++ b/cpp/route_guide/Makefile @@ -0,0 +1,47 @@ +# +# Copyright 2015, Google Inc. +# All rights reserved. +# +# 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. +# + +CXX=g++ +CPPFLAGS=-I/usr/local/include -pthread +CXXFLAGS=-std=c++11 +LDFLAGS=-L/usr/local/lib -lgrpc -lgrpc++ -lprotobuf -lpthread -ldl + +all: greeter_client greeter_server + +greeter_client: helloworld.pb.o greeter_client.o + $(CXX) $(CPPFLAGS) $^ $(LDFLAGS) -o $@ + +greeter_server: helloworld.pb.o greeter_server.o + $(CXX) $(CPPFLAGS) $^ $(LDFLAGS) -o $@ + +clean: + rm -f *.o greeter_client greeter_server + diff --git a/cpp/route_guide/route_guide.pb.cc b/cpp/route_guide/route_guide.pb.cc new file mode 100644 index 0000000..6f4a1e7 --- /dev/null +++ b/cpp/route_guide/route_guide.pb.cc @@ -0,0 +1,1736 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "route_guide.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace examples { + +namespace { + +const ::google::protobuf::Descriptor* Point_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + Point_reflection_ = NULL; +const ::google::protobuf::Descriptor* Rectangle_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + Rectangle_reflection_ = NULL; +const ::google::protobuf::Descriptor* Feature_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + Feature_reflection_ = NULL; +const ::google::protobuf::Descriptor* RouteNote_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + RouteNote_reflection_ = NULL; +const ::google::protobuf::Descriptor* RouteSummary_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + RouteSummary_reflection_ = NULL; + +} // namespace + + +void protobuf_AssignDesc_route_5fguide_2eproto() { + protobuf_AddDesc_route_5fguide_2eproto(); + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( + "route_guide.proto"); + GOOGLE_CHECK(file != NULL); + Point_descriptor_ = file->message_type(0); + static const int Point_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, latitude_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, longitude_), + }; + Point_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + Point_descriptor_, + Point::default_instance_, + Point_offsets_, + -1, + -1, + -1, + sizeof(Point), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Point, _is_default_instance_)); + Rectangle_descriptor_ = file->message_type(1); + static const int Rectangle_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, lo_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, hi_), + }; + Rectangle_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + Rectangle_descriptor_, + Rectangle::default_instance_, + Rectangle_offsets_, + -1, + -1, + -1, + sizeof(Rectangle), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Rectangle, _is_default_instance_)); + Feature_descriptor_ = file->message_type(2); + static const int Feature_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, name_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, location_), + }; + Feature_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + Feature_descriptor_, + Feature::default_instance_, + Feature_offsets_, + -1, + -1, + -1, + sizeof(Feature), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Feature, _is_default_instance_)); + RouteNote_descriptor_ = file->message_type(3); + static const int RouteNote_offsets_[2] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, location_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, message_), + }; + RouteNote_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + RouteNote_descriptor_, + RouteNote::default_instance_, + RouteNote_offsets_, + -1, + -1, + -1, + sizeof(RouteNote), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteNote, _is_default_instance_)); + RouteSummary_descriptor_ = file->message_type(4); + static const int RouteSummary_offsets_[4] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, point_count_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, feature_count_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, distance_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, elapsed_time_), + }; + RouteSummary_reflection_ = + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( + RouteSummary_descriptor_, + RouteSummary::default_instance_, + RouteSummary_offsets_, + -1, + -1, + -1, + sizeof(RouteSummary), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RouteSummary, _is_default_instance_)); +} + +namespace { + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +inline void protobuf_AssignDescriptorsOnce() { + ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, + &protobuf_AssignDesc_route_5fguide_2eproto); +} + +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + Point_descriptor_, &Point::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + Rectangle_descriptor_, &Rectangle::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + Feature_descriptor_, &Feature::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + RouteNote_descriptor_, &RouteNote::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + RouteSummary_descriptor_, &RouteSummary::default_instance()); +} + +} // namespace + +void protobuf_ShutdownFile_route_5fguide_2eproto() { + delete Point::default_instance_; + delete Point_reflection_; + delete Rectangle::default_instance_; + delete Rectangle_reflection_; + delete Feature::default_instance_; + delete Feature_reflection_; + delete RouteNote::default_instance_; + delete RouteNote_reflection_; + delete RouteSummary::default_instance_; + delete RouteSummary_reflection_; +} + +void protobuf_AddDesc_route_5fguide_2eproto() { + static bool already_here = false; + if (already_here) return; + already_here = true; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + "\n\021route_guide.proto\022\010examples\",\n\005Point\022\020" + "\n\010latitude\030\001 \001(\005\022\021\n\tlongitude\030\002 \001(\005\"E\n\tR" + "ectangle\022\033\n\002lo\030\001 \001(\0132\017.examples.Point\022\033\n" + "\002hi\030\002 \001(\0132\017.examples.Point\":\n\007Feature\022\014\n" + "\004name\030\001 \001(\t\022!\n\010location\030\002 \001(\0132\017.examples" + ".Point\"\?\n\tRouteNote\022!\n\010location\030\001 \001(\0132\017." + "examples.Point\022\017\n\007message\030\002 \001(\t\"b\n\014Route" + "Summary\022\023\n\013point_count\030\001 \001(\005\022\025\n\rfeature_" + "count\030\002 \001(\005\022\020\n\010distance\030\003 \001(\005\022\024\n\014elapsed" + "_time\030\004 \001(\0052\365\001\n\nRouteGuide\0222\n\nGetFeature" + "\022\017.examples.Point\032\021.examples.Feature\"\000\022:" + "\n\014ListFeatures\022\023.examples.Rectangle\032\021.ex" + "amples.Feature\"\0000\001\022:\n\013RecordRoute\022\017.exam" + "ples.Point\032\026.examples.RouteSummary\"\000(\001\022;" + "\n\tRouteChat\022\023.examples.RouteNote\032\023.examp" + "les.RouteNote\"\000(\0010\001B\t\n\007ex.grpcb\006proto3", 638); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "route_guide.proto", &protobuf_RegisterTypes); + Point::default_instance_ = new Point(); + Rectangle::default_instance_ = new Rectangle(); + Feature::default_instance_ = new Feature(); + RouteNote::default_instance_ = new RouteNote(); + RouteSummary::default_instance_ = new RouteSummary(); + Point::default_instance_->InitAsDefaultInstance(); + Rectangle::default_instance_->InitAsDefaultInstance(); + Feature::default_instance_->InitAsDefaultInstance(); + RouteNote::default_instance_->InitAsDefaultInstance(); + RouteSummary::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_route_5fguide_2eproto); +} + +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer_route_5fguide_2eproto { + StaticDescriptorInitializer_route_5fguide_2eproto() { + protobuf_AddDesc_route_5fguide_2eproto(); + } +} static_descriptor_initializer_route_5fguide_2eproto_; + +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD; +static void MergeFromFail(int line) { + GOOGLE_CHECK(false) << __FILE__ << ":" << line; +} + +} // namespace + + +// =================================================================== + +#ifndef _MSC_VER +const int Point::kLatitudeFieldNumber; +const int Point::kLongitudeFieldNumber; +#endif // !_MSC_VER + +Point::Point() + : ::google::protobuf::Message() , _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:examples.Point) +} + +void Point::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +Point::Point(const Point& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:examples.Point) +} + +void Point::SharedCtor() { + _is_default_instance_ = false; + _cached_size_ = 0; + latitude_ = 0; + longitude_ = 0; +} + +Point::~Point() { + // @@protoc_insertion_point(destructor:examples.Point) + SharedDtor(); +} + +void Point::SharedDtor() { + if (this != default_instance_) { + } +} + +void Point::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Point::descriptor() { + protobuf_AssignDescriptorsOnce(); + return Point_descriptor_; +} + +const Point& Point::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto(); + return *default_instance_; +} + +Point* Point::default_instance_ = NULL; + +Point* Point::New(::google::protobuf::Arena* arena) const { + Point* n = new Point; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Point::Clear() { +#define OFFSET_OF_FIELD_(f) (reinterpret_cast( \ + &reinterpret_cast(16)->f) - \ + reinterpret_cast(16)) + +#define ZR_(first, last) do { \ + size_t f = OFFSET_OF_FIELD_(first); \ + size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \ + ::memset(&first, 0, n); \ + } while (0) + + ZR_(latitude_, longitude_); + +#undef OFFSET_OF_FIELD_ +#undef ZR_ + +} + +bool Point::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:examples.Point) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional int32 latitude = 1; + case 1: { + if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &latitude_))); + + } else { + goto handle_unusual; + } + if (input->ExpectTag(16)) goto parse_longitude; + break; + } + + // optional int32 longitude = 2; + case 2: { + if (tag == 16) { + parse_longitude: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &longitude_))); + + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:examples.Point) + return true; +failure: + // @@protoc_insertion_point(parse_failure:examples.Point) + return false; +#undef DO_ +} + +void Point::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:examples.Point) + // optional int32 latitude = 1; + if (this->latitude() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->latitude(), output); + } + + // optional int32 longitude = 2; + if (this->longitude() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->longitude(), output); + } + + // @@protoc_insertion_point(serialize_end:examples.Point) +} + +::google::protobuf::uint8* Point::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:examples.Point) + // optional int32 latitude = 1; + if (this->latitude() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->latitude(), target); + } + + // optional int32 longitude = 2; + if (this->longitude() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->longitude(), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:examples.Point) + return target; +} + +int Point::ByteSize() const { + int total_size = 0; + + // optional int32 latitude = 1; + if (this->latitude() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->latitude()); + } + + // optional int32 longitude = 2; + if (this->longitude() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->longitude()); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Point::MergeFrom(const ::google::protobuf::Message& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Point* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void Point::MergeFrom(const Point& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.latitude() != 0) { + set_latitude(from.latitude()); + } + if (from.longitude() != 0) { + set_longitude(from.longitude()); + } +} + +void Point::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Point::CopyFrom(const Point& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Point::IsInitialized() const { + + return true; +} + +void Point::Swap(Point* other) { + if (other == this) return; + InternalSwap(other); +} +void Point::InternalSwap(Point* other) { + std::swap(latitude_, other->latitude_); + std::swap(longitude_, other->longitude_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata Point::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = Point_descriptor_; + metadata.reflection = Point_reflection_; + return metadata; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int Rectangle::kLoFieldNumber; +const int Rectangle::kHiFieldNumber; +#endif // !_MSC_VER + +Rectangle::Rectangle() + : ::google::protobuf::Message() , _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:examples.Rectangle) +} + +void Rectangle::InitAsDefaultInstance() { + _is_default_instance_ = true; + lo_ = const_cast< ::examples::Point*>(&::examples::Point::default_instance()); + hi_ = const_cast< ::examples::Point*>(&::examples::Point::default_instance()); +} + +Rectangle::Rectangle(const Rectangle& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:examples.Rectangle) +} + +void Rectangle::SharedCtor() { + _is_default_instance_ = false; + _cached_size_ = 0; + lo_ = NULL; + hi_ = NULL; +} + +Rectangle::~Rectangle() { + // @@protoc_insertion_point(destructor:examples.Rectangle) + SharedDtor(); +} + +void Rectangle::SharedDtor() { + if (this != default_instance_) { + delete lo_; + delete hi_; + } +} + +void Rectangle::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Rectangle::descriptor() { + protobuf_AssignDescriptorsOnce(); + return Rectangle_descriptor_; +} + +const Rectangle& Rectangle::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto(); + return *default_instance_; +} + +Rectangle* Rectangle::default_instance_ = NULL; + +Rectangle* Rectangle::New(::google::protobuf::Arena* arena) const { + Rectangle* n = new Rectangle; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Rectangle::Clear() { + if (lo_ != NULL) delete lo_; + lo_ = NULL; + if (hi_ != NULL) delete hi_; + hi_ = NULL; +} + +bool Rectangle::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:examples.Rectangle) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional .examples.Point lo = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_lo())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_hi; + break; + } + + // optional .examples.Point hi = 2; + case 2: { + if (tag == 18) { + parse_hi: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_hi())); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:examples.Rectangle) + return true; +failure: + // @@protoc_insertion_point(parse_failure:examples.Rectangle) + return false; +#undef DO_ +} + +void Rectangle::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:examples.Rectangle) + // optional .examples.Point lo = 1; + if (this->has_lo()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, *this->lo_, output); + } + + // optional .examples.Point hi = 2; + if (this->has_hi()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 2, *this->hi_, output); + } + + // @@protoc_insertion_point(serialize_end:examples.Rectangle) +} + +::google::protobuf::uint8* Rectangle::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:examples.Rectangle) + // optional .examples.Point lo = 1; + if (this->has_lo()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 1, *this->lo_, target); + } + + // optional .examples.Point hi = 2; + if (this->has_hi()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 2, *this->hi_, target); + } + + // @@protoc_insertion_point(serialize_to_array_end:examples.Rectangle) + return target; +} + +int Rectangle::ByteSize() const { + int total_size = 0; + + // optional .examples.Point lo = 1; + if (this->has_lo()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->lo_); + } + + // optional .examples.Point hi = 2; + if (this->has_hi()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hi_); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Rectangle::MergeFrom(const ::google::protobuf::Message& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Rectangle* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void Rectangle::MergeFrom(const Rectangle& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.has_lo()) { + mutable_lo()->::examples::Point::MergeFrom(from.lo()); + } + if (from.has_hi()) { + mutable_hi()->::examples::Point::MergeFrom(from.hi()); + } +} + +void Rectangle::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Rectangle::CopyFrom(const Rectangle& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Rectangle::IsInitialized() const { + + return true; +} + +void Rectangle::Swap(Rectangle* other) { + if (other == this) return; + InternalSwap(other); +} +void Rectangle::InternalSwap(Rectangle* other) { + std::swap(lo_, other->lo_); + std::swap(hi_, other->hi_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata Rectangle::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = Rectangle_descriptor_; + metadata.reflection = Rectangle_reflection_; + return metadata; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int Feature::kNameFieldNumber; +const int Feature::kLocationFieldNumber; +#endif // !_MSC_VER + +Feature::Feature() + : ::google::protobuf::Message() , _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:examples.Feature) +} + +void Feature::InitAsDefaultInstance() { + _is_default_instance_ = true; + location_ = const_cast< ::examples::Point*>(&::examples::Point::default_instance()); +} + +Feature::Feature(const Feature& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:examples.Feature) +} + +void Feature::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + location_ = NULL; +} + +Feature::~Feature() { + // @@protoc_insertion_point(destructor:examples.Feature) + SharedDtor(); +} + +void Feature::SharedDtor() { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + delete location_; + } +} + +void Feature::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Feature::descriptor() { + protobuf_AssignDescriptorsOnce(); + return Feature_descriptor_; +} + +const Feature& Feature::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto(); + return *default_instance_; +} + +Feature* Feature::default_instance_ = NULL; + +Feature* Feature::New(::google::protobuf::Arena* arena) const { + Feature* n = new Feature; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void Feature::Clear() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (location_ != NULL) delete location_; + location_ = NULL; +} + +bool Feature::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:examples.Feature) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string name = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_name())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "examples.Feature.name"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_location; + break; + } + + // optional .examples.Point location = 2; + case 2: { + if (tag == 18) { + parse_location: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_location())); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:examples.Feature) + return true; +failure: + // @@protoc_insertion_point(parse_failure:examples.Feature) + return false; +#undef DO_ +} + +void Feature::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:examples.Feature) + // optional string name = 1; + if (this->name().size() > 0) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "examples.Feature.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->name(), output); + } + + // optional .examples.Point location = 2; + if (this->has_location()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 2, *this->location_, output); + } + + // @@protoc_insertion_point(serialize_end:examples.Feature) +} + +::google::protobuf::uint8* Feature::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:examples.Feature) + // optional string name = 1; + if (this->name().size() > 0) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "examples.Feature.name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->name(), target); + } + + // optional .examples.Point location = 2; + if (this->has_location()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 2, *this->location_, target); + } + + // @@protoc_insertion_point(serialize_to_array_end:examples.Feature) + return target; +} + +int Feature::ByteSize() const { + int total_size = 0; + + // optional string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // optional .examples.Point location = 2; + if (this->has_location()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->location_); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Feature::MergeFrom(const ::google::protobuf::Message& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const Feature* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void Feature::MergeFrom(const Feature& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.name().size() > 0) { + + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_location()) { + mutable_location()->::examples::Point::MergeFrom(from.location()); + } +} + +void Feature::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Feature::CopyFrom(const Feature& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Feature::IsInitialized() const { + + return true; +} + +void Feature::Swap(Feature* other) { + if (other == this) return; + InternalSwap(other); +} +void Feature::InternalSwap(Feature* other) { + name_.Swap(&other->name_); + std::swap(location_, other->location_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata Feature::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = Feature_descriptor_; + metadata.reflection = Feature_reflection_; + return metadata; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int RouteNote::kLocationFieldNumber; +const int RouteNote::kMessageFieldNumber; +#endif // !_MSC_VER + +RouteNote::RouteNote() + : ::google::protobuf::Message() , _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:examples.RouteNote) +} + +void RouteNote::InitAsDefaultInstance() { + _is_default_instance_ = true; + location_ = const_cast< ::examples::Point*>(&::examples::Point::default_instance()); +} + +RouteNote::RouteNote(const RouteNote& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:examples.RouteNote) +} + +void RouteNote::SharedCtor() { + _is_default_instance_ = false; + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + location_ = NULL; + message_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +RouteNote::~RouteNote() { + // @@protoc_insertion_point(destructor:examples.RouteNote) + SharedDtor(); +} + +void RouteNote::SharedDtor() { + message_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != default_instance_) { + delete location_; + } +} + +void RouteNote::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* RouteNote::descriptor() { + protobuf_AssignDescriptorsOnce(); + return RouteNote_descriptor_; +} + +const RouteNote& RouteNote::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto(); + return *default_instance_; +} + +RouteNote* RouteNote::default_instance_ = NULL; + +RouteNote* RouteNote::New(::google::protobuf::Arena* arena) const { + RouteNote* n = new RouteNote; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void RouteNote::Clear() { + if (location_ != NULL) delete location_; + location_ = NULL; + message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +bool RouteNote::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:examples.RouteNote) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional .examples.Point location = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_location())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_message; + break; + } + + // optional string message = 2; + case 2: { + if (tag == 18) { + parse_message: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_message())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->message().data(), this->message().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "examples.RouteNote.message"); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:examples.RouteNote) + return true; +failure: + // @@protoc_insertion_point(parse_failure:examples.RouteNote) + return false; +#undef DO_ +} + +void RouteNote::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:examples.RouteNote) + // optional .examples.Point location = 1; + if (this->has_location()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, *this->location_, output); + } + + // optional string message = 2; + if (this->message().size() > 0) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->message().data(), this->message().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "examples.RouteNote.message"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 2, this->message(), output); + } + + // @@protoc_insertion_point(serialize_end:examples.RouteNote) +} + +::google::protobuf::uint8* RouteNote::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:examples.RouteNote) + // optional .examples.Point location = 1; + if (this->has_location()) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteMessageNoVirtualToArray( + 1, *this->location_, target); + } + + // optional string message = 2; + if (this->message().size() > 0) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->message().data(), this->message().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "examples.RouteNote.message"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 2, this->message(), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:examples.RouteNote) + return target; +} + +int RouteNote::ByteSize() const { + int total_size = 0; + + // optional .examples.Point location = 1; + if (this->has_location()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->location_); + } + + // optional string message = 2; + if (this->message().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->message()); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void RouteNote::MergeFrom(const ::google::protobuf::Message& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const RouteNote* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void RouteNote::MergeFrom(const RouteNote& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.has_location()) { + mutable_location()->::examples::Point::MergeFrom(from.location()); + } + if (from.message().size() > 0) { + + message_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.message_); + } +} + +void RouteNote::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void RouteNote::CopyFrom(const RouteNote& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool RouteNote::IsInitialized() const { + + return true; +} + +void RouteNote::Swap(RouteNote* other) { + if (other == this) return; + InternalSwap(other); +} +void RouteNote::InternalSwap(RouteNote* other) { + std::swap(location_, other->location_); + message_.Swap(&other->message_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata RouteNote::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = RouteNote_descriptor_; + metadata.reflection = RouteNote_reflection_; + return metadata; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int RouteSummary::kPointCountFieldNumber; +const int RouteSummary::kFeatureCountFieldNumber; +const int RouteSummary::kDistanceFieldNumber; +const int RouteSummary::kElapsedTimeFieldNumber; +#endif // !_MSC_VER + +RouteSummary::RouteSummary() + : ::google::protobuf::Message() , _internal_metadata_(NULL) { + SharedCtor(); + // @@protoc_insertion_point(constructor:examples.RouteSummary) +} + +void RouteSummary::InitAsDefaultInstance() { + _is_default_instance_ = true; +} + +RouteSummary::RouteSummary(const RouteSummary& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:examples.RouteSummary) +} + +void RouteSummary::SharedCtor() { + _is_default_instance_ = false; + _cached_size_ = 0; + point_count_ = 0; + feature_count_ = 0; + distance_ = 0; + elapsed_time_ = 0; +} + +RouteSummary::~RouteSummary() { + // @@protoc_insertion_point(destructor:examples.RouteSummary) + SharedDtor(); +} + +void RouteSummary::SharedDtor() { + if (this != default_instance_) { + } +} + +void RouteSummary::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* RouteSummary::descriptor() { + protobuf_AssignDescriptorsOnce(); + return RouteSummary_descriptor_; +} + +const RouteSummary& RouteSummary::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_route_5fguide_2eproto(); + return *default_instance_; +} + +RouteSummary* RouteSummary::default_instance_ = NULL; + +RouteSummary* RouteSummary::New(::google::protobuf::Arena* arena) const { + RouteSummary* n = new RouteSummary; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void RouteSummary::Clear() { +#define OFFSET_OF_FIELD_(f) (reinterpret_cast( \ + &reinterpret_cast(16)->f) - \ + reinterpret_cast(16)) + +#define ZR_(first, last) do { \ + size_t f = OFFSET_OF_FIELD_(first); \ + size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \ + ::memset(&first, 0, n); \ + } while (0) + + ZR_(point_count_, elapsed_time_); + +#undef OFFSET_OF_FIELD_ +#undef ZR_ + +} + +bool RouteSummary::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:examples.RouteSummary) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional int32 point_count = 1; + case 1: { + if (tag == 8) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &point_count_))); + + } else { + goto handle_unusual; + } + if (input->ExpectTag(16)) goto parse_feature_count; + break; + } + + // optional int32 feature_count = 2; + case 2: { + if (tag == 16) { + parse_feature_count: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &feature_count_))); + + } else { + goto handle_unusual; + } + if (input->ExpectTag(24)) goto parse_distance; + break; + } + + // optional int32 distance = 3; + case 3: { + if (tag == 24) { + parse_distance: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &distance_))); + + } else { + goto handle_unusual; + } + if (input->ExpectTag(32)) goto parse_elapsed_time; + break; + } + + // optional int32 elapsed_time = 4; + case 4: { + if (tag == 32) { + parse_elapsed_time: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &elapsed_time_))); + + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag)); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:examples.RouteSummary) + return true; +failure: + // @@protoc_insertion_point(parse_failure:examples.RouteSummary) + return false; +#undef DO_ +} + +void RouteSummary::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:examples.RouteSummary) + // optional int32 point_count = 1; + if (this->point_count() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->point_count(), output); + } + + // optional int32 feature_count = 2; + if (this->feature_count() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->feature_count(), output); + } + + // optional int32 distance = 3; + if (this->distance() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->distance(), output); + } + + // optional int32 elapsed_time = 4; + if (this->elapsed_time() != 0) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->elapsed_time(), output); + } + + // @@protoc_insertion_point(serialize_end:examples.RouteSummary) +} + +::google::protobuf::uint8* RouteSummary::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:examples.RouteSummary) + // optional int32 point_count = 1; + if (this->point_count() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->point_count(), target); + } + + // optional int32 feature_count = 2; + if (this->feature_count() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->feature_count(), target); + } + + // optional int32 distance = 3; + if (this->distance() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->distance(), target); + } + + // optional int32 elapsed_time = 4; + if (this->elapsed_time() != 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->elapsed_time(), target); + } + + // @@protoc_insertion_point(serialize_to_array_end:examples.RouteSummary) + return target; +} + +int RouteSummary::ByteSize() const { + int total_size = 0; + + // optional int32 point_count = 1; + if (this->point_count() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->point_count()); + } + + // optional int32 feature_count = 2; + if (this->feature_count() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->feature_count()); + } + + // optional int32 distance = 3; + if (this->distance() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->distance()); + } + + // optional int32 elapsed_time = 4; + if (this->elapsed_time() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->elapsed_time()); + } + + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void RouteSummary::MergeFrom(const ::google::protobuf::Message& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const RouteSummary* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void RouteSummary::MergeFrom(const RouteSummary& from) { + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + if (from.point_count() != 0) { + set_point_count(from.point_count()); + } + if (from.feature_count() != 0) { + set_feature_count(from.feature_count()); + } + if (from.distance() != 0) { + set_distance(from.distance()); + } + if (from.elapsed_time() != 0) { + set_elapsed_time(from.elapsed_time()); + } +} + +void RouteSummary::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void RouteSummary::CopyFrom(const RouteSummary& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool RouteSummary::IsInitialized() const { + + return true; +} + +void RouteSummary::Swap(RouteSummary* other) { + if (other == this) return; + InternalSwap(other); +} +void RouteSummary::InternalSwap(RouteSummary* other) { + std::swap(point_count_, other->point_count_); + std::swap(feature_count_, other->feature_count_); + std::swap(distance_, other->distance_); + std::swap(elapsed_time_, other->elapsed_time_); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata RouteSummary::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = RouteSummary_descriptor_; + metadata.reflection = RouteSummary_reflection_; + return metadata; +} + + +static const char* RouteGuide_method_names[] = { + "/examples.RouteGuide/GetFeature", + "/examples.RouteGuide/ListFeatures", + "/examples.RouteGuide/RecordRoute", + "/examples.RouteGuide/RouteChat", +}; + +RouteGuide::Stub* RouteGuide::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) { + RouteGuide::Stub* stub = new RouteGuide::Stub(); + stub->set_channel(channel); + return stub; +}; + +::grpc::Status RouteGuide::Stub::GetFeature(::grpc::ClientContext* context, const ::examples::Point& request, ::examples::Feature* response) { + return ::grpc::BlockingUnaryCall(channel(),::grpc::RpcMethod(RouteGuide_method_names[0]), context, request, response); +} + +::grpc::ClientAsyncResponseReader< ::examples::Feature>* RouteGuide::Stub::GetFeature(::grpc::ClientContext* context, const ::examples::Point& request, ::grpc::CompletionQueue* cq, void* tag) { + return new ::grpc::ClientAsyncResponseReader< ::examples::Feature>(channel(), cq, ::grpc::RpcMethod(RouteGuide_method_names[0]), context, request, tag); +} + +::grpc::ClientReader< ::examples::Feature>* RouteGuide::Stub::ListFeatures(::grpc::ClientContext* context, const ::examples::Rectangle& request) { + return new ::grpc::ClientReader< ::examples::Feature>(channel(),::grpc::RpcMethod(RouteGuide_method_names[1], ::grpc::RpcMethod::RpcType::SERVER_STREAMING), context, request); +} + +::grpc::ClientAsyncReader< ::examples::Feature>* RouteGuide::Stub::ListFeatures(::grpc::ClientContext* context, const ::examples::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag) { + return new ::grpc::ClientAsyncReader< ::examples::Feature>(channel(), cq, ::grpc::RpcMethod(RouteGuide_method_names[1], ::grpc::RpcMethod::RpcType::SERVER_STREAMING), context, request, tag); +} + +::grpc::ClientWriter< ::examples::Point>* RouteGuide::Stub::RecordRoute(::grpc::ClientContext* context, ::examples::RouteSummary* response) { + return new ::grpc::ClientWriter< ::examples::Point>(channel(),::grpc::RpcMethod(RouteGuide_method_names[2], ::grpc::RpcMethod::RpcType::CLIENT_STREAMING), context, response); +} + +::grpc::ClientAsyncWriter< ::examples::Point>* RouteGuide::Stub::RecordRoute(::grpc::ClientContext* context, ::examples::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag) { + return new ::grpc::ClientAsyncWriter< ::examples::Point>(channel(), cq, ::grpc::RpcMethod(RouteGuide_method_names[2], ::grpc::RpcMethod::RpcType::CLIENT_STREAMING), context, response, tag); +} + +::grpc::ClientReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* RouteGuide::Stub::RouteChat(::grpc::ClientContext* context) { + return new ::grpc::ClientReaderWriter< ::examples::RouteNote, ::examples::RouteNote>(channel(),::grpc::RpcMethod(RouteGuide_method_names[3], ::grpc::RpcMethod::RpcType::BIDI_STREAMING), context); +} + +::grpc::ClientAsyncReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* RouteGuide::Stub::RouteChat(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) { + return new ::grpc::ClientAsyncReaderWriter< ::examples::RouteNote, ::examples::RouteNote>(channel(), cq, ::grpc::RpcMethod(RouteGuide_method_names[3], ::grpc::RpcMethod::RpcType::BIDI_STREAMING), context, tag); +} + +RouteGuide::AsyncService::AsyncService(::grpc::CompletionQueue* cq) : ::grpc::AsynchronousService(cq, RouteGuide_method_names, 4) {} + +RouteGuide::Service::~Service() { + delete service_; +} + +::grpc::Status RouteGuide::Service::GetFeature(::grpc::ServerContext* context, const ::examples::Point* request, ::examples::Feature* response) { + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED); +} + +void RouteGuide::AsyncService::RequestGetFeature(::grpc::ServerContext* context, ::examples::Point* request, ::grpc::ServerAsyncResponseWriter< ::examples::Feature>* response, ::grpc::CompletionQueue* cq, void* tag) { + AsynchronousService::RequestAsyncUnary(0, context, request, response, cq, tag); +} + +::grpc::Status RouteGuide::Service::ListFeatures(::grpc::ServerContext* context, const ::examples::Rectangle* request, ::grpc::ServerWriter< ::examples::Feature>* writer) { + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED); +} + +void RouteGuide::AsyncService::RequestListFeatures(::grpc::ServerContext* context, ::examples::Rectangle* request, ::grpc::ServerAsyncWriter< ::examples::Feature>* writer, ::grpc::CompletionQueue* cq, void* tag) { + AsynchronousService::RequestServerStreaming(1, context, request, writer, cq, tag); +} + +::grpc::Status RouteGuide::Service::RecordRoute(::grpc::ServerContext* context, ::grpc::ServerReader< ::examples::Point>* reader, ::examples::RouteSummary* response) { + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED); +} + +void RouteGuide::AsyncService::RequestRecordRoute(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::examples::RouteSummary, ::examples::Point>* reader, ::grpc::CompletionQueue* cq, void* tag) { + AsynchronousService::RequestClientStreaming(2, context, reader, cq, tag); +} + +::grpc::Status RouteGuide::Service::RouteChat(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* stream) { + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED); +} + +void RouteGuide::AsyncService::RequestRouteChat(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* stream, ::grpc::CompletionQueue* cq, void *tag) { + AsynchronousService::RequestBidiStreaming(3, context, stream, cq, tag); +} + +::grpc::RpcService* RouteGuide::Service::service() { + if (service_ != nullptr) { + return service_; + } + service_ = new ::grpc::RpcService(); + service_->AddMethod(new ::grpc::RpcServiceMethod( + RouteGuide_method_names[0], + ::grpc::RpcMethod::NORMAL_RPC, + new ::grpc::RpcMethodHandler< RouteGuide::Service, ::examples::Point, ::examples::Feature>( + std::function< ::grpc::Status(RouteGuide::Service*, ::grpc::ServerContext*, const ::examples::Point*, ::examples::Feature*)>(&RouteGuide::Service::GetFeature), this), + new ::examples::Point, new ::examples::Feature)); + service_->AddMethod(new ::grpc::RpcServiceMethod( + RouteGuide_method_names[1], + ::grpc::RpcMethod::SERVER_STREAMING, + new ::grpc::ServerStreamingHandler< RouteGuide::Service, ::examples::Rectangle, ::examples::Feature>( + std::function< ::grpc::Status(RouteGuide::Service*, ::grpc::ServerContext*, const ::examples::Rectangle*, ::grpc::ServerWriter< ::examples::Feature>*)>(&RouteGuide::Service::ListFeatures), this), + new ::examples::Rectangle, new ::examples::Feature)); + service_->AddMethod(new ::grpc::RpcServiceMethod( + RouteGuide_method_names[2], + ::grpc::RpcMethod::CLIENT_STREAMING, + new ::grpc::ClientStreamingHandler< RouteGuide::Service, ::examples::Point, ::examples::RouteSummary>( + std::function< ::grpc::Status(RouteGuide::Service*, ::grpc::ServerContext*, ::grpc::ServerReader< ::examples::Point>*, ::examples::RouteSummary*)>(&RouteGuide::Service::RecordRoute), this), + new ::examples::Point, new ::examples::RouteSummary)); + service_->AddMethod(new ::grpc::RpcServiceMethod( + RouteGuide_method_names[3], + ::grpc::RpcMethod::BIDI_STREAMING, + new ::grpc::BidiStreamingHandler< RouteGuide::Service, ::examples::RouteNote, ::examples::RouteNote>( + std::function< ::grpc::Status(RouteGuide::Service*, ::grpc::ServerContext*, ::grpc::ServerReaderWriter< ::examples::RouteNote, ::examples::RouteNote>*)>(&RouteGuide::Service::RouteChat), this), + new ::examples::RouteNote, new ::examples::RouteNote)); + return service_; +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace examples + +// @@protoc_insertion_point(global_scope) diff --git a/cpp/route_guide/route_guide.pb.h b/cpp/route_guide/route_guide.pb.h new file mode 100644 index 0000000..7689003 --- /dev/null +++ b/cpp/route_guide/route_guide.pb.h @@ -0,0 +1,929 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +#ifndef PROTOBUF_route_5fguide_2eproto__INCLUDED +#define PROTOBUF_route_5fguide_2eproto__INCLUDED + +#include + +#include + +#if GOOGLE_PROTOBUF_VERSION < 3000000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpc { +class CompletionQueue; +class ChannelInterface; +class RpcService; +class ServerContext; +template class ClientAsyncResponseReader; +template class ServerAsyncResponseWriter; +template class ClientWriter; +template class ServerReader; +template class ClientAsyncWriter; +template class ServerAsyncReader; +template class ClientReader; +template class ServerWriter; +template class ClientAsyncReader; +template class ServerAsyncWriter; +template +class ClientReaderWriter; +template +class ServerReaderWriter; +template +class ClientAsyncReaderWriter; +template +class ServerAsyncReaderWriter; +} // namespace grpc +// @@protoc_insertion_point(includes) + +namespace examples { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_route_5fguide_2eproto(); +void protobuf_AssignDesc_route_5fguide_2eproto(); +void protobuf_ShutdownFile_route_5fguide_2eproto(); + +class Point; +class Rectangle; +class Feature; +class RouteNote; +class RouteSummary; + +// =================================================================== + +class Point : public ::google::protobuf::Message { + public: + Point(); + virtual ~Point(); + + Point(const Point& from); + + inline Point& operator=(const Point& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Point& default_instance(); + + void Swap(Point* other); + + // implements Message ---------------------------------------------- + + inline Point* New() const { return New(NULL); } + + Point* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Point& from); + void MergeFrom(const Point& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Point* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 latitude = 1; + inline void clear_latitude(); + static const int kLatitudeFieldNumber = 1; + inline ::google::protobuf::int32 latitude() const; + inline void set_latitude(::google::protobuf::int32 value); + + // optional int32 longitude = 2; + inline void clear_longitude(); + static const int kLongitudeFieldNumber = 2; + inline ::google::protobuf::int32 longitude() const; + inline void set_longitude(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:examples.Point) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::int32 latitude_; + ::google::protobuf::int32 longitude_; + mutable int _cached_size_; + friend void protobuf_AddDesc_route_5fguide_2eproto(); + friend void protobuf_AssignDesc_route_5fguide_2eproto(); + friend void protobuf_ShutdownFile_route_5fguide_2eproto(); + + void InitAsDefaultInstance(); + static Point* default_instance_; +}; +// ------------------------------------------------------------------- + +class Rectangle : public ::google::protobuf::Message { + public: + Rectangle(); + virtual ~Rectangle(); + + Rectangle(const Rectangle& from); + + inline Rectangle& operator=(const Rectangle& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Rectangle& default_instance(); + + void Swap(Rectangle* other); + + // implements Message ---------------------------------------------- + + inline Rectangle* New() const { return New(NULL); } + + Rectangle* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Rectangle& from); + void MergeFrom(const Rectangle& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Rectangle* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional .examples.Point lo = 1; + inline bool has_lo() const; + inline void clear_lo(); + static const int kLoFieldNumber = 1; + inline const ::examples::Point& lo() const; + inline ::examples::Point* mutable_lo(); + inline ::examples::Point* release_lo(); + inline void set_allocated_lo(::examples::Point* lo); + + // optional .examples.Point hi = 2; + inline bool has_hi() const; + inline void clear_hi(); + static const int kHiFieldNumber = 2; + inline const ::examples::Point& hi() const; + inline ::examples::Point* mutable_hi(); + inline ::examples::Point* release_hi(); + inline void set_allocated_hi(::examples::Point* hi); + + // @@protoc_insertion_point(class_scope:examples.Rectangle) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::examples::Point* lo_; + ::examples::Point* hi_; + mutable int _cached_size_; + friend void protobuf_AddDesc_route_5fguide_2eproto(); + friend void protobuf_AssignDesc_route_5fguide_2eproto(); + friend void protobuf_ShutdownFile_route_5fguide_2eproto(); + + void InitAsDefaultInstance(); + static Rectangle* default_instance_; +}; +// ------------------------------------------------------------------- + +class Feature : public ::google::protobuf::Message { + public: + Feature(); + virtual ~Feature(); + + Feature(const Feature& from); + + inline Feature& operator=(const Feature& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Feature& default_instance(); + + void Swap(Feature* other); + + // implements Message ---------------------------------------------- + + inline Feature* New() const { return New(NULL); } + + Feature* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const Feature& from); + void MergeFrom(const Feature& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Feature* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string name = 1; + inline void clear_name(); + static const int kNameFieldNumber = 1; + inline const ::std::string& name() const; + inline void set_name(const ::std::string& value); + inline void set_name(const char* value); + inline void set_name(const char* value, size_t size); + inline ::std::string* mutable_name(); + inline ::std::string* release_name(); + inline void set_allocated_name(::std::string* name); + + // optional .examples.Point location = 2; + inline bool has_location() const; + inline void clear_location(); + static const int kLocationFieldNumber = 2; + inline const ::examples::Point& location() const; + inline ::examples::Point* mutable_location(); + inline ::examples::Point* release_location(); + inline void set_allocated_location(::examples::Point* location); + + // @@protoc_insertion_point(class_scope:examples.Feature) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::internal::ArenaStringPtr name_; + ::examples::Point* location_; + mutable int _cached_size_; + friend void protobuf_AddDesc_route_5fguide_2eproto(); + friend void protobuf_AssignDesc_route_5fguide_2eproto(); + friend void protobuf_ShutdownFile_route_5fguide_2eproto(); + + void InitAsDefaultInstance(); + static Feature* default_instance_; +}; +// ------------------------------------------------------------------- + +class RouteNote : public ::google::protobuf::Message { + public: + RouteNote(); + virtual ~RouteNote(); + + RouteNote(const RouteNote& from); + + inline RouteNote& operator=(const RouteNote& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const RouteNote& default_instance(); + + void Swap(RouteNote* other); + + // implements Message ---------------------------------------------- + + inline RouteNote* New() const { return New(NULL); } + + RouteNote* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const RouteNote& from); + void MergeFrom(const RouteNote& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(RouteNote* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional .examples.Point location = 1; + inline bool has_location() const; + inline void clear_location(); + static const int kLocationFieldNumber = 1; + inline const ::examples::Point& location() const; + inline ::examples::Point* mutable_location(); + inline ::examples::Point* release_location(); + inline void set_allocated_location(::examples::Point* location); + + // optional string message = 2; + inline void clear_message(); + static const int kMessageFieldNumber = 2; + inline const ::std::string& message() const; + inline void set_message(const ::std::string& value); + inline void set_message(const char* value); + inline void set_message(const char* value, size_t size); + inline ::std::string* mutable_message(); + inline ::std::string* release_message(); + inline void set_allocated_message(::std::string* message); + + // @@protoc_insertion_point(class_scope:examples.RouteNote) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::examples::Point* location_; + ::google::protobuf::internal::ArenaStringPtr message_; + mutable int _cached_size_; + friend void protobuf_AddDesc_route_5fguide_2eproto(); + friend void protobuf_AssignDesc_route_5fguide_2eproto(); + friend void protobuf_ShutdownFile_route_5fguide_2eproto(); + + void InitAsDefaultInstance(); + static RouteNote* default_instance_; +}; +// ------------------------------------------------------------------- + +class RouteSummary : public ::google::protobuf::Message { + public: + RouteSummary(); + virtual ~RouteSummary(); + + RouteSummary(const RouteSummary& from); + + inline RouteSummary& operator=(const RouteSummary& from) { + CopyFrom(from); + return *this; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const RouteSummary& default_instance(); + + void Swap(RouteSummary* other); + + // implements Message ---------------------------------------------- + + inline RouteSummary* New() const { return New(NULL); } + + RouteSummary* New(::google::protobuf::Arena* arena) const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const RouteSummary& from); + void MergeFrom(const RouteSummary& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(RouteSummary* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 point_count = 1; + inline void clear_point_count(); + static const int kPointCountFieldNumber = 1; + inline ::google::protobuf::int32 point_count() const; + inline void set_point_count(::google::protobuf::int32 value); + + // optional int32 feature_count = 2; + inline void clear_feature_count(); + static const int kFeatureCountFieldNumber = 2; + inline ::google::protobuf::int32 feature_count() const; + inline void set_feature_count(::google::protobuf::int32 value); + + // optional int32 distance = 3; + inline void clear_distance(); + static const int kDistanceFieldNumber = 3; + inline ::google::protobuf::int32 distance() const; + inline void set_distance(::google::protobuf::int32 value); + + // optional int32 elapsed_time = 4; + inline void clear_elapsed_time(); + static const int kElapsedTimeFieldNumber = 4; + inline ::google::protobuf::int32 elapsed_time() const; + inline void set_elapsed_time(::google::protobuf::int32 value); + + // @@protoc_insertion_point(class_scope:examples.RouteSummary) + private: + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + bool _is_default_instance_; + ::google::protobuf::int32 point_count_; + ::google::protobuf::int32 feature_count_; + ::google::protobuf::int32 distance_; + ::google::protobuf::int32 elapsed_time_; + mutable int _cached_size_; + friend void protobuf_AddDesc_route_5fguide_2eproto(); + friend void protobuf_AssignDesc_route_5fguide_2eproto(); + friend void protobuf_ShutdownFile_route_5fguide_2eproto(); + + void InitAsDefaultInstance(); + static RouteSummary* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +// Point + +// optional int32 latitude = 1; +inline void Point::clear_latitude() { + latitude_ = 0; +} +inline ::google::protobuf::int32 Point::latitude() const { + // @@protoc_insertion_point(field_get:examples.Point.latitude) + return latitude_; +} +inline void Point::set_latitude(::google::protobuf::int32 value) { + + latitude_ = value; + // @@protoc_insertion_point(field_set:examples.Point.latitude) +} + +// optional int32 longitude = 2; +inline void Point::clear_longitude() { + longitude_ = 0; +} +inline ::google::protobuf::int32 Point::longitude() const { + // @@protoc_insertion_point(field_get:examples.Point.longitude) + return longitude_; +} +inline void Point::set_longitude(::google::protobuf::int32 value) { + + longitude_ = value; + // @@protoc_insertion_point(field_set:examples.Point.longitude) +} + +// ------------------------------------------------------------------- + +// Rectangle + +// optional .examples.Point lo = 1; +inline bool Rectangle::has_lo() const { + return !_is_default_instance_ && lo_ != NULL; +} +inline void Rectangle::clear_lo() { + if (lo_ != NULL) delete lo_; + lo_ = NULL; +} +inline const ::examples::Point& Rectangle::lo() const { + // @@protoc_insertion_point(field_get:examples.Rectangle.lo) + return lo_ != NULL ? *lo_ : *default_instance_->lo_; +} +inline ::examples::Point* Rectangle::mutable_lo() { + + if (lo_ == NULL) { + lo_ = new ::examples::Point; + } + // @@protoc_insertion_point(field_mutable:examples.Rectangle.lo) + return lo_; +} +inline ::examples::Point* Rectangle::release_lo() { + + ::examples::Point* temp = lo_; + lo_ = NULL; + return temp; +} +inline void Rectangle::set_allocated_lo(::examples::Point* lo) { + delete lo_; + lo_ = lo; + if (lo) { + + } else { + + } + // @@protoc_insertion_point(field_set_allocated:examples.Rectangle.lo) +} + +// optional .examples.Point hi = 2; +inline bool Rectangle::has_hi() const { + return !_is_default_instance_ && hi_ != NULL; +} +inline void Rectangle::clear_hi() { + if (hi_ != NULL) delete hi_; + hi_ = NULL; +} +inline const ::examples::Point& Rectangle::hi() const { + // @@protoc_insertion_point(field_get:examples.Rectangle.hi) + return hi_ != NULL ? *hi_ : *default_instance_->hi_; +} +inline ::examples::Point* Rectangle::mutable_hi() { + + if (hi_ == NULL) { + hi_ = new ::examples::Point; + } + // @@protoc_insertion_point(field_mutable:examples.Rectangle.hi) + return hi_; +} +inline ::examples::Point* Rectangle::release_hi() { + + ::examples::Point* temp = hi_; + hi_ = NULL; + return temp; +} +inline void Rectangle::set_allocated_hi(::examples::Point* hi) { + delete hi_; + hi_ = hi; + if (hi) { + + } else { + + } + // @@protoc_insertion_point(field_set_allocated:examples.Rectangle.hi) +} + +// ------------------------------------------------------------------- + +// Feature + +// optional string name = 1; +inline void Feature::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& Feature::name() const { + // @@protoc_insertion_point(field_get:examples.Feature.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Feature::set_name(const ::std::string& value) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:examples.Feature.name) +} +inline void Feature::set_name(const char* value) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:examples.Feature.name) +} +inline void Feature::set_name(const char* value, size_t size) { + + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:examples.Feature.name) +} +inline ::std::string* Feature::mutable_name() { + + // @@protoc_insertion_point(field_mutable:examples.Feature.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* Feature::release_name() { + + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Feature::set_allocated_name(::std::string* name) { + if (name != NULL) { + + } else { + + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:examples.Feature.name) +} + +// optional .examples.Point location = 2; +inline bool Feature::has_location() const { + return !_is_default_instance_ && location_ != NULL; +} +inline void Feature::clear_location() { + if (location_ != NULL) delete location_; + location_ = NULL; +} +inline const ::examples::Point& Feature::location() const { + // @@protoc_insertion_point(field_get:examples.Feature.location) + return location_ != NULL ? *location_ : *default_instance_->location_; +} +inline ::examples::Point* Feature::mutable_location() { + + if (location_ == NULL) { + location_ = new ::examples::Point; + } + // @@protoc_insertion_point(field_mutable:examples.Feature.location) + return location_; +} +inline ::examples::Point* Feature::release_location() { + + ::examples::Point* temp = location_; + location_ = NULL; + return temp; +} +inline void Feature::set_allocated_location(::examples::Point* location) { + delete location_; + location_ = location; + if (location) { + + } else { + + } + // @@protoc_insertion_point(field_set_allocated:examples.Feature.location) +} + +// ------------------------------------------------------------------- + +// RouteNote + +// optional .examples.Point location = 1; +inline bool RouteNote::has_location() const { + return !_is_default_instance_ && location_ != NULL; +} +inline void RouteNote::clear_location() { + if (location_ != NULL) delete location_; + location_ = NULL; +} +inline const ::examples::Point& RouteNote::location() const { + // @@protoc_insertion_point(field_get:examples.RouteNote.location) + return location_ != NULL ? *location_ : *default_instance_->location_; +} +inline ::examples::Point* RouteNote::mutable_location() { + + if (location_ == NULL) { + location_ = new ::examples::Point; + } + // @@protoc_insertion_point(field_mutable:examples.RouteNote.location) + return location_; +} +inline ::examples::Point* RouteNote::release_location() { + + ::examples::Point* temp = location_; + location_ = NULL; + return temp; +} +inline void RouteNote::set_allocated_location(::examples::Point* location) { + delete location_; + location_ = location; + if (location) { + + } else { + + } + // @@protoc_insertion_point(field_set_allocated:examples.RouteNote.location) +} + +// optional string message = 2; +inline void RouteNote::clear_message() { + message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline const ::std::string& RouteNote::message() const { + // @@protoc_insertion_point(field_get:examples.RouteNote.message) + return message_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void RouteNote::set_message(const ::std::string& value) { + + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:examples.RouteNote.message) +} +inline void RouteNote::set_message(const char* value) { + + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:examples.RouteNote.message) +} +inline void RouteNote::set_message(const char* value, size_t size) { + + message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:examples.RouteNote.message) +} +inline ::std::string* RouteNote::mutable_message() { + + // @@protoc_insertion_point(field_mutable:examples.RouteNote.message) + return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* RouteNote::release_message() { + + return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void RouteNote::set_allocated_message(::std::string* message) { + if (message != NULL) { + + } else { + + } + message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message); + // @@protoc_insertion_point(field_set_allocated:examples.RouteNote.message) +} + +// ------------------------------------------------------------------- + +// RouteSummary + +// optional int32 point_count = 1; +inline void RouteSummary::clear_point_count() { + point_count_ = 0; +} +inline ::google::protobuf::int32 RouteSummary::point_count() const { + // @@protoc_insertion_point(field_get:examples.RouteSummary.point_count) + return point_count_; +} +inline void RouteSummary::set_point_count(::google::protobuf::int32 value) { + + point_count_ = value; + // @@protoc_insertion_point(field_set:examples.RouteSummary.point_count) +} + +// optional int32 feature_count = 2; +inline void RouteSummary::clear_feature_count() { + feature_count_ = 0; +} +inline ::google::protobuf::int32 RouteSummary::feature_count() const { + // @@protoc_insertion_point(field_get:examples.RouteSummary.feature_count) + return feature_count_; +} +inline void RouteSummary::set_feature_count(::google::protobuf::int32 value) { + + feature_count_ = value; + // @@protoc_insertion_point(field_set:examples.RouteSummary.feature_count) +} + +// optional int32 distance = 3; +inline void RouteSummary::clear_distance() { + distance_ = 0; +} +inline ::google::protobuf::int32 RouteSummary::distance() const { + // @@protoc_insertion_point(field_get:examples.RouteSummary.distance) + return distance_; +} +inline void RouteSummary::set_distance(::google::protobuf::int32 value) { + + distance_ = value; + // @@protoc_insertion_point(field_set:examples.RouteSummary.distance) +} + +// optional int32 elapsed_time = 4; +inline void RouteSummary::clear_elapsed_time() { + elapsed_time_ = 0; +} +inline ::google::protobuf::int32 RouteSummary::elapsed_time() const { + // @@protoc_insertion_point(field_get:examples.RouteSummary.elapsed_time) + return elapsed_time_; +} +inline void RouteSummary::set_elapsed_time(::google::protobuf::int32 value) { + + elapsed_time_ = value; + // @@protoc_insertion_point(field_set:examples.RouteSummary.elapsed_time) +} + + +class RouteGuide final { + public: + class Stub final : public ::grpc::InternalStub { + public: + ::grpc::Status GetFeature(::grpc::ClientContext* context, const ::examples::Point& request, ::examples::Feature* response); + ::grpc::ClientAsyncResponseReader< ::examples::Feature>* GetFeature(::grpc::ClientContext* context, const ::examples::Point& request, ::grpc::CompletionQueue* cq, void* tag); + ::grpc::ClientReader< ::examples::Feature>* ListFeatures(::grpc::ClientContext* context, const ::examples::Rectangle& request); + ::grpc::ClientAsyncReader< ::examples::Feature>* ListFeatures(::grpc::ClientContext* context, const ::examples::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag); + ::grpc::ClientWriter< ::examples::Point>* RecordRoute(::grpc::ClientContext* context, ::examples::RouteSummary* response); + ::grpc::ClientAsyncWriter< ::examples::Point>* RecordRoute(::grpc::ClientContext* context, ::examples::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag); + ::grpc::ClientReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* RouteChat(::grpc::ClientContext* context); + ::grpc::ClientAsyncReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* RouteChat(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag); + }; + static Stub* NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); + + class Service : public ::grpc::SynchronousService { + public: + Service() : service_(nullptr) {} + virtual ~Service(); + virtual ::grpc::Status GetFeature(::grpc::ServerContext* context, const ::examples::Point* request, ::examples::Feature* response); + virtual ::grpc::Status ListFeatures(::grpc::ServerContext* context, const ::examples::Rectangle* request, ::grpc::ServerWriter< ::examples::Feature>* writer); + virtual ::grpc::Status RecordRoute(::grpc::ServerContext* context, ::grpc::ServerReader< ::examples::Point>* reader, ::examples::RouteSummary* response); + virtual ::grpc::Status RouteChat(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* stream); + ::grpc::RpcService* service() override final; + private: + ::grpc::RpcService* service_; + }; + class AsyncService final : public ::grpc::AsynchronousService { + public: + explicit AsyncService(::grpc::CompletionQueue* cq); + ~AsyncService() {}; + void RequestGetFeature(::grpc::ServerContext* context, ::examples::Point* request, ::grpc::ServerAsyncResponseWriter< ::examples::Feature>* response, ::grpc::CompletionQueue* cq, void *tag); + void RequestListFeatures(::grpc::ServerContext* context, ::examples::Rectangle* request, ::grpc::ServerAsyncWriter< ::examples::Feature>* writer, ::grpc::CompletionQueue* cq, void *tag); + void RequestRecordRoute(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::examples::RouteSummary, ::examples::Point>* reader, ::grpc::CompletionQueue* cq, void *tag); + void RequestRouteChat(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* stream, ::grpc::CompletionQueue* cq, void *tag); + }; +}; + +// @@protoc_insertion_point(namespace_scope) + +} // namespace examples + +#ifndef SWIG +namespace google { +namespace protobuf { + + +} // namespace protobuf +} // namespace google +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_route_5fguide_2eproto__INCLUDED diff --git a/cpp/route_guide/route_guide_client.cc b/cpp/route_guide/route_guide_client.cc new file mode 100644 index 0000000..4a51f5e --- /dev/null +++ b/cpp/route_guide/route_guide_client.cc @@ -0,0 +1,91 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * 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. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include "helloworld.pb.h" + +using grpc::ChannelArguments; +using grpc::ChannelInterface; +using grpc::ClientContext; +using grpc::Status; +using helloworld::HelloRequest; +using helloworld::HelloReply; +using helloworld::Greeter; + +class GreeterClient { + public: + GreeterClient(std::shared_ptr channel) + : stub_(Greeter::NewStub(channel)) {} + + std::string SayHello(const std::string& user) { + HelloRequest request; + request.set_name(user); + HelloReply reply; + ClientContext context; + + Status status = stub_->sayHello(&context, request, &reply); + if (status.IsOk()) { + return reply.message(); + } else { + return "Rpc failed"; + } + } + + void Shutdown() { stub_.reset(); } + + private: + std::unique_ptr stub_; +}; + +int main(int argc, char** argv) { + grpc_init(); + + GreeterClient greeter( + grpc::CreateChannel("localhost:50051", ChannelArguments())); + std::string user("world"); + std::string reply = greeter.SayHello(user); + std::cout << "Greeter received: " << reply << std::endl; + + greeter.Shutdown(); + + grpc_shutdown(); +} diff --git a/cpp/route_guide/route_guide_server.cc b/cpp/route_guide/route_guide_server.cc new file mode 100644 index 0000000..3a2ab60 --- /dev/null +++ b/cpp/route_guide/route_guide_server.cc @@ -0,0 +1,84 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * 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. + * + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "helloworld.pb.h" + +using grpc::Server; +using grpc::ServerBuilder; +using grpc::ServerContext; +using grpc::Status; +using helloworld::HelloRequest; +using helloworld::HelloReply; +using helloworld::Greeter; + +class GreeterServiceImpl final : public Greeter::Service { + Status sayHello(ServerContext* context, const HelloRequest* request, + HelloReply* reply) override { + std::string prefix("Hello "); + reply->set_message(prefix + request->name()); + return Status::OK; + } +}; + +void RunServer() { + std::string server_address("0.0.0.0:50051"); + GreeterServiceImpl service; + + ServerBuilder builder; + builder.AddPort(server_address); + builder.RegisterService(&service); + std::unique_ptr server(builder.BuildAndStart()); + std::cout << "Server listening on " << server_address << std::endl; + while (true) { + std::this_thread::sleep_for(std::chrono::seconds(5)); + } +} + +int main(int argc, char** argv) { + grpc_init(); + + RunServer(); + + grpc_shutdown(); + return 0; +}