/xdl-algorithm-solution/ESMM/data/third_party/protobuf/protobuf-3.5.0/src/google/protobuf/compiler/cpp/cpp_message_field.h

https://github.com/alibaba/x-deeplearning · C Header · 158 lines · 86 code · 21 blank · 51 comment · 0 complexity · 8fd7833a30a470915f1a1f36a7f98b6e MD5 · raw file

  1. /* Copyright (C) 2016-2018 Alibaba Group Holding Limited
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. ==============================================================================*/
  12. // Protocol Buffers - Google's data interchange format
  13. // Copyright 2008 Google Inc. All rights reserved.
  14. // https://developers.google.com/protocol-buffers/
  15. //
  16. // Redistribution and use in source and binary forms, with or without
  17. // modification, are permitted provided that the following conditions are
  18. // met:
  19. //
  20. // * Redistributions of source code must retain the above copyright
  21. // notice, this list of conditions and the following disclaimer.
  22. // * Redistributions in binary form must reproduce the above
  23. // copyright notice, this list of conditions and the following disclaimer
  24. // in the documentation and/or other materials provided with the
  25. // distribution.
  26. // * Neither the name of Google Inc. nor the names of its
  27. // contributors may be used to endorse or promote products derived from
  28. // this software without specific prior written permission.
  29. //
  30. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  33. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  36. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  37. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  38. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  39. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  40. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  41. // Author: kenton@google.com (Kenton Varda)
  42. // Based on original Protocol Buffers design by
  43. // Sanjay Ghemawat, Jeff Dean, and others.
  44. #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
  45. #define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
  46. #include <map>
  47. #include <string>
  48. #include <google/protobuf/compiler/cpp/cpp_field.h>
  49. namespace google {
  50. namespace protobuf {
  51. namespace compiler {
  52. namespace cpp {
  53. bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options);
  54. class MessageFieldGenerator : public FieldGenerator {
  55. public:
  56. MessageFieldGenerator(const FieldDescriptor* descriptor,
  57. const Options& options);
  58. ~MessageFieldGenerator();
  59. // implements FieldGenerator ---------------------------------------
  60. void GeneratePrivateMembers(io::Printer* printer) const;
  61. void GenerateAccessorDeclarations(io::Printer* printer) const;
  62. void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
  63. void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
  64. void GenerateClearingCode(io::Printer* printer) const;
  65. void GenerateMessageClearingCode(io::Printer* printer) const;
  66. void GenerateMergingCode(io::Printer* printer) const;
  67. void GenerateSwappingCode(io::Printer* printer) const;
  68. void GenerateDestructorCode(io::Printer* printer) const;
  69. void GenerateConstructorCode(io::Printer* printer) const;
  70. void GenerateCopyConstructorCode(io::Printer* printer) const;
  71. void GenerateMergeFromCodedStream(io::Printer* printer) const;
  72. void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
  73. void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
  74. void GenerateByteSize(io::Printer* printer) const;
  75. protected:
  76. const FieldDescriptor* descriptor_;
  77. const bool implicit_weak_field_;
  78. std::map<string, string> variables_;
  79. private:
  80. GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
  81. };
  82. class MessageOneofFieldGenerator : public MessageFieldGenerator {
  83. public:
  84. MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
  85. const Options& options);
  86. ~MessageOneofFieldGenerator();
  87. // implements FieldGenerator ---------------------------------------
  88. void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
  89. void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
  90. void GenerateClearingCode(io::Printer* printer) const;
  91. // MessageFieldGenerator, from which we inherit, overrides this so we need to
  92. // override it as well.
  93. void GenerateMessageClearingCode(io::Printer* printer) const;
  94. void GenerateSwappingCode(io::Printer* printer) const;
  95. void GenerateDestructorCode(io::Printer* printer) const;
  96. void GenerateConstructorCode(io::Printer* printer) const;
  97. private:
  98. const bool dependent_base_;
  99. GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
  100. };
  101. class RepeatedMessageFieldGenerator : public FieldGenerator {
  102. public:
  103. RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
  104. const Options& options);
  105. ~RepeatedMessageFieldGenerator();
  106. // implements FieldGenerator ---------------------------------------
  107. void GeneratePrivateMembers(io::Printer* printer) const;
  108. void GenerateDependentAccessorDeclarations(io::Printer* printer) const;
  109. void GenerateAccessorDeclarations(io::Printer* printer) const;
  110. void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const;
  111. void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
  112. void GenerateClearingCode(io::Printer* printer) const;
  113. void GenerateMergingCode(io::Printer* printer) const;
  114. void GenerateSwappingCode(io::Printer* printer) const;
  115. void GenerateConstructorCode(io::Printer* printer) const;
  116. void GenerateCopyConstructorCode(io::Printer* printer) const {}
  117. void GenerateMergeFromCodedStream(io::Printer* printer) const;
  118. void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
  119. void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
  120. void GenerateByteSize(io::Printer* printer) const;
  121. private:
  122. void InternalGenerateTypeDependentAccessorDeclarations(
  123. io::Printer* printer) const;
  124. const FieldDescriptor* descriptor_;
  125. const bool dependent_field_;
  126. const bool implicit_weak_field_;
  127. std::map<string, string> variables_;
  128. GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);
  129. };
  130. } // namespace cpp
  131. } // namespace compiler
  132. } // namespace protobuf
  133. } // namespace google
  134. #endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__