OK, well you can really excuse me now, as I think I figured this out.
Looks like I use the mutable_create_request method to access the
create_request message, then I can use the accessors from that class to
set the fields. I was expecting to create my own class, then somehow
add that class to the union, and it doesn't look like that is what you do...
Howard
On 10/8/13 1:58 PM, Howard Lander wrote:
Hi all
Please excuse this question from a newcomer; any assistance is greatly
appreciated.
I have the following 2 .proto files that I want to use to generate c++
code:
create.proto:
package proto;
message CreateRequest {
required string resource_type = 1;
required string request_type = 2;
}
message CreateResponse {
required string file_url = 1;
required int32 return_code = 2;
required int32 thread_id = 3;
}
RequestReply.proto
package proto;
import "create.proto";
message RequestUnion {
enum message_type {CreateRequestMessage = 1; }
required message_type type = 1;
optional CreateRequest create_request= 2;
}
message ResponseUnion {
enum message_type {CreateResponseMessage = 1; }
required message_type type = 1;
optional CreateResponse create_response = 2;
}
When I run protoc using protoc -I=. --cpp_out=.everything is fine and
the correct .cc and .h files are produced. The problem is that I can't
seem to find a way to set the value of the create_request field in the
RequestUnion message. The generated classes for the CreateRequest and
CreateReply messages have set methods for each of the fields and the
generated class for the RequestUnion message has a set_type method but
I can't figure out how I set the value of the optional create_request
field. I'm assuming I've either done something dumb, or I have a
fundamental misunderstanding of the situation (or maybe both)! Any
suggestions?
For reference, I've attached RequestReply.pb.h
Howard
--
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 post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.
--
Howard Lander <mailto:how...@renci.org>
Senior Research Software Developer
Renaissance Computing Institute (RENCI) <http://www.renci.org>
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651
--
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 post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.