How should I add methods a Protobuf message?
Suppose I have in my .proto file:
package proto;
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
}
and I want to add a method, say, string concatenateNameEmail()
to the message.
What I do right now is I create my own C++ class like this:
class Person : public proto::Person
{
public:
Person( proto::Person const & person_ )
: proto::Person(person_)
{}
string concateNateNameEmail()
{
...
}
};
So the downside is I need to call proto::Person copy constructor. Is there a more elegant solution than this?