diff options
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_field.h')
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_field.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index fdd338a6..00dc25d4 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -61,11 +61,11 @@ namespace cpp { // ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size', // 'deprecation']. void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options); void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables); + std::map<string, string>* variables); class FieldGenerator { public: @@ -124,10 +124,20 @@ class FieldGenerator { io::Printer* /*printer*/) const {} // Generate lines of code (statements, not declarations) which clear the - // field. This is used to define the clear_$name$() method as well as - // the Clear() method for the whole message. + // field. This is used to define the clear_$name$() method virtual void GenerateClearingCode(io::Printer* printer) const = 0; + // Generate lines of code (statements, not declarations) which clear the field + // as part of the Clear() method for the whole message. For message types + // which have field presence bits, MessageGenerator::GenerateClear will have + // already checked the presence bits. + // + // Since most field types can re-use GenerateClearingCode, this method is not + // pure virtual. + virtual void GenerateMessageClearingCode(io::Printer* printer) const { + GenerateClearingCode(printer); + } + // Generate lines of code (statements, not declarations) which merges the // contents of the field from the current message to the target message, // which is stored in the generated code variable "from". @@ -136,12 +146,8 @@ class FieldGenerator { // GenerateMergeFrom method. virtual void GenerateMergingCode(io::Printer* printer) const = 0; - // The same, but the generated code may or may not check the possibility that - // the two objects being merged have the same address. To be safe, callers - // should avoid calling this unless they know the objects are different. - virtual void GenerateUnsafeMergingCode(io::Printer* printer) const { - GenerateMergingCode(printer); - } + // Generates a copy constructor + virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0; // Generate lines of code (statements, not declarations) which swaps // this field and the corresponding field of another message, which |