[protobuf] protoc not generated add_...() method for repeated nested messages

2014-06-11 Thread CB

I've got a proto file that looks like this:

option optimize_for = SPEED;

package test;

message KeyedStrings
{
optional string key = 1;
repeated string value = 2;
}

message Map
{
repeated KeyedStrings map = 1;
repeated string test = 2;
}

My problem is that the generated C++ code does not include any methods that 
allow me to add or set the map values. The test field is fine as you can 
see the required methods in the attached files. What am I doing wrong?

FYI - using protoc version 2.5.0

Thanks.


-- 
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/d/optout.
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: Map.proto

#ifndef PROTOBUF_Map_2eproto__INCLUDED
#define PROTOBUF_Map_2eproto__INCLUDED

#include string

#include google/protobuf/stubs/common.h

#if GOOGLE_PROTOBUF_VERSION  2005000
#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 2005000  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 google/protobuf/generated_message_util.h
#include google/protobuf/message.h
#include google/protobuf/repeated_field.h
#include google/protobuf/extension_set.h
#include google/protobuf/unknown_field_set.h
// @@protoc_insertion_point(includes)

namespace test {

// Internal implementation detail -- do not call these.
void  protobuf_AddDesc_Map_2eproto();
void protobuf_AssignDesc_Map_2eproto();
void protobuf_ShutdownFile_Map_2eproto();

class KeyedStrings;
class Map;

// ===

class KeyedStrings : public ::google::protobuf::Message {
 public:
  KeyedStrings();
  virtual ~KeyedStrings();

  KeyedStrings(const KeyedStrings from);

