templates.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>, Tatyana Borisova <tanusshhka@mail.ru>
  5. *
  6. * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. #pragma once
  26. #include <unordered_map>
  27. #include <string>
  28. #include <google/protobuf/descriptor.h>
  29. namespace QtProtobuf {
  30. namespace generator {
  31. /*!
  32. * \ingroup generator
  33. * \private
  34. * \brief The Templates class
  35. */
  36. class Templates {
  37. public:
  38. static const std::vector<std::string> ListOfQmlExeptions;
  39. static const char *ProtoSufix;
  40. static const char *DefaultProtobufIncludesTemplate;
  41. static const char *QmlProtobufIncludesTemplate;
  42. static const char *GlobalEnumClassNameTemplate;
  43. static const char *PreambleTemplate;
  44. static const char *DisclaimerTemplate;
  45. static const char *InternalIncludeTemplate;
  46. static const char *ExternalIncludeTemplate;
  47. static const char *GlobalEnumIncludeTemplate;
  48. static const char *UsingQtProtobufNamespaceTemplate;
  49. static const char *ManualRegistrationDeclaration;
  50. static const char *ManualRegistrationComplexTypeDefinition;
  51. static const char *ManualRegistrationGlobalEnumDefinition;
  52. static const char *ComplexGlobalEnumFieldRegistrationTemplate;
  53. static const char *ComplexListTypeUsingTemplate;
  54. static const char *MapTypeUsingTemplate;
  55. static const char *MessageMapTypeUsingTemplate;
  56. static const char *NestedMessageUsingTemplate;
  57. static const char *EnumTypeRepeatedTemplate;
  58. static const char *NamespaceTemplate;
  59. static const char *UsingNamespaceTemplate;
  60. static const char *ClassDeclarationTemplate;
  61. static const char *ProtoClassForwardDeclarationTemplate;
  62. static const char *ProtoClassDeclarationBeginTemplate;
  63. static const char *ConstructorHeaderTemplate;
  64. static const char *ClassDefinitionTemplate;
  65. static const char *QObjectMacro;
  66. static const char *PropertyTemplate;
  67. static const char *RepeatedPropertyTemplate;
  68. static const char *RepeatedMessagePropertyTemplate;
  69. static const char *NonScriptablePropertyTemplate;
  70. static const char *NonScriptableAliasPropertyTemplate;
  71. static const char *MessagePropertyTemplate;
  72. static const char *QmlListPropertyTemplate;
  73. static const char *ConstructorParameterTemplate;
  74. static const char *ConstructorMessageParameterTemplate;
  75. static const char *ConstructorRepeatedParameterTemplate;
  76. static const char *ProtoConstructorBeginTemplate;
  77. static const char *ProtoConstructorEndTemplate;
  78. static const char *ConstructorParameterDefinitionTemplate;
  79. static const char *ConstructorMessageParameterDefinitionTemplate;
  80. static const char *ConstructorRepeatedParameterDefinitionTemplate;
  81. static const char *ProtoConstructorDefinitionBeginTemplate;
  82. static const char *ProtoConstructorDefinitionEndTemplate;
  83. static const char *MemberTemplate;
  84. static const char *ListMemberTemplate;
  85. static const char *ComplexMemberTemplate;
  86. static const char *PublicBlockTemplate;
  87. static const char *PrivateBlockTemplate;
  88. static const char *EnumDefinitionTemplate;
  89. static const char *EnumFieldTemplate;
  90. static const char *ConstructorTemplate;
  91. static const char *QObjectConstructorTemplate;
  92. static const char *CopyConstructorDeclarationTemplate;
  93. static const char *MoveConstructorDeclarationTemplate;
  94. static const char *CopyConstructorDefinitionTemplate;
  95. static const char *MoveConstructorDefinitionTemplate;
  96. static const char *EmptyCopyConstructorDefinitionTemplate;
  97. static const char *EmptyMoveConstructorDefinitionTemplate;
  98. static const char *DeletedCopyConstructorTemplate;
  99. static const char *DeletedMoveConstructorTemplate;
  100. static const char *CopyFieldTemplate;
  101. static const char *CopyComplexFieldTemplate;
  102. static const char *AssignComplexFieldTemplate;
  103. static const char *MoveMessageFieldTemplate;
  104. static const char *MoveAssignMessageFieldTemplate;
  105. static const char *MoveComplexFieldTemplate;
  106. static const char *MoveComplexFieldConstructorTemplate;
  107. static const char *MoveFieldTemplate;
  108. static const char *EnumMoveFieldTemplate;
  109. static const char *AssignmentOperatorDeclarationTemplate;
  110. static const char *AssignmentOperatorDefinitionTemplate;
  111. static const char *EmptyAssignmentOperatorDefinitionTemplate;
  112. static const char *AssignmentOperatorReturnTemplate;
  113. static const char *MoveAssignmentOperatorDeclarationTemplate;
  114. static const char *MoveAssignmentOperatorDefinitionTemplate;
  115. static const char *EmptyMoveAssignmentOperatorDefinitionTemplate;
  116. static const char *EqualOperatorDeclarationTemplate;
  117. static const char *EqualOperatorDefinitionTemplate;
  118. static const char *EmptyEqualOperatorDefinitionTemplate;
  119. static const char *EqualOperatorPropertyTemplate;
  120. static const char *EqualOperatorMessagePropertyTemplate;
  121. static const char *EqualOperatorRepeatedPropertyTemplate;
  122. static const char *NotEqualOperatorDeclarationTemplate;
  123. static const char *NotEqualOperatorDefinitionTemplate;
  124. static const char *GetterPrivateMessageDeclarationTemplate;
  125. static const char *GetterPrivateMessageDefinitionTemplate;
  126. static const char *GetterMessageDeclarationTemplate;
  127. static const char *GetterMessageDefinitionTemplate;
  128. static const char *GetterTemplate;
  129. static const char *NonScriptableGetterTemplate;
  130. static const char *GetterContainerExtraTemplate;
  131. static const char *GetterQmlListDeclarationTemplate;
  132. static const char *GetterQmlListDefinitionTemplate;
  133. static const char *SetterPrivateTemplateDeclarationMessageType;
  134. static const char *SetterPrivateTemplateDefinitionMessageType;
  135. static const char *SetterTemplateDeclarationMessageType;
  136. static const char *SetterTemplateDefinitionMessageType;
  137. static const char *SetterTemplateDeclarationComplexType;
  138. static const char *SetterTemplateDefinitionComplexType;
  139. static const char *SetterTemplate;
  140. static const char *NonScriptableSetterTemplate;
  141. static const char *SignalsBlockTemplate;
  142. static const char *SignalTemplate;
  143. static const char *FieldsOrderingContainerTemplate;
  144. static const char *FieldOrderTemplate;
  145. static const char *EnumTemplate;
  146. static const char *SimpleBlockEnclosureTemplate;
  147. static const char *SemicolonBlockEnclosureTemplate;
  148. static const char *EmptyBlockTemplate;
  149. static const char *PropertyInitializerTemplate;
  150. static const char *PropertyDefaultInitializerTemplate;
  151. static const char *MessagePropertyInitializerTemplate;
  152. static const char *MessagePropertyDefaultInitializerTemplate;
  153. static const char *ConstructorContentTemplate;
  154. static const char *DeclareMetaTypeTemplate;
  155. static const char *DeclareMetaTypeListTemplate;
  156. static const char *DeclareMessageMetaTypeTemplate;
  157. static const char *DeclareComplexListTypeTemplate;
  158. static const char *DeclareComplexQmlListTypeTemplate;
  159. static const char *DeclareMetaTypeMapTemplate;
  160. static const char *RegisterLocalEnumTemplate;
  161. static const char *RegisterMapTemplate;
  162. static const char *RegisterMetaTypeTemplate;
  163. static const char *RegisterGlobalEnumMetaTypeTemplate;
  164. static const char *RegisterMetaTypeTemplateNoNamespace;
  165. static const char *RegisterQmlListPropertyMetaTypeTemplate;
  166. static const char *QEnumTemplate;
  167. static const char *RegisterSerializersTemplate;
  168. static const char *RegisterEnumSerializersTemplate;
  169. static const char *RegistrarTemplate;
  170. static const char *EnumRegistrarTemplate;
  171. static const char *QmlRegisterTypeTemplate;
  172. static const char *QmlRegisterTypeUncreatableTemplate;
  173. static const char *QmlRegisterEnumTypeTemplate;
  174. //Service templates
  175. static const char *ClientConstructorDefinitionTemplate;
  176. static const char *ClientMethodDeclarationSyncTemplate;
  177. static const char *ClientMethodDeclarationAsyncTemplate;
  178. static const char *ClientMethodDeclarationAsync2Template;
  179. static const char *ClientMethodDeclarationQmlTemplate;
  180. static const char *ClientMethodDeclarationQml2Template;
  181. static const char *ServerMethodDeclarationTemplate;
  182. static const char *ClientMethodDefinitionSyncTemplate;
  183. static const char *ClientMethodDefinitionAsyncTemplate;
  184. static const char *ClientMethodDefinitionAsync2Template;
  185. static const char *ClientMethodDefinitionQmlTemplate;
  186. static const char *ClientMethodDefinitionQml2Template;
  187. //Streaming
  188. static const char *ClientMethodSignalDeclarationTemplate;
  189. static const char *ClientMethodServerStreamDeclarationTemplate;
  190. static const char *ClientMethodServerStream2DeclarationTemplate;
  191. static const char *ClientMethodServerStreamQmlDeclarationTemplate;
  192. static const char *ClientMethodServerStreamDefinitionTemplate;
  193. static const char *ClientMethodServerStream2DefinitionTemplate;
  194. static const char *ClientMethodServerStreamQmlDefinitionTemplate;
  195. static const char *ListSuffix;
  196. static const char *ProtoFileSuffix;
  197. static const char *GrpcFileSuffix;
  198. static const char *EnumClassSuffix;
  199. static const std::unordered_map<::google::protobuf::FieldDescriptor::Type, std::string> TypeReflection;
  200. static const char *QtProtobufNamespace;
  201. static const char *QtProtobufNestedNamespace;
  202. static const char *FieldEnumTemplate;
  203. static const char *FieldNumberTemplate;
  204. static const char *QtProtobufFieldEnum;
  205. };
  206. } //namespace generator
  207. } //namespace QtProtobuf