1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.
3 // http://code.google.com/p/protobuf/
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // Author: kenton@google.com (Kenton Varda)
18 // Based on original Protocol Buffers design by
19 // Sanjay Ghemawat, Jeff Dean, and others.
21 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
22 #define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
25 #include <google/protobuf/stubs/common.h>
26 #include <google/protobuf/descriptor.h>
31 class Printer
; // printer.h
39 class FieldGenerator
{
42 virtual ~FieldGenerator();
44 virtual void GenerateMembers(io::Printer
* printer
) const = 0;
45 virtual void GenerateBuilderMembers(io::Printer
* printer
) const = 0;
46 virtual void GenerateMergingCode(io::Printer
* printer
) const = 0;
47 virtual void GenerateBuildingCode(io::Printer
* printer
) const = 0;
48 virtual void GenerateParsingCode(io::Printer
* printer
) const = 0;
49 virtual void GenerateSerializationCode(io::Printer
* printer
) const = 0;
50 virtual void GenerateSerializedSizeCode(io::Printer
* printer
) const = 0;
52 virtual string
GetBoxedType() const = 0;
55 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator
);
58 // Convenience class which constructs FieldGenerators for a Descriptor.
59 class FieldGeneratorMap
{
61 explicit FieldGeneratorMap(const Descriptor
* descriptor
);
64 const FieldGenerator
& get(const FieldDescriptor
* field
) const;
65 const FieldGenerator
& get_extension(int index
) const;
68 const Descriptor
* descriptor_
;
69 scoped_array
<scoped_ptr
<FieldGenerator
> > field_generators_
;
70 scoped_array
<scoped_ptr
<FieldGenerator
> > extension_generators_
;
72 static FieldGenerator
* MakeGenerator(const FieldDescriptor
* field
);
74 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap
);
78 } // namespace compiler
79 } // namespace protobuf
82 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__