From c2043821269b696215421f164f3d2309fffae8ff Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 22 Feb 2015 20:18:51 +0100 Subject: [PATCH] Working project --- Client/Client.cpp | 2 + Client/Client.vcxproj | 25 +++ Client/Client.vcxproj.filters | 16 ++ Client/proto/client.pb.cc | 344 ++++++++++++++++++++++++++++++++++ Client/proto/client.pb.h | 221 ++++++++++++++++++++++ Client/proto/client.proto | 7 + ProtoBufTest.sln | 8 + protobuf | 2 +- 8 files changed, 624 insertions(+), 1 deletion(-) create mode 100644 Client/proto/client.pb.cc create mode 100644 Client/proto/client.pb.h create mode 100644 Client/proto/client.proto diff --git a/Client/Client.cpp b/Client/Client.cpp index ca905f7..a050ae5 100644 --- a/Client/Client.cpp +++ b/Client/Client.cpp @@ -1,5 +1,7 @@ #include +#include "proto/client.pb.h" + int main(int argc, char **argv) { std::cout << "Client running" << std::endl; diff --git a/Client/Client.vcxproj b/Client/Client.vcxproj index f0b4656..c5f20fc 100644 --- a/Client/Client.vcxproj +++ b/Client/Client.vcxproj @@ -52,10 +52,14 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + ..\protobuf\src\ + false Console true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);libprotobuf.lib + $(OutDir) @@ -67,16 +71,37 @@ true true WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + ..\protobuf\src\ + false Console true true true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);libprotobuf.lib + $(OutDir) + + + + + false + Document + false + $(OutDir)\protoc.exe -I=%(RelativeDir) --cpp_out=$(ProjectDir)\proto %(Identity) + proto\client.pb.h;proto\client.pb.cc;%(Outputs) + false + $(OutDir)\protoc.exe -I=%(RelativeDir) --cpp_out=$(ProjectDir)\proto %(Identity) + proto\client.pb.h;proto\client.pb.cc;%(Outputs) + false + + + + diff --git a/Client/Client.vcxproj.filters b/Client/Client.vcxproj.filters index 10a1c2e..59bdb66 100644 --- a/Client/Client.vcxproj.filters +++ b/Client/Client.vcxproj.filters @@ -13,10 +13,26 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {d00f39be-e659-481d-b36a-0ad0301014f8} + Source Files + + proto + + + + + proto + + + + + proto + \ No newline at end of file diff --git a/Client/proto/client.pb.cc b/Client/proto/client.pb.cc new file mode 100644 index 0000000..7dbd854 --- /dev/null +++ b/Client/proto/client.pb.cc @@ -0,0 +1,344 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: client.proto + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "client.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace client { + +namespace { + +const ::google::protobuf::Descriptor* ClientInfo_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + ClientInfo_reflection_ = NULL; + +} // namespace + + +void protobuf_AssignDesc_client_2eproto() { + protobuf_AddDesc_client_2eproto(); + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( + "client.proto"); + GOOGLE_CHECK(file != NULL); + ClientInfo_descriptor_ = file->message_type(0); + static const int ClientInfo_offsets_[1] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ClientInfo, name_), + }; + ClientInfo_reflection_ = + new ::google::protobuf::internal::GeneratedMessageReflection( + ClientInfo_descriptor_, + ClientInfo::default_instance_, + ClientInfo_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ClientInfo, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ClientInfo, _unknown_fields_), + -1, + ::google::protobuf::DescriptorPool::generated_pool(), + ::google::protobuf::MessageFactory::generated_factory(), + sizeof(ClientInfo)); +} + +namespace { + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +inline void protobuf_AssignDescriptorsOnce() { + ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, + &protobuf_AssignDesc_client_2eproto); +} + +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + ClientInfo_descriptor_, &ClientInfo::default_instance()); +} + +} // namespace + +void protobuf_ShutdownFile_client_2eproto() { + delete ClientInfo::default_instance_; + delete ClientInfo_reflection_; +} + +void protobuf_AddDesc_client_2eproto() { + static bool already_here = false; + if (already_here) return; + already_here = true; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + "\n\014client.proto\022\006client\"\034\n\nClientInfo\022\016\n\004" + "name\030\001 \001(\t:\000", 52); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "client.proto", &protobuf_RegisterTypes); + ClientInfo::default_instance_ = new ClientInfo(); + ClientInfo::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_client_2eproto); +} + +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer_client_2eproto { + StaticDescriptorInitializer_client_2eproto() { + protobuf_AddDesc_client_2eproto(); + } +} static_descriptor_initializer_client_2eproto_; + +// =================================================================== + +#ifndef _MSC_VER +const int ClientInfo::kNameFieldNumber; +#endif // !_MSC_VER + +ClientInfo::ClientInfo() + : ::google::protobuf::Message() { + SharedCtor(); + // @@protoc_insertion_point(constructor:client.ClientInfo) +} + +void ClientInfo::InitAsDefaultInstance() { +} + +ClientInfo::ClientInfo(const ClientInfo& from) + : ::google::protobuf::Message() { + SharedCtor(); + MergeFrom(from); + // @@protoc_insertion_point(copy_constructor:client.ClientInfo) +} + +void ClientInfo::SharedCtor() { + ::google::protobuf::internal::GetEmptyString(); + _cached_size_ = 0; + name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +ClientInfo::~ClientInfo() { + // @@protoc_insertion_point(destructor:client.ClientInfo) + SharedDtor(); +} + +void ClientInfo::SharedDtor() { + if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + delete name_; + } + if (this != default_instance_) { + } +} + +void ClientInfo::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* ClientInfo::descriptor() { + protobuf_AssignDescriptorsOnce(); + return ClientInfo_descriptor_; +} + +const ClientInfo& ClientInfo::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_client_2eproto(); + return *default_instance_; +} + +ClientInfo* ClientInfo::default_instance_ = NULL; + +ClientInfo* ClientInfo::New() const { + return new ClientInfo; +} + +void ClientInfo::Clear() { + if (has_name()) { + if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + name_->clear(); + } + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + mutable_unknown_fields()->Clear(); +} + +bool ClientInfo::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:client.ClientInfo) + 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 [default = ""]; + 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, + "name"); + } 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::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:client.ClientInfo) + return true; +failure: + // @@protoc_insertion_point(parse_failure:client.ClientInfo) + return false; +#undef DO_ +} + +void ClientInfo::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:client.ClientInfo) + // optional string name = 1 [default = ""]; + if (has_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->name(), output); + } + + if (!unknown_fields().empty()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:client.ClientInfo) +} + +::google::protobuf::uint8* ClientInfo::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // @@protoc_insertion_point(serialize_to_array_start:client.ClientInfo) + // optional string name = 1 [default = ""]; + if (has_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->name(), target); + } + + if (!unknown_fields().empty()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:client.ClientInfo) + return target; +} + +int ClientInfo::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // optional string name = 1 [default = ""]; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + } + if (!unknown_fields().empty()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ClientInfo::MergeFrom(const ::google::protobuf::Message& from) { + GOOGLE_CHECK_NE(&from, this); + const ClientInfo* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void ClientInfo::MergeFrom(const ClientInfo& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_name()) { + set_name(from.name()); + } + } + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +} + +void ClientInfo::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ClientInfo::CopyFrom(const ClientInfo& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ClientInfo::IsInitialized() const { + + return true; +} + +void ClientInfo::Swap(ClientInfo* other) { + if (other != this) { + std::swap(name_, other->name_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _unknown_fields_.Swap(&other->_unknown_fields_); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::google::protobuf::Metadata ClientInfo::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ClientInfo_descriptor_; + metadata.reflection = ClientInfo_reflection_; + return metadata; +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace client + +// @@protoc_insertion_point(global_scope) diff --git a/Client/proto/client.pb.h b/Client/proto/client.pb.h new file mode 100644 index 0000000..fb723dc --- /dev/null +++ b/Client/proto/client.pb.h @@ -0,0 +1,221 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: client.proto + +#ifndef PROTOBUF_client_2eproto__INCLUDED +#define PROTOBUF_client_2eproto__INCLUDED + +#include + +#include + +#if GOOGLE_PROTOBUF_VERSION < 2006000 +#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 2006001 < 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 +// @@protoc_insertion_point(includes) + +namespace client { + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_client_2eproto(); +void protobuf_AssignDesc_client_2eproto(); +void protobuf_ShutdownFile_client_2eproto(); + +class ClientInfo; + +// =================================================================== + +class ClientInfo : public ::google::protobuf::Message { + public: + ClientInfo(); + virtual ~ClientInfo(); + + ClientInfo(const ClientInfo& from); + + inline ClientInfo& operator=(const ClientInfo& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const ClientInfo& default_instance(); + + void Swap(ClientInfo* other); + + // implements Message ---------------------------------------------- + + ClientInfo* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const ClientInfo& from); + void MergeFrom(const ClientInfo& 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; + public: + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional string name = 1 [default = ""]; + inline bool has_name() const; + 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); + + // @@protoc_insertion_point(class_scope:client.ClientInfo) + private: + inline void set_has_name(); + inline void clear_has_name(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::uint32 _has_bits_[1]; + mutable int _cached_size_; + ::std::string* name_; + friend void protobuf_AddDesc_client_2eproto(); + friend void protobuf_AssignDesc_client_2eproto(); + friend void protobuf_ShutdownFile_client_2eproto(); + + void InitAsDefaultInstance(); + static ClientInfo* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +// ClientInfo + +// optional string name = 1 [default = ""]; +inline bool ClientInfo::has_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void ClientInfo::set_has_name() { + _has_bits_[0] |= 0x00000001u; +} +inline void ClientInfo::clear_has_name() { + _has_bits_[0] &= ~0x00000001u; +} +inline void ClientInfo::clear_name() { + if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + name_->clear(); + } + clear_has_name(); +} +inline const ::std::string& ClientInfo::name() const { + // @@protoc_insertion_point(field_get:client.ClientInfo.name) + return *name_; +} +inline void ClientInfo::set_name(const ::std::string& value) { + set_has_name(); + if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + name_ = new ::std::string; + } + name_->assign(value); + // @@protoc_insertion_point(field_set:client.ClientInfo.name) +} +inline void ClientInfo::set_name(const char* value) { + set_has_name(); + if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + name_ = new ::std::string; + } + name_->assign(value); + // @@protoc_insertion_point(field_set_char:client.ClientInfo.name) +} +inline void ClientInfo::set_name(const char* value, size_t size) { + set_has_name(); + if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + name_ = new ::std::string; + } + name_->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:client.ClientInfo.name) +} +inline ::std::string* ClientInfo::mutable_name() { + set_has_name(); + if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + name_ = new ::std::string; + } + // @@protoc_insertion_point(field_mutable:client.ClientInfo.name) + return name_; +} +inline ::std::string* ClientInfo::release_name() { + clear_has_name(); + if (name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + return NULL; + } else { + ::std::string* temp = name_; + name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return temp; + } +} +inline void ClientInfo::set_allocated_name(::std::string* name) { + if (name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + delete name_; + } + if (name) { + set_has_name(); + name_ = name; + } else { + clear_has_name(); + name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + // @@protoc_insertion_point(field_set_allocated:client.ClientInfo.name) +} + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace client + +#ifndef SWIG +namespace google { +namespace protobuf { + + +} // namespace google +} // namespace protobuf +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_client_2eproto__INCLUDED diff --git a/Client/proto/client.proto b/Client/proto/client.proto new file mode 100644 index 0000000..db7e6d4 --- /dev/null +++ b/Client/proto/client.proto @@ -0,0 +1,7 @@ +package client; + +message ClientInfo +{ + optional string name = 1 [default = ""]; +} + diff --git a/ProtoBufTest.sln b/ProtoBufTest.sln index fe223de..2637127 100644 --- a/ProtoBufTest.sln +++ b/ProtoBufTest.sln @@ -4,8 +4,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Server", "Server\Server.vcxproj", "{DD8094A4-9A06-48C2-8089-8F9CD17DB56A}" + ProjectSection(ProjectDependencies) = postProject + {3E283F37-A4ED-41B7-A3E6-A2D89D131A30} = {3E283F37-A4ED-41B7-A3E6-A2D89D131A30} + {1738D5F6-ED1E-47E0-B2F0-456864B93C1E} = {1738D5F6-ED1E-47E0-B2F0-456864B93C1E} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Client", "Client\Client.vcxproj", "{010C073D-B9CB-4FF6-8CA5-5029D6A6A2C7}" + ProjectSection(ProjectDependencies) = postProject + {3E283F37-A4ED-41B7-A3E6-A2D89D131A30} = {3E283F37-A4ED-41B7-A3E6-A2D89D131A30} + {1738D5F6-ED1E-47E0-B2F0-456864B93C1E} = {1738D5F6-ED1E-47E0-B2F0-456864B93C1E} + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "protobuf", "protobuf", "{79C6CA55-40CE-4F5F-A29E-F06C0158D617}" EndProject diff --git a/protobuf b/protobuf index ba4dea9..22ad388 160000 --- a/protobuf +++ b/protobuf @@ -1 +1 @@ -Subproject commit ba4dea9fe8ad9e81ca605e3d91feb1823b943337 +Subproject commit 22ad3884705524b510fa1e01e513390472aca2b9