summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/serialization/boolean.hxx
blob: 90978c4cb4b7e2aefb93a36f5795d72c42a61108 (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
// file      : xsd/cxx/tree/serialization/boolean.hxx
// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef XSD_CXX_TREE_SERIALIZATION_BOOLEAN_HXX
#define XSD_CXX_TREE_SERIALIZATION_BOOLEAN_HXX

#include <sstream>

namespace XERCES_CPP_NAMESPACE
{
  inline void
  operator<< (xercesc::DOMElement& e, bool b)
  {
    std::basic_ostringstream<char> os;
    os.setf (std::ios_base::boolalpha);
    os << b;
    e << os.str ();
  }

  inline void
  operator<< (xercesc::DOMAttr& a, bool b)
  {
    std::basic_ostringstream<char> os;
    os.setf (std::ios_base::boolalpha);
    os << b;
    a << os.str ();
  }
}

namespace xsd
{
  namespace cxx
  {
    namespace tree
    {
      template <typename C>
      inline void
      operator<< (list_stream<C>& ls, bool b)
      {
        // We don't need to restore the original bool format flag
        // since items in the list are all of the same type.
        //
        ls.os_.setf (std::ios_base::boolalpha);
        ls.os_ << b;
      }
    }
  }
}

#endif // XSD_CXX_TREE_SERIALIZATION_BOOLEAN_HXX