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< ::std::string>* mutable_value();

  // @@protoc_insertion_point(class_scope:test.KeyedStrings)
 private:
  inline void set_has_key();
  inline void clear_has_key();

  ::google::protobuf::UnknownFieldSet _unknown_fields_;

  ::std::string* key_;
  ::google::protobuf::RepeatedPtrField< ::std::string> value_;

  mutable int _cached_size_;
  ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];

  friend void  protobuf_AddDesc_Map_2eproto();
  friend void protobuf_AssignDesc_Map_2eproto();
  friend void protobuf_ShutdownFile_Map_2eproto();

  void InitAsDefaultInstance();
  static KeyedStrings* default_instance_;
};
// -------------------------------------------------------------------

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

  Map(const Map& from);

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

  void Swap(Map* other);

  // implements Message ----------------------------------------------

  Map* New() const;
  void CopyFrom(const ::google::protobuf::Message& from);
  void MergeFrom(const ::google::protobuf::Message& from);
  void CopyFrom(const Map& from);
  void MergeFrom(const Map& 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 -------------------------------------------------------

  // repeated .test.KeyedStrings map = 1;
  inline int map_size() const;
  inline void clear_map();
  static const int kMapFieldNumber = 1;
  inline const ::test::KeyedStrings& map(int index) const;
  inline ::test::KeyedStrings* mutable_map(int index);
  inline ::test::KeyedStrings* add_map();
  inline const ::google::protobuf::RepeatedPtrField< ::test::KeyedStrings >&
      map() const;
  inline ::google::protobuf::RepeatedPtrField< ::test::KeyedStrings >*
      mutable_map();

  // repeated string test = 2;
  inline int test_size() const;
  inline void clear_test();
  static const int kTestFieldNumber = 2;
  inline const ::std::string& test(int index) const;
  inline ::std::string* mutable_test(int index);
  inline void set_test(int index, const ::std::string& value);
  inline void set_test(int index, const char* value);
  inline void set_test(int index, const char* value, size_t size);
  inline ::std::string* add_test();
  inline void add_test(const ::std::string& value);
  inline void add_test(const char* value);
  inline void add_test(const char* value, size_t size);
  inline const ::google::protobuf::RepeatedPtrField< ::std::string>& test() const;
  inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_test();

  // @@protoc_insertion_point(class_scope:test.Map)
 private:

  ::google::protobuf::UnknownFieldSet _unknown_fields_;

  ::google::protobuf::RepeatedPtrField< ::test::KeyedStrings > map_;
  ::google::protobuf::RepeatedPtrField< ::std::string> test_;

  mutable int _cached_size_;
  ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];

  friend void  protobuf_AddDesc_Map_2eproto();
  friend void protobuf_AssignDesc_Map_2eproto();
  friend void protobuf_ShutdownFile_Map_2eproto();

  void InitAsDefaultInstance();
  static Map* default_instance_;
};
// ===================================================================


// ===================================================================

// KeyedStrings

