1ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Protocol Buffers - Google's data interchange format
2ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Copyright 2008 Google Inc.  All rights reserved.
3ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// http://code.google.com/p/protobuf/
4ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//
5ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Redistribution and use in source and binary forms, with or without
6ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// modification, are permitted provided that the following conditions are
7ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// met:
8ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//
9ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//     * Redistributions of source code must retain the above copyright
10ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// notice, this list of conditions and the following disclaimer.
11ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//     * Redistributions in binary form must reproduce the above
12ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// copyright notice, this list of conditions and the following disclaimer
13ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// in the documentation and/or other materials provided with the
14ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// distribution.
15ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//     * Neither the name of Google Inc. nor the names of its
16ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// contributors may be used to endorse or promote products derived from
17ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// this software without specific prior written permission.
18ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//
19ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
31ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Author: kenton@google.com (Kenton Varda)
32ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//
33d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// Front-end for protoc code generator plugins written in C++.
34d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//
35d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// To implement a protoc plugin in C++, simply write an implementation of
36d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// CodeGenerator, then create a main() function like:
37d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   int main(int argc, char* argv[]) {
38d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//     MyCodeGenerator generator;
39d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//     return google::protobuf::compiler::PluginMain(argc, argv, &generator);
40d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   }
41d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// You must link your plugin against libprotobuf and libprotoc.
42d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//
43d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// To get protoc to use the plugin, do one of the following:
44d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// * Place the plugin binary somewhere in the PATH and give it the name
45d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   "protoc-gen-NAME" (replacing "NAME" with the name of your plugin).  If you
46d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   then invoke protoc with the parameter --NAME_out=OUT_DIR (again, replace
47d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   "NAME" with your plugin's name), protoc will invoke your plugin to generate
48d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   the output, which will be placed in OUT_DIR.
49d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// * Place the plugin binary anywhere, with any name, and pass the --plugin
50d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   parameter to protoc to direct it to your plugin like so:
51d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//     protoc --plugin=protoc-gen-NAME=path/to/mybinary --NAME_out=OUT_DIR
52d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//   On Windows, make sure to include the .exe suffix:
53d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville//     protoc --plugin=protoc-gen-NAME=path/to/mybinary.exe --NAME_out=OUT_DIR
54ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
55d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
56d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
57ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
58d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#include <google/protobuf/stubs/common.h>
59ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
60ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Savillenamespace google {
61ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Savillenamespace protobuf {
62ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Savillenamespace compiler {
63ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
64d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savilleclass CodeGenerator;    // code_generator.h
65ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
66d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// Implements main() for a protoc plugin exposing the given code generator.
67d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink SavilleLIBPROTOC_EXPORT int PluginMain(int argc, char* argv[], const CodeGenerator* generator);
68ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
69ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville}  // namespace compiler
70ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville}  // namespace protobuf
71ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
72ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville}  // namespace google
73d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#endif  // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
74