1 // file      : tests/cxx/parser/list/driver.cxx
2 // copyright : Copyright (c) 2006-2017 Code Synthesis Tools CC
3 // license   : GNU GPL v2 + exceptions; see accompanying LICENSE file
4 
5 // Test xsd:list parsing.
6 //
7 
8 #include <string>
9 #include <iostream>
10 
11 #include "test-pskel.hxx"
12 
13 using namespace std;
14 using namespace test;
15 
16 struct string_list_pimpl: string_list_pskel
17 {
18   virtual void
prestring_list_pimpl19   pre ()
20   {
21     cout << "{" << endl;
22   }
23 
24   virtual void
itemstring_list_pimpl25   item (string const& v)
26   {
27     cout << "  '" << v << "'" << endl;
28   }
29 
30   virtual void
post_string_liststring_list_pimpl31   post_string_list ()
32   {
33     cout << "}" << endl
34          << endl;
35   }
36 };
37 
38 struct string_list_lang_pimpl: string_list_lang_pskel
39 {
40   virtual void
prestring_list_lang_pimpl41   pre ()
42   {
43     cout << "{" << endl;
44   }
45 
46   virtual void
itemstring_list_lang_pimpl47   item (string const& v)
48   {
49     cout << "  '" << v << "'" << endl;
50   }
51 
52   virtual void
langstring_list_lang_pimpl53   lang (string const& v)
54   {
55     cout << "  lang: '" << v << "'" << endl;
56   }
57 
58   virtual void
post_string_list_langstring_list_lang_pimpl59   post_string_list_lang ()
60   {
61     cout << "}" << endl
62          << endl;
63   }
64 };
65 
66 struct type_pimpl: type_pskel
67 {
68 };
69 
70 int
main(int argc,char * argv[])71 main (int argc, char* argv[])
72 {
73   if (argc != 2)
74   {
75     cerr << "usage: " << argv[0] << " test.xml" << endl;
76     return 1;
77   }
78 
79   try
80   {
81     xml_schema::string_pimpl string_p;
82     string_list_pimpl string_list_p;
83     string_list_lang_pimpl string_list_lang_p;
84     type_pimpl type_p;
85 
86     string_list_p.parsers (string_p);
87     string_list_lang_p.parsers (string_p, string_p);
88     type_p.parsers (string_list_p, string_list_lang_p);
89 
90     xml_schema::document doc_p (type_p, "test", "root");
91 
92     type_p.pre ();
93     doc_p.parse (argv[1]);
94     type_p.post_type ();
95   }
96   catch (xml_schema::exception const& e)
97   {
98     cerr << e << endl;
99     return 1;
100   }
101   catch (ios_base::failure const&)
102   {
103     cerr << "io failure" << endl;
104     return 1;
105   }
106 }
107