Header_Template.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. {% macro enum_macro(_enum) %}
  2. enum {{ _enum.name }}
  3. {
  4. {% for value in _enum.values() %}
  5. {{ value.name }} = {{ value.number }}{{ "," if not loop.last }}
  6. {% endfor %}
  7. };
  8. {% endmacro %}
  9. {# #}
  10. {# ------------------------------------------------------------------------------------------------------------------ #}
  11. {# #}
  12. {% macro oneof_init(_oneof) %}
  13. void init_{{_oneof.name}}(const id field_id)
  14. {
  15. if(id::NOT_SET != {{_oneof.which_oneof}})
  16. {
  17. // First delete the old object in the oneof.
  18. clear_{{_oneof.name}}();
  19. }
  20. // C++11 unions only support nontrivial members when you explicitly call the placement new statement.
  21. switch(field_id)
  22. {
  23. {% for field in _oneof.fields() %}
  24. case id::{{field.variable_id_name}}:
  25. {% if field.of_type_message or field.is_repeated_field or field.is_string or field.is_bytes %}
  26. new(&{{field.variable_full_name}}) {{field.type}};
  27. {{_oneof.which_oneof}} = id::{{field.variable_id_name}};
  28. {% endif %}
  29. break;
  30. {% endfor %}
  31. default:
  32. break;
  33. }
  34. }
  35. {% endmacro %}
  36. {# #}
  37. {# ------------------------------------------------------------------------------------------------------------------ #}
  38. {# #}
  39. {% macro oneof_assign(_oneof) %}
  40. if(rhs.get_which_{{_oneof.name}}() != {{_oneof.which_oneof}})
  41. {
  42. // First delete the old object in the oneof.
  43. clear_{{_oneof.name}}();
  44. }
  45. switch(rhs.get_which_{{_oneof.name}}())
  46. {
  47. {% for field in _oneof.fields() %}
  48. case id::{{field.variable_id_name}}:
  49. set_{{field.name}}(rhs.get_{{field.name}}());
  50. break;
  51. {% endfor %}
  52. default:
  53. break;
  54. }
  55. {% endmacro %}
  56. {# #}
  57. {# ------------------------------------------------------------------------------------------------------------------ #}
  58. {# #}
  59. {% macro oneof_clear(_oneof) %}
  60. void clear_{{_oneof.name}}()
  61. {
  62. switch({{_oneof.which_oneof}})
  63. {
  64. {% for field in _oneof.fields() %}
  65. case id::{{field.variable_id_name}}:
  66. {% if field.of_type_message or field.is_repeated_field or field.is_string or field.is_bytes%}
  67. {{field.variable_full_name}}.~{{field.short_type}}();
  68. {% else %}
  69. {{field.variable_full_name}}.set(0);
  70. {% endif %}
  71. break;
  72. {% endfor %}
  73. default:
  74. break;
  75. }
  76. {{_oneof.which_oneof}} = id::NOT_SET;
  77. }
  78. {% endmacro %}
  79. {# #}
  80. {# ------------------------------------------------------------------------------------------------------------------ #}
  81. {# #}
  82. {% macro field_get_set_macro(_field) %}
  83. {% if _field.is_string or _field.is_bytes %}
  84. inline const {{_field.repeated_type}}& {{_field.name}}() const { return {{_field.variable_full_name}}; }
  85. {% if _field.which_oneof is defined %}
  86. inline void clear_{{_field.name}}()
  87. {
  88. if(id::{{_field.variable_id_name}} == {{_field.which_oneof}})
  89. {
  90. {{_field.which_oneof}} = id::NOT_SET;
  91. {{_field.variable_full_name}}.~{{_field.short_type}}();
  92. }
  93. }
  94. inline {{_field.repeated_type}}& mutable_{{_field.name}}()
  95. {
  96. if(id::{{_field.variable_id_name}} != {{_field.which_oneof}})
  97. {
  98. init_{{_field.oneof_name}}(id::{{_field.variable_id_name}});
  99. }
  100. return {{_field.variable_full_name}};
  101. }
  102. {% else %}
  103. inline void clear_{{_field.name}}() { {{_field.variable_full_name}}.clear(); }
  104. inline {{_field.repeated_type}}& mutable_{{_field.name}}() { return {{_field.variable_full_name}}; }
  105. {% endif %}
  106. {% if _field.is_string %}
  107. inline const char* get_{{_field.name}}() const { return {{_field.variable_full_name}}.get_const(); }
  108. {% else %}{# is bytes #}
  109. inline const uint8_t* get_{{_field.name}}() const { return {{_field.variable_full_name}}.get_const(); }
  110. {% endif %}
  111. {% elif _field.is_repeated_field %}
  112. inline const {{_field.type}}& {{_field.name}}(uint32_t index) const { return {{_field.variable_full_name}}[index]; }
  113. {% if _field.which_oneof is defined %}
  114. inline void clear_{{_field.name}}()
  115. {
  116. if(id::{{_field.variable_id_name}} == {{_field.which_oneof}})
  117. {
  118. {{_field.which_oneof}} = id::NOT_SET;
  119. {{_field.variable_full_name}}.~{{_field.short_type}}();
  120. }
  121. }
  122. inline void set_{{_field.name}}(uint32_t index, const {{_field.type}}& value)
  123. {
  124. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  125. {{_field.variable_full_name}}.set(index, value);
  126. }
  127. inline void set_{{_field.name}}(uint32_t index, const {{_field.type}}&& value)
  128. {
  129. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  130. {{_field.variable_full_name}}.set(index, value);
  131. }
  132. inline void set_{{_field.name}}(const {{_field.repeated_type}}& values)
  133. {
  134. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  135. {{_field.variable_full_name}} = values;
  136. }
  137. inline void add_{{_field.name}}(const {{_field.type}}& value)
  138. {
  139. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  140. {{_field.variable_full_name}}.add(value);
  141. }
  142. inline {{_field.repeated_type}}& mutable_{{_field.name}}()
  143. {
  144. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  145. return {{_field.variable_full_name}};
  146. }
  147. {% else %}
  148. inline void clear_{{_field.name}}() { {{_field.variable_full_name}}.clear(); }
  149. inline void set_{{_field.name}}(uint32_t index, const {{_field.type}}& value) { {{_field.variable_full_name}}.set(index, value); }
  150. inline void set_{{_field.name}}(uint32_t index, const {{_field.type}}&& value) { {{_field.variable_full_name}}.set(index, value); }
  151. inline void set_{{_field.name}}(const {{_field.repeated_type}}& values) { {{_field.variable_full_name}} = values; }
  152. inline void add_{{_field.name}}(const {{_field.type}}& value) { {{_field.variable_full_name}}.add(value); }
  153. inline {{_field.repeated_type}}& mutable_{{_field.name}}() { return {{_field.variable_full_name}}; }
  154. {% endif %}
  155. inline const {{_field.repeated_type}}& get_{{_field.name}}() const { return {{_field.variable_full_name}}; }
  156. {% elif _field.of_type_message %}
  157. inline const {{_field.type}}& {{_field.name}}() const { return {{_field.variable_full_name}}; }
  158. {% if _field.which_oneof is defined %}
  159. inline void clear_{{_field.name}}()
  160. {
  161. if(id::{{_field.variable_id_name}} == {{_field.which_oneof}})
  162. {
  163. {{_field.which_oneof}} = id::NOT_SET;
  164. {{_field.variable_full_name}}.~{{_field.short_type}}();
  165. }
  166. }
  167. inline void set_{{_field.name}}(const {{_field.type}}& value)
  168. {
  169. if(id::{{_field.variable_id_name}} != {{_field.which_oneof}})
  170. {
  171. init_{{_field.oneof_name}}(id::{{_field.variable_id_name}});
  172. }
  173. {{_field.variable_full_name}} = value;
  174. }
  175. inline void set_{{_field.name}}(const {{_field.type}}&& value)
  176. {
  177. if(id::{{_field.variable_id_name}} != {{_field.which_oneof}})
  178. {
  179. init_{{_field.oneof_name}}(id::{{_field.variable_id_name}});
  180. }
  181. {{_field.variable_full_name}} = value;
  182. }
  183. inline {{_field.type}}& mutable_{{_field.name}}()
  184. {
  185. if(id::{{_field.variable_id_name}} != {{_field.which_oneof}})
  186. {
  187. init_{{_field.oneof_name}}(id::{{_field.variable_id_name}});
  188. }
  189. return {{_field.variable_full_name}};
  190. }
  191. {% else %}
  192. inline void clear_{{_field.name}}() { {{_field.variable_full_name}}.clear(); }
  193. inline void set_{{_field.name}}(const {{_field.type}}& value) { {{_field.variable_full_name}} = value; }
  194. inline void set_{{_field.name}}(const {{_field.type}}&& value) { {{_field.variable_full_name}} = value; }
  195. inline {{_field.type}}& mutable_{{_field.name}}() { return {{_field.variable_full_name}}; }
  196. {% endif %}
  197. inline const {{_field.type}}& get_{{_field.name}}() const { return {{_field.variable_full_name}}; }
  198. {% elif _field.of_type_enum %}
  199. inline {{_field.type}} {{_field.name}}() const { return {{_field.variable_full_name}}; }
  200. {% if _field.which_oneof is defined %}
  201. inline void clear_{{_field.name}}()
  202. {
  203. if(id::{{_field.variable_id_name}} == {{_field.which_oneof}})
  204. {
  205. {{_field.which_oneof}} = id::NOT_SET;
  206. {{_field.variable_full_name}} = static_cast<{{_field.type}}>({{_field.default_value}});
  207. }
  208. }
  209. inline void set_{{_field.name}}(const {{_field.type}}& value)
  210. {
  211. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  212. {{_field.variable_full_name}} = value;
  213. }
  214. inline void set_{{_field.name}}(const {{_field.type}}&& value)
  215. {
  216. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  217. {{_field.variable_full_name}} = value;
  218. }
  219. {% else %}
  220. inline void clear_{{_field.name}}() { {{_field.variable_full_name}} = static_cast<{{_field.type}}>({{_field.default_value}}); }
  221. inline void set_{{_field.name}}(const {{_field.type}}& value) { {{_field.variable_full_name}} = value; }
  222. inline void set_{{_field.name}}(const {{_field.type}}&& value) { {{_field.variable_full_name}} = value; }
  223. {% endif %} inline {{_field.type}} get_{{_field.name}}() const { return {{_field.variable_full_name}}; }
  224. {% else %}
  225. inline {{_field.type}}::FIELD_TYPE {{_field.name}}() const { return {{_field.variable_full_name}}.get(); }
  226. {% if _field.which_oneof is defined %}
  227. inline void clear_{{_field.name}}()
  228. {
  229. if(id::{{_field.variable_id_name}} == {{_field.which_oneof}})
  230. {
  231. {{_field.which_oneof}} = id::NOT_SET;
  232. {{_field.variable_full_name}}.set({{_field.default_value}});
  233. }
  234. }
  235. inline void set_{{_field.name}}(const {{_field.type}}::FIELD_TYPE& value)
  236. {
  237. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  238. {{_field.variable_full_name}}.set(value);
  239. }
  240. inline void set_{{_field.name}}(const {{_field.type}}::FIELD_TYPE&& value)
  241. {
  242. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  243. {{_field.variable_full_name}}.set(value);
  244. }
  245. {% else %}
  246. inline void clear_{{_field.name}}() { {{_field.variable_full_name}}.set({{_field.default_value}}); }
  247. inline void set_{{_field.name}}(const {{_field.type}}::FIELD_TYPE& value) { {{_field.variable_full_name}}.set(value); }
  248. inline void set_{{_field.name}}(const {{_field.type}}::FIELD_TYPE&& value) { {{_field.variable_full_name}}.set(value); }
  249. {% endif %}
  250. inline {{_field.type}}::FIELD_TYPE get_{{_field.name}}() const { return {{_field.variable_full_name}}.get(); }
  251. {% endif %}
  252. {% endmacro %}
  253. {# #}
  254. {# ------------------------------------------------------------------------------------------------------------------ #}
  255. {# #}
  256. {% macro field_serialize_macro(_field) %}
  257. {% if _field.is_repeated_field or _field.is_string or _field.is_bytes %}
  258. if(::EmbeddedProto::Error::NO_ERRORS == return_value)
  259. {
  260. return_value = {{_field.variable_full_name}}.serialize_with_id(static_cast<uint32_t>(id::{{_field.variable_id_name}}), buffer);
  261. }
  262. {% elif _field.of_type_message %}
  263. if(::EmbeddedProto::Error::NO_ERRORS == return_value)
  264. {
  265. return_value = {{_field.variable_full_name}}.serialize_with_id(static_cast<uint32_t>(id::{{_field.variable_id_name}}), buffer);
  266. }
  267. {% elif _field.of_type_enum %}
  268. if(({{_field.default_value}} != {{_field.variable_full_name}}) && (::EmbeddedProto::Error::NO_ERRORS == return_value))
  269. {
  270. EmbeddedProto::uint32 value;
  271. value.set(static_cast<uint32_t>({{_field.variable_full_name}}));
  272. return_value = value.serialize_with_id(static_cast<uint32_t>(id::{{_field.variable_id_name}}), buffer);
  273. }
  274. {% else %}
  275. if(({{_field.default_value}} != {{_field.variable_full_name}}.get()) && (::EmbeddedProto::Error::NO_ERRORS == return_value))
  276. {
  277. return_value = {{_field.variable_full_name}}.serialize_with_id(static_cast<uint32_t>(id::{{_field.variable_id_name}}), buffer);
  278. } {% endif %} {% endmacro %}
  279. {# #}
  280. {# ------------------------------------------------------------------------------------------------------------------ #}
  281. {# #}
  282. {% macro field_deserialize_macro(_field) %}
  283. {% if _field.is_repeated_field %}
  284. if(::EmbeddedProto::WireFormatter::WireType::LENGTH_DELIMITED == wire_type)
  285. {
  286. return_value = {{_field.variable_full_name}}.deserialize(buffer);
  287. }
  288. {% else %}
  289. if(::EmbeddedProto::WireFormatter::WireType::{{_field.wire_type}} == wire_type)
  290. {
  291. {% if _field.of_type_message %}
  292. uint32_t size;
  293. return_value = ::EmbeddedProto::WireFormatter::DeserializeVarint(buffer, size);
  294. ::EmbeddedProto::ReadBufferSection bufferSection(buffer, size);
  295. if(::EmbeddedProto::Error::NO_ERRORS == return_value)
  296. {
  297. return_value = mutable_{{_field.name}}().deserialize(bufferSection);
  298. }
  299. {% elif _field.is_string or _field.is_bytes %}
  300. return_value = mutable_{{_field.name}}().deserialize(buffer);
  301. {% elif _field.of_type_enum %}
  302. uint32_t value;
  303. return_value = ::EmbeddedProto::WireFormatter::DeserializeVarint(buffer, value);
  304. if(::EmbeddedProto::Error::NO_ERRORS == return_value)
  305. {
  306. set_{{_field.name}}(static_cast<{{_field.type}}>(value));
  307. }
  308. {% else %}
  309. return_value = {{_field.variable_full_name}}.deserialize(buffer);
  310. {% endif %}
  311. {% if _field.which_oneof is defined %}
  312. if(::EmbeddedProto::Error::NO_ERRORS == return_value)
  313. {
  314. {{_field.which_oneof}} = id::{{_field.variable_id_name}};
  315. }
  316. {% endif %}
  317. }
  318. {% endif %}
  319. else
  320. {
  321. // Wire type does not match field.
  322. return_value = ::EmbeddedProto::Error::INVALID_WIRETYPE;
  323. } {% endmacro %}
  324. {# #}
  325. {# ------------------------------------------------------------------------------------------------------------------ #}
  326. {# #}
  327. {% macro msg_macro(msg) %}
  328. {% if msg.templates is defined %}
  329. {% for template in msg.templates %}
  330. {{"template<" if loop.first}}{{template['type']}} {{template['name']}}{{", " if not loop.last}}{{">" if loop.last}}
  331. {% endfor %}
  332. {% endif %}
  333. class {{ msg.name }} final: public ::EmbeddedProto::MessageInterface
  334. {
  335. public:
  336. {{ msg.name }}(){% if (msg.has_fields or msg.has_oneofs) %} :
  337. {% endif %}
  338. {% for field in msg.fields() %}
  339. {% if field.of_type_enum %}
  340. {{field.variable_full_name}}({{field.default_value}}){{"," if not loop.last}}
  341. {% else %}
  342. {{field.variable_full_name}}(){{"," if not loop.last}}{{"," if loop.last and msg.has_oneofs}}
  343. {% endif %}
  344. {% endfor %}
  345. {% for oneof in msg.oneofs() %}
  346. {{oneof.which_oneof}}(id::NOT_SET){{"," if not loop.last}}
  347. {% endfor %}
  348. {
  349. };
  350. ~{{ msg.name }}() override = default;
  351. {% for enum in msg.nested_enums() %}
  352. {{ enum_macro(enum) }}
  353. {% endfor %}
  354. enum class id
  355. {
  356. NOT_SET = 0,
  357. {% for id_set in msg.field_ids %}
  358. {{id_set[1]}} = {{id_set[0]}}{{ "," if not loop.last }}
  359. {% endfor %}
  360. };
  361. {{ msg.name }}& operator=(const {{ msg.name }}& rhs)
  362. {
  363. {% for field in msg.fields() %}
  364. set_{{ field.name }}(rhs.get_{{ field.name }}());
  365. {% endfor %}
  366. {% for oneof in msg.oneofs() %}
  367. {{ oneof_assign(oneof)|indent(6) }}
  368. {% endfor %}
  369. return *this;
  370. }
  371. {% for field in msg.fields() %}
  372. {{ field_get_set_macro(field)|indent(4) }}
  373. {% endfor %}
  374. {% for oneof in msg.oneofs() %}
  375. id get_which_{{oneof.name}}() const { return {{oneof.which_oneof}}; }
  376. {% for field in oneof.fields() %}
  377. {{ field_get_set_macro(field)|indent(4) }}
  378. {% endfor %}
  379. {% endfor %}
  380. ::EmbeddedProto::Error serialize(::EmbeddedProto::WriteBufferInterface& buffer) const final
  381. {
  382. ::EmbeddedProto::Error return_value = ::EmbeddedProto::Error::NO_ERRORS;
  383. {% for field in msg.fields() %}
  384. {{ field_serialize_macro(field)|indent(6) }}
  385. {% endfor %}
  386. {% for oneof in msg.oneofs() %}
  387. switch({{oneof.which_oneof}})
  388. {
  389. {% for field in oneof.fields() %}
  390. case id::{{field.variable_id_name}}:
  391. {{ field_serialize_macro(field)|indent(12) }}
  392. break;
  393. {% endfor %}
  394. default:
  395. break;
  396. }
  397. {% endfor %}
  398. return return_value;
  399. };
  400. ::EmbeddedProto::Error deserialize(::EmbeddedProto::ReadBufferInterface& buffer) final
  401. {
  402. ::EmbeddedProto::Error return_value = ::EmbeddedProto::Error::NO_ERRORS;
  403. ::EmbeddedProto::WireFormatter::WireType wire_type;
  404. uint32_t id_number = 0;
  405. ::EmbeddedProto::Error tag_value = ::EmbeddedProto::WireFormatter::DeserializeTag(buffer, wire_type, id_number);
  406. while((::EmbeddedProto::Error::NO_ERRORS == return_value) && (::EmbeddedProto::Error::NO_ERRORS == tag_value))
  407. {
  408. switch(id_number)
  409. {
  410. {% for field in msg.fields() %}
  411. case static_cast<uint32_t>(id::{{field.variable_id_name}}):
  412. {
  413. {{ field_deserialize_macro(field)|indent(12) }}
  414. break;
  415. }
  416. {% endfor %}
  417. {% for oneof in msg.oneofs() %}
  418. {% for field in oneof.fields() %}
  419. case static_cast<uint32_t>(id::{{field.variable_id_name}}):
  420. {
  421. {{ field_deserialize_macro(field)|indent(12) }}
  422. break;
  423. }
  424. {% endfor %}
  425. {% endfor %}
  426. default:
  427. break;
  428. }
  429. if(::EmbeddedProto::Error::NO_ERRORS == return_value)
  430. {
  431. // Read the next tag.
  432. tag_value = ::EmbeddedProto::WireFormatter::DeserializeTag(buffer, wire_type, id_number);
  433. }
  434. }
  435. // When an error was detect while reading the tag but no other errors where found, set it in the return value.
  436. if((::EmbeddedProto::Error::NO_ERRORS == return_value)
  437. && (::EmbeddedProto::Error::NO_ERRORS != tag_value)
  438. && (::EmbeddedProto::Error::END_OF_BUFFER != tag_value)) // The end of the buffer is not an array in this case.
  439. {
  440. return_value = tag_value;
  441. }
  442. return return_value;
  443. };
  444. void clear() final
  445. {
  446. {% for field in msg.fields() %}
  447. clear_{{field.name}}();
  448. {% endfor %}
  449. {% for oneof in msg.oneofs() %}
  450. clear_{{oneof.name}}();
  451. {% endfor %}
  452. }
  453. private:
  454. {% for field in msg.fields() %}
  455. {% if field.is_repeated_field or field.is_string or field.is_bytes %}
  456. {{field.repeated_type}} {{field.variable_name}};
  457. {% else %}
  458. {{field.type}} {{field.variable_name}};
  459. {% endif %}
  460. {% endfor %}
  461. {% for oneof in msg.oneofs() %}
  462. id {{oneof.which_oneof}};
  463. union {{oneof.name}}
  464. {
  465. {{oneof.name}}() {}
  466. ~{{oneof.name}}() {}
  467. {% for field in oneof.fields() %}
  468. {% if field.is_repeated_field or field.is_string or field.is_bytes %}
  469. {{field.repeated_type}} {{field.variable_name}};
  470. {% else %}
  471. {{field.type}} {{field.variable_name}};
  472. {% endif %}
  473. {% endfor %}
  474. };
  475. {{oneof.name}} {{oneof.name}}_;
  476. {{ oneof_init(oneof)|indent(4) }}
  477. {{ oneof_clear(oneof)|indent(4) }}
  478. {% endfor %}
  479. };
  480. {% endmacro %}
  481. {# #}
  482. {# ------------------------------------------------------------------------------------------------------------------ #}
  483. {# #}
  484. /*
  485. * Copyright (C) 2020 Embedded AMS B.V. - All Rights Reserved
  486. *
  487. * This file is part of Embedded Proto.
  488. *
  489. * Embedded Proto is open source software: you can redistribute it and/or
  490. * modify it under the terms of the GNU General Public License as published
  491. * by the Free Software Foundation, version 3 of the license.
  492. *
  493. * Embedded Proto is distributed in the hope that it will be useful,
  494. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  495. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  496. * GNU General Public License for more details.
  497. *
  498. * You should have received a copy of the GNU General Public License
  499. * along with Embedded Proto. If not, see <https://www.gnu.org/licenses/>.
  500. *
  501. * For commercial and closed source application please visit:
  502. * <https://EmbeddedProto.com/license/>.
  503. *
  504. * Embedded AMS B.V.
  505. * Info:
  506. * info at EmbeddedProto dot com
  507. *
  508. * Postal address:
  509. * Johan Huizingalaan 763a
  510. * 1066 VH, Amsterdam
  511. * the Netherlands
  512. */
  513. // This file is generated. Please do not edit!
  514. #ifndef _{{header_guard}}_H_
  515. #define _{{header_guard}}_H_
  516. #include <cstdint>
  517. {% if messages %}
  518. #include <MessageInterface.h>
  519. #include <WireFormatter.h>
  520. #include <Fields.h>
  521. #include <MessageSizeCalculator.h>
  522. #include <ReadBufferSection.h>
  523. #include <RepeatedFieldFixedSize.h>
  524. #include <FieldStringBytes.h>
  525. #include <Errors.h>
  526. {% endif %}
  527. {% if dependencies %}
  528. // Include external proto definitions
  529. {% for dependency in dependencies %}
  530. #include <{{dependency}}>
  531. {% endfor %}
  532. {% endif %}
  533. {% for namespace in namespaces %}
  534. namespace {{ namespace }} {
  535. {% endfor %}
  536. {% for enum in enums %}
  537. {{ enum_macro(enum) }}
  538. {% endfor %}
  539. {% for msg in messages %}
  540. {{ msg_macro(msg) }}
  541. {% endfor %}
  542. {% for namespace in namespaces|reverse %}
  543. } // End of namespace {{ namespace }}
  544. {% endfor %}
  545. #endif // _{{header_guard}}_H_