In C++ you use the mutable_ accessor to set the value.  So for example, you
could do:
  my_message.mutable_auth_resp_msg()->set_foo(1);

On Tue, Jul 6, 2010 at 3:01 PM, Maxim Leonovich <lm.b...@gmail.com> wrote:

> I have a protocol like that:
>
> message MSG {
>        enum MessageType {
>                //One enum value is needed for each message type
>                AUTHORIZATION_REQUEST = 1;
>                AUTHORIZATION_RESPONCE = 2;
>        }
>        required MessageType type = 1;
>        required int32 proto_version = 2 [default = 1];
>
>        //One value for each message
>        optional AuthorizationRequest auth_req_msg = 3;
>        optional AuthorizationResponce auth_resp_msg = 4;
> }
>
>        message AuthorizationRequest {
>        required string login = 1;
>        required string password = 2;
> }
>
> message AuthorizationResponce {
>        enum Result {
>                ACCEPTED = 1;
>                INVALID_LOGIN_PASS = 2;
>                ACCOUNT_SUSPENDED = 3;
>                REJECTED = 4;
>        }
>        required Result result = 1;
>        optional string message = 2;
> }
>
>
> But in generated C++ class I have setters only for "type" and
> "proto_version". For auth_msg_req and auth_msg_resp I have only
>
> // optional .proto.AuthorizationResponce auth_resp_msg = 4;
>  inline bool has_auth_resp_msg() const;
>  inline void clear_auth_resp_msg();
>  static const int kAuthRespMsgFieldNumber = 4;
>  inline const ::proto::AuthorizationResponce& auth_resp_msg() const;
>  inline ::proto::AuthorizationResponce* mutable_auth_resp_msg();
>
> But there is no setter here.
> OK. How can I set a value for auth_resp and auth_req?
> P.S. I have this problem only in C++. In Java all setters exists.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to