FieldMsg_Deserialize.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {#
  2. Copyright (C) 2020 Embedded AMS B.V. - All Rights Reserved
  3. This file is part of Embedded Proto.
  4. Embedded Proto is open source software: you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation, version 3 of the license.
  7. Embedded Proto is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with Embedded Proto. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial and closed source application please visit:
  14. <https://EmbeddedProto.com/license/>.
  15. Embedded AMS B.V.
  16. Info:
  17. info at EmbeddedProto dot com
  18. Postal address:
  19. Johan Huizingalaan 763a
  20. 1066 VH, Amsterdam
  21. the Netherlands
  22. #}
  23. if(::EmbeddedProto::WireFormatter::WireType::{{field.get_wire_type_str()}} == wire_type)
  24. {
  25. uint32_t size;
  26. return_value = ::EmbeddedProto::WireFormatter::DeserializeVarint(buffer, size);
  27. ::EmbeddedProto::ReadBufferSection bufferSection(buffer, size);
  28. if(::EmbeddedProto::Error::NO_ERRORS == return_value)
  29. {
  30. return_value = mutable_{{field.get_name()}}().deserialize(bufferSection);
  31. }
  32. {% if field.oneof is not none %}
  33. if(::EmbeddedProto::Error::NO_ERRORS != return_value)
  34. {
  35. clear_{{field.get_name()}}();
  36. }
  37. {% endif %}
  38. }
  39. else
  40. {
  41. // Wire type does not match field.
  42. return_value = ::EmbeddedProto::Error::INVALID_WIRETYPE;
  43. }