I am trying to achieve to basic pattern.
>From business objects  defined as message in a proto file, I would
like to generate some additional messages to handle CRUD operations.

Eg my test.proto file contains:

message TestObject {
  option messageType = BO;
  required string message = 1;
}

I am fighting with the generator code in order to generate directly
the following message:

message CreateTestObject {
  required TestObject object = 1;
}

The problem is for importing my proto file.
If I add the dependency, the file cannot be loaded. Maybe I am missing
how to set up the dependency path in the generator.

I am using the follwing main:

int main(int argc, char* argv[]) {
  google::protobuf::compiler::CommandLineInterface cli;

  vpmsproto::compiler::JavaGenerator  java_generator;
  cli.RegisterGenerator("--java_out", &java_generator,
    "Generate Java source and header.");
  return cli.Run(argc, argv);
}

And in my generator, I do the following:

  bool Generate(const FileDescriptor* file,
                const string& parameter,
                compiler::OutputDirectory* output_directory,
                string* error) const {
...
      DescriptorPool pool;
      FileDescriptorProto proto =  FileDescriptorProto();
      proto.set_name("testEric");
      proto.add_dependency("test.proto");
...

      const FileDescriptor* newFile = pool.BuildFile(proto);
...

I have the following error:


libprotobuf ERROR google/protobuf/descriptor.cc:2222] Invalid proto
descriptor for file "testEric":
libprotobuf ERROR google/protobuf/descriptor.cc:2225]   testEric:
Import "test.proto" has not been loaded.


Am I missing something?
Is there a more efficient to achive my goal?
Thanks in advance for your help.
Eric

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@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