// optional string key = 1;
inline bool KeyedStrings::has_key() const {
  return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void KeyedStrings::set_has_key() {
  _has_bits_[0] |= 0x00000001u;
}
inline void KeyedStrings::clear_has_key() {
  _has_bits_[0] &= ~0x00000001u;
}
inline void KeyedStrings::clear_key() {
  if (key_ != &::google::protobuf::internal::kEmptyString) {
    key_->clear();
  }
  clear_has_key();
}
inline const ::std::string& KeyedStrings::key() const {
  return *key_;
}
inline void KeyedStrings::set_key(const ::std::string& value) {
  set_has_key();
  if (key_ == &::google::protobuf::internal::kEmptyString) {
    key_ = new ::std::string;
  }
  key_->assign(value);
}
inline void KeyedStrings::set_key(const char* value) {
  set_has_key();
  if (key_ == &::google::protobuf::internal::kEmptyString) {
    key_ = new ::std::string;
  }
  key_->assign(value);
}
inline void KeyedStrings::set_key(const char* value, size_t size) {
  set_has_key();
  if (key_ == &::google::protobuf::internal::kEmptyString) {
    key_ = new ::std::string;
  }
  key_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* KeyedStrings::mutable_key() {
  set_has_key();
  if (key_ == &::google::protobuf::internal::kEmptyString) {
    key_ = new ::std::string;
  }
  return key_;
}
inline ::std::string* KeyedStrings::release_key() {
  clear_has_key();
  if (key_ == &::google::protobuf::internal::kEmptyString) {
    return NULL;
  } else {
    ::std::string* temp = key_;
    key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
    return temp;
  }
}
inline void KeyedStrings::set_allocated_key(::std::string* key) {
  if (key_ != &::google::protobuf::internal::kEmptyString) {
    delete key_;
  }
  if (key) {
    set_has_key();
    key_ = key;
  } else {
    clear_has_key();
    key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
  }
}

// repeated string value = 2;
inline int KeyedStrings::value_size() const {
  return value_.size();
}
inline void KeyedStrings::clear_value() {
  value_.Clear();
}
inline const ::std::string& KeyedStrings::value(int index) const {
  return value_.Get(index);
}
inline ::std::string* KeyedStrings::mutable_value(int index) {
  return value_.Mutable(index);
}
inline void KeyedStrings::set_value(int index, const ::std::string& value) {
  value_.Mutable(index)->assign(value);
}
inline void KeyedStrings::set_value(int index, const char* value) {
  value_.Mutable(index)->assign(value);
}
inline void KeyedStrings::set_value(int index, const char* value, size_t size) {
  value_.Mutable(index)->assign(
    reinterpret_cast<const char*>(value), size);
}
inline ::std::string* KeyedStrings::add_value() {
  return value_.Add();
}
inline void KeyedStrings::add_value(const ::std::string& value) {
  value_.Add()->assign(value);
}
inline void KeyedStrings::add_value(const char* value) {
  value_.Add()->assign(value);
}
inline void KeyedStrings::add_value(const char* value, size_t size) {
  value_.Add()->assign(reinterpret_cast<const char*>(value), size);
}
inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
KeyedStrings::value() const {
  return value_;
}
inline ::google::protobuf::RepeatedPtrField< ::std::string>*
KeyedStrings::mutable_value() {
  return &value_;
}

// -------------------------------------------------------------------

// Map

// repeated .test.KeyedStrings map = 1;
inline int Map::map_size() const {
  return map_.size();
}
inline void Map::clear_map() {
  map_.Clear();
}
inline const ::test::KeyedStrings& Map::map(int index) const {
  return map_.Get(index);
}
inline ::test::KeyedStrings* Map::mutable_map(int index) {
  return map_.Mutable(index);
}
inline ::test::KeyedStrings* Map::add_map() {
  return map_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::test::KeyedStrings >&
Map::map() const {
  return map_;
}
inline ::google::protobuf::RepeatedPtrField< ::test::KeyedStrings >*
Map::mutable_map() {
  return &map_;
}

// repeated string test = 2;
inline int Map::test_size() const {
  return test_.size();
}
inline void Map::clear_test() {
  test_.Clear();
}
inline const ::std::string& Map::test(int index) const {
  return test_.Get(index);
}
inline ::std::string* Map::mutable_test(int index) {
  return test_.Mutable(index);
}
inline void Map::set_test(int index, const ::std::string& value) {
  test_.Mutable(index)->assign(value);
}
inline void Map::set_test(int index, const char* value) {
  test_.Mutable(index)->assign(value);
}
inline void Map::set_test(int index, const char* value, size_t size) {
  test_.Mutable(index)->assign(
    reinterpret_cast<const char*>(value), size);
}
inline ::std::string* Map::add_test() {
  return test_.Add();
}
inline void Map::add_test(const ::std::string& value) {
  test_.Add()->assign(value);
}
inline void Map::add_test(const char* value) {
  test_.Add()->assign(value);
}
inline void Map::add_test(const char* value, size_t size) {
  test_.Add()->assign(reinterpret_cast<const char*>(value), size);
}
inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
Map::test() const {
  return test_;
}
inline ::google::protobuf::RepeatedPtrField< ::std::string>*
Map::mutable_test() {
  return &test_;
}


// @@protoc_insertion_point(namespace_scope)

}  // namespace test

#ifndef SWIG
namespace google {
namespace protobuf {


}  // namespace google
}  // namespace protobuf
#endif  // SWIG

// @@protoc_insertion_point(global_scope)

#endif  // PROTOBUF_Map_2eproto__INCLUDED

Attachment: Map.proto
Description: Binary data

Reply via email to