blob: f3e388b12cf733e65ece252e366f82381e706bdd (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// file : examples/cxx/tree/performance/driver.cxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : not copyrighted - public domain
#include <string>
#include <sstream>
#include <iostream>
#include <xercesc/util/PlatformUtils.hpp>
using namespace std;
// See parsing.cxx
//
bool
parsing (const char* file, unsigned long iter, bool validate);
// See serialization.cxx
//
bool
serialization (const char* file, unsigned long iter);
int
main (int argc, char* argv[])
{
if (argc < 2)
{
cerr << "usage: " << argv[0] << " [-v] [-i <count>] test.xml" << endl
<< "\t -v turn on validation (default is off)" << endl
<< "\t -i number of iterations to perform (default is 1000)" << endl;
return 1;
}
bool validate (false);
unsigned long iter (1000);
const char* file (0);
// Parse command line arguments.
//
for (int i (1); i < argc; ++i)
{
std::string arg (argv[i]);
if (arg == "-v")
{
validate = true;
}
else if (arg == "-i")
{
if (++i == argc)
{
cerr << "argument expected for the -i option" << endl;
return 1;
}
iter = 0;
istringstream is (argv[i]);
is >> iter;
if (iter == 0)
{
cerr << "invalid argument for the -i option" << endl;
return 1;
}
}
else
{
file = argv[i];
break;
}
}
if (file == 0)
{
cerr << "no input file specified" << endl;
return 1;
}
int r (0);
xercesc::XMLPlatformUtils::Initialize ();
// Call parsing and serialization tests.
//
if (!parsing (file, iter, validate) || !serialization (file, iter))
r = 1;
xercesc::XMLPlatformUtils::Terminate ();
return r;
}
|