1 | // file : xsd/cxx/tree/stream-insertion.hxx |
---|
2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
---|
3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
---|
4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
---|
5 | |
---|
6 | #ifndef XSD_CXX_TREE_STREAM_INSERTION_HXX |
---|
7 | #define XSD_CXX_TREE_STREAM_INSERTION_HXX |
---|
8 | |
---|
9 | #include <xsd/cxx/tree/elements.hxx> |
---|
10 | #include <xsd/cxx/tree/types.hxx> |
---|
11 | #include <xsd/cxx/tree/list.hxx> |
---|
12 | |
---|
13 | #include <xsd/cxx/tree/ostream.hxx> |
---|
14 | |
---|
15 | namespace xsd |
---|
16 | { |
---|
17 | namespace cxx |
---|
18 | { |
---|
19 | namespace tree |
---|
20 | { |
---|
21 | // type |
---|
22 | // |
---|
23 | template <typename S> |
---|
24 | inline ostream<S>& |
---|
25 | operator<< (ostream<S>& s, const type&) |
---|
26 | { |
---|
27 | return s; |
---|
28 | } |
---|
29 | |
---|
30 | // simple_type |
---|
31 | // |
---|
32 | template <typename S, typename B> |
---|
33 | inline ostream<S>& |
---|
34 | operator<< (ostream<S>& s, const simple_type<B>&) |
---|
35 | { |
---|
36 | return s; |
---|
37 | } |
---|
38 | |
---|
39 | // fundamental_base |
---|
40 | // |
---|
41 | template <typename S, typename X, typename C, typename B> |
---|
42 | inline ostream<S>& |
---|
43 | operator<< (ostream<S>& s, const fundamental_base<X, C, B>& x) |
---|
44 | { |
---|
45 | const X& r (x); |
---|
46 | return s << r; |
---|
47 | } |
---|
48 | |
---|
49 | // list |
---|
50 | // |
---|
51 | template <typename S, typename X, typename C, bool fund> |
---|
52 | ostream<S>& |
---|
53 | operator<< (ostream<S>& s, const list<X, C, fund>& x) |
---|
54 | { |
---|
55 | s << ostream_common::as_size<std::size_t> (x.size ()); |
---|
56 | |
---|
57 | for (typename list<X, C, fund>::const_iterator |
---|
58 | i (x.begin ()), e (x.end ()); i != e; ++i) |
---|
59 | { |
---|
60 | s << *i; |
---|
61 | } |
---|
62 | |
---|
63 | return s; |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | // Insertion operators for built-in types. |
---|
68 | // |
---|
69 | |
---|
70 | |
---|
71 | // string |
---|
72 | // |
---|
73 | template <typename S, typename C, typename B> |
---|
74 | inline ostream<S>& |
---|
75 | operator<< (ostream<S>& s, const string<C, B>& x) |
---|
76 | { |
---|
77 | const std::basic_string<C>& r (x); |
---|
78 | return s << r; |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | // normalized_string |
---|
83 | // |
---|
84 | template <typename S, typename C, typename B> |
---|
85 | inline ostream<S>& |
---|
86 | operator<< (ostream<S>& s, const normalized_string<C, B>& x) |
---|
87 | { |
---|
88 | const B& r (x); |
---|
89 | return s << r; |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | // token |
---|
94 | // |
---|
95 | template <typename S, typename C, typename B> |
---|
96 | inline ostream<S>& |
---|
97 | operator<< (ostream<S>& s, const token<C, B>& x) |
---|
98 | { |
---|
99 | const B& r (x); |
---|
100 | return s << r; |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | // nmtoken |
---|
105 | // |
---|
106 | template <typename S, typename C, typename B> |
---|
107 | inline ostream<S>& |
---|
108 | operator<< (ostream<S>& s, const nmtoken<C, B>& x) |
---|
109 | { |
---|
110 | const B& r (x); |
---|
111 | return s << r; |
---|
112 | } |
---|
113 | |
---|
114 | |
---|
115 | // nmtokens |
---|
116 | // |
---|
117 | template <typename S, typename C, typename B, typename nmtoken> |
---|
118 | inline ostream<S>& |
---|
119 | operator<< (ostream<S>& s, const nmtokens<C, B, nmtoken>& x) |
---|
120 | { |
---|
121 | const list<nmtoken, C>& r (x); |
---|
122 | return s << r; |
---|
123 | } |
---|
124 | |
---|
125 | |
---|
126 | // name |
---|
127 | // |
---|
128 | template <typename S, typename C, typename B> |
---|
129 | inline ostream<S>& |
---|
130 | operator<< (ostream<S>& s, const name<C, B>& x) |
---|
131 | { |
---|
132 | const B& r (x); |
---|
133 | return s << r; |
---|
134 | } |
---|
135 | |
---|
136 | |
---|
137 | // ncname |
---|
138 | // |
---|
139 | template <typename S, typename C, typename B> |
---|
140 | inline ostream<S>& |
---|
141 | operator<< (ostream<S>& s, const ncname<C, B>& x) |
---|
142 | { |
---|
143 | const B& r (x); |
---|
144 | return s << r; |
---|
145 | } |
---|
146 | |
---|
147 | |
---|
148 | // language |
---|
149 | // |
---|
150 | template <typename S, typename C, typename B> |
---|
151 | inline ostream<S>& |
---|
152 | operator<< (ostream<S>& s, const language<C, B>& x) |
---|
153 | { |
---|
154 | const std::basic_string<C>& r (x); |
---|
155 | return s << r; |
---|
156 | } |
---|
157 | |
---|
158 | |
---|
159 | // id |
---|
160 | // |
---|
161 | template <typename S, typename C, typename B> |
---|
162 | inline ostream<S>& |
---|
163 | operator<< (ostream<S>& s, const id<C, B>& x) |
---|
164 | { |
---|
165 | const std::basic_string<C>& r (x); |
---|
166 | return s << r; |
---|
167 | } |
---|
168 | |
---|
169 | |
---|
170 | // idref |
---|
171 | // |
---|
172 | template <typename S, typename X, typename C, typename B> |
---|
173 | inline ostream<S>& |
---|
174 | operator<< (ostream<S>& s, const idref<X, C, B>& x) |
---|
175 | { |
---|
176 | const B& r (x); |
---|
177 | return s << r; |
---|
178 | } |
---|
179 | |
---|
180 | |
---|
181 | // idrefs |
---|
182 | // |
---|
183 | template <typename S, typename C, typename B, typename idref> |
---|
184 | inline ostream<S>& |
---|
185 | operator<< (ostream<S>& s, const idrefs<C, B, idref>& x) |
---|
186 | { |
---|
187 | const list<idref, C>& r (x); |
---|
188 | return s << r; |
---|
189 | } |
---|
190 | |
---|
191 | |
---|
192 | // uri |
---|
193 | // |
---|
194 | template <typename S, typename C, typename B> |
---|
195 | inline ostream<S>& |
---|
196 | operator<< (ostream<S>& s, const uri<C, B>& x) |
---|
197 | { |
---|
198 | const std::basic_string<C>& r (x); |
---|
199 | return s << r; |
---|
200 | } |
---|
201 | |
---|
202 | |
---|
203 | // qname |
---|
204 | // |
---|
205 | template <typename S, |
---|
206 | typename C, |
---|
207 | typename B, |
---|
208 | typename uri, |
---|
209 | typename ncname> |
---|
210 | inline ostream<S>& |
---|
211 | operator<< (ostream<S>& s, const qname<C, B, uri, ncname>& x) |
---|
212 | { |
---|
213 | return s << x.namespace_ () << x.name (); |
---|
214 | } |
---|
215 | |
---|
216 | |
---|
217 | // base64_binary |
---|
218 | // |
---|
219 | template <typename S, typename C, typename B> |
---|
220 | inline ostream<S>& |
---|
221 | operator<< (ostream<S>& s, const base64_binary<C, B>& x) |
---|
222 | { |
---|
223 | const buffer<C>& r (x); |
---|
224 | return s << r; |
---|
225 | } |
---|
226 | |
---|
227 | |
---|
228 | // hex_binary |
---|
229 | // |
---|
230 | template <typename S, typename C, typename B> |
---|
231 | inline ostream<S>& |
---|
232 | operator<< (ostream<S>& s, const hex_binary<C, B>& x) |
---|
233 | { |
---|
234 | const buffer<C>& r (x); |
---|
235 | return s << r; |
---|
236 | } |
---|
237 | |
---|
238 | |
---|
239 | // entity |
---|
240 | // |
---|
241 | template <typename S, typename C, typename B> |
---|
242 | inline ostream<S>& |
---|
243 | operator<< (ostream<S>& s, const entity<C, B>& x) |
---|
244 | { |
---|
245 | const B& r (x); |
---|
246 | return s << r; |
---|
247 | } |
---|
248 | |
---|
249 | |
---|
250 | // entities |
---|
251 | // |
---|
252 | template <typename S, typename C, typename B, typename entity> |
---|
253 | inline ostream<S>& |
---|
254 | operator<< (ostream<S>& s, const entities<C, B, entity>& x) |
---|
255 | { |
---|
256 | const list<entity, C>& r (x); |
---|
257 | return s << r; |
---|
258 | } |
---|
259 | } |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | #include <xsd/cxx/tree/date-time-insertion.txx> |
---|
264 | |
---|
265 | #endif // XSD_CXX_TREE_STREAM_INSERTION_HXX |
---|