aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/serializer/enumeration/driver.cxx
blob: 5eb2f3faee23b57c06d635ffbbb99971fac1616b (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
70
71
72
73
74
75
76
// file      : tests/cxx/serializer/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 enumeration type serialization.
//

#include <iostream>

#include "test-sskel.hxx"

using namespace std;
using namespace test;

struct digit_simpl: digit_sskel
{
  digit_simpl ()
      : digit_sskel (&base_impl_)
  {
  }

private:
  xml_schema::int_simpl base_impl_;
};

struct boolean_simpl: boolean_sskel
{
  boolean_simpl ()
      : boolean_sskel (&base_impl_)
  {
  }

  virtual void
  pre (boolean b)
  {
    int i = b;
    base_impl_.pre (i);
  }

private:
  xml_schema::int_simpl base_impl_;
};

struct root_simpl: root_sskel
{
  virtual int
  digit ()
  {
    return 7;
  }

  virtual ::boolean
  boolean ()
  {
    return TRUE;
  }
};

int
main ()
{
  digit_simpl digit_s;
  boolean_simpl boolean_s;
  root_simpl root_s;

  root_s.serializers (digit_s, boolean_s);

  xml_schema::document_simpl doc_s (root_s, "test", "root");

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

  return 0;
}