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.
 
 

57 lines
1.4 KiB

class <%= @name %> {
virtual ~<%= @name %>() = 0;
public:
<% if !(@attributes.nil?) %>
<%- @attributes.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
<% if !(@attributeafters.nil?) %>
<%- @attributeafters.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
<% if !(@bitfields.nil?) %>
<%- @bitfields.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
<% if !(@repeats.nil?) %>
<%- @repeats.not_nil!.each do |attr| -%>
<%- attr.class_name = @name -%>
<%-= attr.to_s %>
<%- end -%>
<% end %>
private:
void dummy_function()
{
<% if !@size.nil? %>
<%- sz = @size.not_nil! -%>
<% if !(@attributes.nil?) %>
<%- @attributes.not_nil!.each do |attr|-%>
<%- if attr.start > sz -%>
<%- raise "attribute starts after end: "+attr.name+" in class "+@name -%>
<%- end -%>
static_assert(<%= attr.name %>_end_position()<=<%= sz%>, "attribute past the end");
<%- end -%>
<%- end -%>
<% if !(@bitfields.nil?) %>
<%- @bitfields.not_nil!.each do |attr|-%>
<%- if attr.start > sz -%>
<%- raise "bitfield starts after end: "+attr.name+" in class "+@name -%>
<%- end -%>
static_assert(<%= attr.name %>_end_position()<=<%= sz%>, "attribute past the end");
<%- end -%>
<%- end -%>
<% end %>
}
};