summaryrefslogtreecommitdiff
path: root/qpid/cpp/rubygen/0-10/exceptions.rb
blob: 4f7080690f7e3432b890425d24806cd413246684 (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
30
31
32
33
34
35
#!/usr/bin/env ruby
$: << ".."                      # Include .. in load path
require 'cppgen'

class GenExceptions < CppGen

  def initialize(outdir, amqp)
    super(outdir, amqp)
    @ns="qpid::amqp_#{@amqp.version.bars}"
    @dir="qpid/amqp_#{@amqp.version.bars}"
  end

  def gen_exceptions()
    h_file("#{@dir}/exceptions") { 
      include "qpid/Exception"
      include "specification.h"
      namespace("#{@ns}") { 
        @amqp.class_("execution").domain("error-code").enum.choices.each { |c|
          name=c.name.typename+"Exception"
          struct(name, "public SessionException") {
            genl "#{name}(const std::string& msg=std::string()) : SessionException(execution::#{c.name.shout}, msg) {}"
          }
        }
      }
    }
  end
  
  def generate()
    gen_exceptions
  end
end

GenExceptions.new($outdir, $amqp).generate();