[protobuf] Service passing

2020-05-26 Thread Rony Kositsky
Hi,

Suppose I have a class and it's base class. I'm writing the protobuf 
protocol to use their methods.

class Base{
}


class Foo:Base{
}


They share some functionality, is there a way to avoid rewriting code by 
passing the service?
For example:

service BaseProto{
   rpc SomeFunction()
}

service FooProto{
   **Passing the service here instead of rewriting SomeFunction()
}


-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/da15a37b-a0b7-4125-94ec-b7e831658459%40googlegroups.com.


[protobuf] C++ generated code support MessageOptions?

2020-05-26 Thread 김진욱
version: protocolbuffer 3.12.1
in proto:

syntax = "proto3";
import "google/protobuf/descriptor.proto";
package proto;

extend google.protobuf.MessageOptions {
  int32 message_id = 59153;
}

message TestMessageId {
option (message_id) = 106;
}


in C#(working)
if (Proto.TestMessageId.Descriptor.CustomOptions.TryGetInt32(59153, out int 
messageId))
{
Console.WriteLine("value:{0}", messageId);
}

in C++(not working):
auto message_id = 
proto::TestMessageId::descriptor()->options().GetExtension(proto::message_id);
std::cout << message_id << std::endl;


I expect message_id is 106. C# code is working but C++ code always return 
0. Is my way is wrong? How can I get message option value in C++?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/74f49fe5-e625-485e-8f14-83809866b110%40googlegroups.com.


Re: [protobuf] Parse sub message from binary encoding

2020-05-26 Thread 'Adam Cozzette' via Protocol Buffers
Why not just parse the entire parent message? But if you really want to
avoid that for some reason, probably the easiest approach is to parse the
binary as an EmptyMessage, then look through the unknown fields for your
submessage field and parse the submessage from there.

On Mon, May 25, 2020 at 2:28 AM R P  wrote:

> Hello
>
> I want to parse a sub message from a binary super message.
>
> I have found some useful information about message encoding here:
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> From the link:
>
> message Test1 { optional int32 a = 1; }
> message Test3 { optional Test1 c = 3; }
>
> Let's say i have a binary representation of a Test3 message with the sub
> message field 'a' is set to 150:
> 1a 03 08 96 01
>
> Is there a method to parse Test1 message from this binary encoding?
>
> BR
> Rainer
>
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/24115597-43bf-4262-86e4-a861ccd13e21%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr4gqHDMO4P8n4kOLROM5Huonqy8zvRMZyBfpMnr_OOx0Q%40mail.gmail.com.