  inline KeyedStrings operator=(const KeyedStrings 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 KeyedStrings default_instance();

  void Swap(KeyedStrings* other);

  // implements Message --

  KeyedStrings* New() const;
  void CopyFrom(const ::google::protobuf::Message from);
  void MergeFrom(const ::google::protobuf::Message from);
  void CopyFrom(const KeyedStrings from);
  void MergeFrom(const KeyedStrings 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 key = 1;
  inline bool has_key() const;
  inline void clear_key();
  static const int kKeyFieldNumber = 1;
  inline const ::std::string key() const;
  inline void set_key(const ::std::string value);
  inline void set_key(const char* value);
  inline void set_key(const char* value, size_t size);
  inline ::std::string* mutable_key();
  inline ::std::string* release_key();
  inline void set_allocated_key(::std::string* key);

  // repeated string value = 2;
  inline int value_size() const;
  inline void clear_value();
  static const int kValueFieldNumber = 2;
  inline const ::std::string value(int index) const;
  inline ::std::string* mutable_value(int index);
  inline void set_value(int index, const ::std::string value);
  inline void set_value(int index, const char* value);
  inline void set_value(int index, const char* value, size_t size);
  inline ::std::string* add_value();
  inline void add_value(const ::std::string value);
  inline void add_value(const char* value);
  inline void add_value(const char* value, size_t size);
  inline const ::google::protobuf::RepeatedPtrField ::std::string value() const;
  inline ::google::protobuf::RepeatedPtrField 

Re: [protobuf] protoc not generated add_...() method for repeated nested messages

2014-06-11 Thread Ilia Mirkin
On Wed, Jun 11, 2014 at 6:54 PM, CB cbrund...@gmail.com wrote:

 I've got a proto file that looks like this:

 option optimize_for = SPEED;

 package test;

 message KeyedStrings
 {
 optional string key = 1;
 repeated string value = 2;
 }

 message Map
 {
 repeated KeyedStrings map = 1;
 repeated string test = 2;
 }

 My problem is that the generated C++ code does not include any methods that
 allow me to add or set the map values. The test field is fine as you can see
 the required methods in the attached files. What am I doing wrong?

What method are you expecting to see but isn't there? add_map() seems
to be there...

  -ilia

-- 
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/d/optout.


Re: [protobuf] protoc not generated add_...() method for repeated nested messages

2014-06-11 Thread CB


On Wednesday, June 11, 2014 7:01:42 PM UTC-4, Ilia Mirkin wrote:

 On Wed, Jun 11, 2014 at 6:54 PM, CB cbru...@gmail.com javascript: 
 wrote: 
  
  I've got a proto file that looks like this: 
  
  option optimize_for = SPEED; 
  
  package test; 
  
  message KeyedStrings 
  { 
  optional string key = 1; 
  repeated string value = 2; 
  } 
  
  message Map 
  { 
  repeated KeyedStrings map = 1; 
  repeated string test = 2; 
  } 
  
  My problem is that the generated C++ code does not include any methods 
 that 
  allow me to add or set the map values. The test field is fine as you can 
 see 
  the required methods in the attached files. What am I doing wrong? 

 What method are you expecting to see but isn't there? add_map() seems 
 to be there... 

   -ilia 


Yes, but it takes no arguments. There are add_test() methods that take the 
string to add, for example. I expected an add_map() method that took the 
KeyedStrings object to add. 

-- 
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/d/optout.


Re: [protobuf] protoc not generated add_...() method for repeated nested messages

2014-06-11 Thread Ilia Mirkin
On Wed, Jun 11, 2014 at 7:04 PM, CB cbrund...@gmail.com wrote:


 On Wednesday, June 11, 2014 7:01:42 PM UTC-4, Ilia Mirkin wrote:

 On Wed, Jun 11, 2014 at 6:54 PM, CB cbru...@gmail.com wrote:
 
  I've got a proto file that looks like this:
 
  option optimize_for = SPEED;
 
  package test;
 
  message KeyedStrings
  {
  optional string key = 1;
  repeated string value = 2;
  }
 
  message Map
  {
  repeated KeyedStrings map = 1;
  repeated string test = 2;
  }
 
  My problem is that the generated C++ code does not include any methods
  that
  allow me to add or set the map values. The test field is fine as you can
  see
  the required methods in the attached files. What am I doing wrong?

 What method are you expecting to see but isn't there? add_map() seems
 to be there...

   -ilia


 Yes, but it takes no arguments. There are add_test() methods that take the
 string to add, for example. I expected an add_map() method that took the
 KeyedStrings object to add.

That's not how it works. It returns a KeyedStrings object for you to
modify. Take a look at

https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#fields

Specifically the Repeated Embedded Message Fields section.

  -ilia

-- 
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/d/optout.


Re: [protobuf] protoc not generated add_...() method for repeated nested messages

2014-06-11 Thread CB


On Wednesday, June 11, 2014 7:07:51 PM UTC-4, Ilia Mirkin wrote:

 On Wed, Jun 11, 2014 at 7:04 PM, CB cbru...@gmail.com javascript: 
 wrote: 
  
  
  On Wednesday, June 11, 2014 7:01:42 PM UTC-4, Ilia Mirkin wrote: 
  
  On Wed, Jun 11, 2014 at 6:54 PM, CB cbru...@gmail.com wrote: 
   
   I've got a proto file that looks like this: 
   
   option optimize_for = SPEED; 
   
   package test; 
   
   message KeyedStrings 
   { 
   optional string key = 1; 
   repeated string value = 2; 
   } 
   
   message Map 
   { 
   repeated KeyedStrings map = 1; 
   repeated string test = 2; 
   } 
   
   My problem is that the generated C++ code does not include any 
 methods 
   that 
   allow me to add or set the map values. The test field is fine as you 
 can 
   see 
   the required methods in the attached files. What am I doing wrong? 
  
  What method are you expecting to see but isn't there? add_map() seems 
  to be there... 
  
-ilia 
  
  
  Yes, but it takes no arguments. There are add_test() methods that take 
 the 
  string to add, for example. I expected an add_map() method that took the 
  KeyedStrings object to add. 

 That's not how it works. It returns a KeyedStrings object for you to 
 modify. Take a look at 


 https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#fields
  

 Specifically the Repeated Embedded Message Fields section. 

   -ilia 


Ah! You're a genius. Thank you.
 

-- 
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/d/optout.