Revision 111, 1.3 kB
(checked in by mido, 16 years ago)
|
pridana knihovna XSD (a jeji chlebodarkyne XERCES), v ramci Win32 zprovoznen priklad tests/test_xsd_hello.cxx
|
Line | |
---|
1 | // file : examples/cxx/parser/hello/driver.cxx |
---|
2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
---|
3 | // copyright : not copyrighted - public domain |
---|
4 | |
---|
5 | #include <string> |
---|
6 | #include <iostream> |
---|
7 | |
---|
8 | #include "hello-pskel.hxx" |
---|
9 | |
---|
10 | using namespace std; |
---|
11 | |
---|
12 | struct hello_pimpl: hello_pskel |
---|
13 | { |
---|
14 | virtual void |
---|
15 | greeting (const string& greeting) |
---|
16 | { |
---|
17 | greeting_ = greeting; |
---|
18 | } |
---|
19 | |
---|
20 | virtual void |
---|
21 | name (const string& name) |
---|
22 | { |
---|
23 | cout << greeting_ << ", " << name << "!" << endl; |
---|
24 | } |
---|
25 | |
---|
26 | private: |
---|
27 | string greeting_; |
---|
28 | }; |
---|
29 | |
---|
30 | int |
---|
31 | main (int argc, char* argv[]) |
---|
32 | { |
---|
33 | if (argc != 2) |
---|
34 | { |
---|
35 | cerr << "usage: " << argv[0] << " hello.xml" << endl; |
---|
36 | return 1; |
---|
37 | } |
---|
38 | |
---|
39 | try |
---|
40 | { |
---|
41 | // Construct the parser. |
---|
42 | // |
---|
43 | xml_schema::string_pimpl string_p; |
---|
44 | hello_pimpl hello_p; |
---|
45 | |
---|
46 | hello_p.greeting_parser (string_p); |
---|
47 | hello_p.name_parser (string_p); |
---|
48 | |
---|
49 | // Parse the XML instance document. The second argument to the |
---|
50 | // document's constructor is the document's root element name. |
---|
51 | // |
---|
52 | xml_schema::document doc_p (hello_p, "hello"); |
---|
53 | |
---|
54 | hello_p.pre (); |
---|
55 | doc_p.parse (argv[1]); |
---|
56 | hello_p.post_hello (); |
---|
57 | } |
---|
58 | catch (const xml_schema::exception& e) |
---|
59 | { |
---|
60 | cerr << e << endl; |
---|
61 | return 1; |
---|
62 | } |
---|
63 | catch (const std::ios_base::failure&) |
---|
64 | { |
---|
65 | cerr << argv[1] << ": unable to open or read failure" << endl; |
---|
66 | return 1; |
---|
67 | } |
---|
68 | } |
---|