blob: 04532665d514ef60a79e9206b7c1288525ff8a34 (
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
// file : XMLSchema/Writer.hpp
// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id : $Id$
#ifndef XMLSCHEMA_WRITER_HPP
#define XMLSCHEMA_WRITER_HPP
#include <sstream>
#include <XSCRT/Writer.hpp>
#include <XMLSchema/Types.hpp>
#include <XMLSchema/Traversal.hpp>
namespace XMLSchema
{
namespace Writer
{
template <typename T, typename C>
struct FundamentalType : Traversal::Traverser<T>,
virtual XSCRT::Writer<C>
{
FundamentalType (XSCRT::XML::Element<C>& e)
: XSCRT::Writer<C> (e)
{
}
using XSCRT::Writer<C>::top_;
using XSCRT::Writer<C>::attr_;
virtual void
traverse (T const& o)
{
using namespace XSCRT::XML;
std::basic_ostringstream<C> os;
os << o;
if (Attribute<C>* a = attr_ ())
{
a->value (os.str ());
}
else
{
top_().value (os.str ());
}
}
protected:
virtual void
traverse (T &t)
{
Traversal::Traverser<T>::traverse (t);
}
FundamentalType ()
{
}
};
template <typename C>
struct IDREF : Traversal::Traverser<XMLSchema::IDREF<C> >,
virtual XSCRT::Writer<C>
{
IDREF (XSCRT::XML::Element<C>& e)
: XSCRT::Writer<C> (e)
{
}
using XSCRT::Writer<C>::top_;
using XSCRT::Writer<C>::attr_;
virtual void
traverse (
typename Traversal::Traverser<XMLSchema::IDREF<C> >::Type const& o)
{
using namespace XSCRT::XML;
if (Attribute<C>* a = attr_ ())
{
a->value (o.id ());
}
else
{
top_().value (o.id ());
}
}
protected:
virtual void
traverse (typename Traversal::Traverser<XMLSchema::IDREF<C> >::Type &o)
{
Traversal::Traverser<XMLSchema::IDREF<C> >::traverse (o);
}
IDREF ()
{
}
};
}
}
#include <XMLSchema/Writer.ipp>
#include <XMLSchema/Writer.tpp>
#endif // XMLSCHEMA_WRITER_HPP
|