Fixed typos
[ACE_TAO.git] / ACE / ace / XML_Utils / XMLSchema / Writer.hpp
blob5a12ce2ff2a4e619b580b85cb78c4e609b3ec166
1 // file : XMLSchema/Writer.hpp
2 // author : Boris Kolpackov <boris@dre.vanderbilt.edu>
3 #ifndef XMLSCHEMA_WRITER_HPP
4 #define XMLSCHEMA_WRITER_HPP
6 #include <sstream>
8 #include <ace/XML_Utils/XSCRT/Writer.hpp>
10 #include <ace/XML_Utils/XMLSchema/Types.hpp>
11 #include <ace/XML_Utils/XMLSchema/Traversal.hpp>
13 #include <iostream>
15 namespace XMLSchema
17 namespace Writer
19 template <typename T, typename C>
20 struct FundamentalType : Traversal::Traverser<T>,
21 virtual XSCRT::Writer<C>
23 FundamentalType (XSCRT::XML::Element<C>& e)
24 : XSCRT::Writer<C> (e)
28 using XSCRT::Writer<C>::top_;
29 using XSCRT::Writer<C>::attr_;
31 virtual void
32 traverse (T const& o)
34 using namespace XSCRT::XML;
36 std::basic_ostringstream<C> os;
38 os << o;
40 if (Attribute<C>* a = attr_ ())
42 a->value (os.str ());
44 else
46 top_().value (os.str ());
50 protected:
51 virtual void
52 traverse (T &t)
54 Traversal::Traverser<T>::traverse (t);
57 FundamentalType ()
62 template<typename C>
63 struct FundamentalType <XSCRT::FundamentalType<bool>, C> :
64 Traversal::Traverser<XSCRT::FundamentalType<bool> >,
65 virtual XSCRT::Writer<C>
67 FundamentalType (XSCRT::XML::Element<C> &e)
68 : XSCRT::Writer<C> (e)
72 using XSCRT::Writer<C>::top_;
73 using XSCRT::Writer<C>::attr_;
75 virtual void
76 traverse (XSCRT::FundamentalType<bool> const &o)
78 using namespace XSCRT::XML;
80 std::basic_ostringstream<C> os;
82 if (o)
84 os << "true";
86 else
88 os << "false";
91 if (Attribute<C>* a = attr_ ())
93 a->value (os.str ());
95 else
97 top_().value (os.str ());
101 protected:
102 virtual void
103 traverse (XSCRT::FundamentalType<bool> &t)
105 Traversal::Traverser<XSCRT::FundamentalType<bool> >::traverse (t);
108 FundamentalType ()
114 template <typename C>
115 struct IDREF : Traversal::Traverser<XMLSchema::IDREF<C> >,
116 virtual XSCRT::Writer<C>
118 IDREF (XSCRT::XML::Element<C>& e)
119 : XSCRT::Writer<C> (e)
123 virtual void
124 traverse (
125 typename Traversal::Traverser<XMLSchema::IDREF<C> >::Type const& o)
127 using namespace XSCRT::XML;
129 if (Attribute<C>* a = XSCRT::Writer<C>::attr_ ())
131 a->value (o.id ());
133 else
135 XSCRT::Writer<C>::top_().value (o.id ());
139 protected:
141 virtual void
142 traverse (typename Traversal::Traverser<XMLSchema::IDREF<C> >::Type &o)
144 Traversal::Traverser<XMLSchema::IDREF<C> >::traverse (o);
147 IDREF ()
154 #endif // XMLSCHEMA_WRITER_HPP