summaryrefslogtreecommitdiff
path: root/cpp/rubygen/templates/ClassBodyVariant.rb
blob: dce14c5652eeb081b4f15caf70d41ef4843885ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env ruby
$: << ".."                      # Include .. in load path
require 'cppgen'

class ClassBodyVariant < CppGen
  
  def initialize(outdir, amqp)
    super(outdir, amqp)
  end

  def class_body(c)
    h_file (c.body_name) { 
      c.amqp_methods.each { |m| genl "#include \"#{m.body_name}.h\""; }
      genl
      genl "#include <boost/visitor.hpp>"
      genl
      gen "typedef boost::variant<"
      indent { genl c.amqp_methods().collect { |m| m.body_name }.join(",\n") }
      genl ">  #{c.body_name};"
    }
  end

  def generate()
    @amqp.amqp_classes.each{ |c| class_body c }
  end
end

ClassBodyVariant.new(Outdir, Amqp).generate();