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_CPP_MESSAGE_FIELD_H__
22 #define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
26 #include <google/protobuf/compiler/cpp/cpp_field.h>
33 class MessageFieldGenerator
: public FieldGenerator
{
35 explicit MessageFieldGenerator(const FieldDescriptor
* descriptor
);
36 ~MessageFieldGenerator();
38 // implements FieldGenerator ---------------------------------------
39 void GeneratePrivateMembers(io::Printer
* printer
) const;
40 void GenerateAccessorDeclarations(io::Printer
* printer
) const;
41 void GenerateInlineAccessorDefinitions(io::Printer
* printer
) const;
42 void GenerateClearingCode(io::Printer
* printer
) const;
43 void GenerateMergingCode(io::Printer
* printer
) const;
44 void GenerateInitializer(io::Printer
* printer
) const;
45 void GenerateMergeFromCodedStream(io::Printer
* printer
) const;
46 void GenerateSerializeWithCachedSizes(io::Printer
* printer
) const;
47 void GenerateByteSize(io::Printer
* printer
) const;
50 const FieldDescriptor
* descriptor_
;
51 map
<string
, string
> variables_
;
53 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator
);
56 class RepeatedMessageFieldGenerator
: public FieldGenerator
{
58 explicit RepeatedMessageFieldGenerator(const FieldDescriptor
* descriptor
);
59 ~RepeatedMessageFieldGenerator();
61 // implements FieldGenerator ---------------------------------------
62 void GeneratePrivateMembers(io::Printer
* printer
) const;
63 void GenerateAccessorDeclarations(io::Printer
* printer
) const;
64 void GenerateInlineAccessorDefinitions(io::Printer
* printer
) const;
65 void GenerateClearingCode(io::Printer
* printer
) const;
66 void GenerateMergingCode(io::Printer
* printer
) const;
67 void GenerateInitializer(io::Printer
* printer
) const;
68 void GenerateMergeFromCodedStream(io::Printer
* printer
) const;
69 void GenerateSerializeWithCachedSizes(io::Printer
* printer
) const;
70 void GenerateByteSize(io::Printer
* printer
) const;
73 const FieldDescriptor
* descriptor_
;
74 map
<string
, string
> variables_
;
76 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator
);
80 } // namespace compiler
81 } // namespace protobuf
84 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__