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
|
This example shows how to use a custom memory allocator implementation
with the Embedded C++/Hybrid mapping. It is based on the 'minimal' example
(so the support for STL, iostream, and C++ exceptions is disabled) and the
only changes made are to the memory management.
The example consists of the following files:
people.xsd
XML Schema which describes a collection of person records.
people.xml
Sample XML instance document.
people.hxx
people.cxx
people-pskel.hxx
people-pskel.cxx
people-pimpl.hxx
people-pimpl.cxx
people-pskel.hxx
people-pskel.cxx
people-pimpl.hxx
people-pimpl.cxx
Object model (the first pair of files), parser skeletons (the second
pair), parser implementations (the third pair), serializer skeletons
(the fourth pair), and serializer implementations (the fifth pair).
These files are generated by the XSD/e compiler from people.xsd. The
--generate-parser, --generate-serializer, --generate-aggregate,
--no-stl, --no-iostream, and --no-exceptions options were used to
request the generation of the parsing and serialization code as well
as to disable the use of STL, iostream, and C++ exceptions. Furthermore,
the --custom-allocator option was specific to make the generated code
use custom memory management functions instead of the standard new and
delete operators.
arena.hxx
arena.cxx
An implementation of a simple pooled memory allocator.
driver.cxx
Driver for the example. Besides the implementation of the main()
function, this file also provides the implementations of the custom
memory management function, xsde_alloc, xsde_realloc, and xsde_free,
that are used by the XSD/e runtime and the generated code.
The driver first sets up the memory pool using a stack-allocated memory
region. It then calls the parser that constructs the object model from
the input XML file. After that the driver prints the content of the
object model to STDERR. Finally, the driver modifies the object model
and calls the serializer to serialize it back to XML. The implementation
also prints the memory usage statistics after parsing and after
serialization.
To run the example on the sample XML instance document simply execute:
$ ./driver people.xml
The example reads from STDIN if input file is not specified:
$ ./driver <people.xml
|