aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/hybrid/polymorphism/enumeration/driver.cxx
blob: 721c2f3682de58db4a4665de558133ab1d0b1a95 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// file      : tests/cxx/hybrid/polymorphism/enumeration/driver.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2006-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

// Test XML Schema enumeration to C++ enum mapping.
//

#include <iostream>

#include "test.hxx"
#include "test-pimpl.hxx"
#include "test-simpl.hxx"

using namespace std;
using namespace test;

int
main (int argc, char* argv[])
{
  if (argc != 2)
  {
    cerr << "usage: " << argv[0] << " test.xml" << endl;
    return 1;
  }

  // Parse.
  //
  root_paggr root_p;

  xml_schema::document_pimpl doc_p (
    root_p.root_parser (),
    root_p.root_namespace (),
    root_p.root_name (),
    true);

  root_p.pre ();
  doc_p.parse (argv[1]);
  type* r = root_p.post ();

  // Test the mapping.
  //
  simple s (simple::a);
  s.value (simple::b);

  complex c;
  c.value (complex::a);

  // Serialize.
  //
  root_saggr root_s;

  xml_schema::document_simpl doc_s (
    root_s.root_serializer (),
    root_s.root_namespace (),
    root_s.root_name (),
    true);

  doc_s.add_prefix ("t", "test");
  doc_s.add_prefix ("xsi", "http://www.w3.org/2001/XMLSchema-instance");

  root_s.pre (*r);
  doc_s.serialize (cout);
  root_s.post ();

  delete r;

  return 0;
}