Code generator for C++ from YAML to generate network protocol parsers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
499 B

4 years ago
4 years ago
  1. <%= @out_type %> get_<%= @name %>(const <%= class_name %>& alter) {
  2. auto ptr = (char*)&alter;
  3. ptr+=<%= @start %>;
  4. return *(<%= @out_type %>*)ptr;
  5. }
  6. void set_<%= @name %>(<%= class_name %>& alter, const <%= @out_type %>& param) {
  7. auto ptr = (char*)&alter;
  8. ptr+=<%= @start %>;
  9. *(<%= @out_type %>*)ptr = param;
  10. }
  11. constexpr size_t <%= @name %>_position() {
  12. return <%= @start %>;
  13. }
  14. constexpr size_t <%= @name %>_end_position() {
  15. return <%= @start %>+sizeof(<%= @out_type %>);
  16. }