aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/hybrid/cdr/qname.cxx
blob: 66b28811299e7fc49ba93776bc4787de798da07b (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
// file      : xsde/cxx/hybrid/cdr/qname.cxx
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#include <xsde/cxx/hybrid/cdr/istream.hxx>
#include <xsde/cxx/hybrid/cdr/ostream.hxx>

namespace xsde
{
  namespace cxx
  {
    namespace hybrid
    {
#ifdef XSDE_EXCEPTIONS

      void
      operator<< (ocdrstream& s, const qname& x)
      {
        s << x.prefix ();
        s << x.name ();
      }

      void
      operator>> (icdrstream& s, qname& x)
      {

#ifdef XSDE_STL
        std::string p, n;
#else
        char* p;
        char* n;
#endif
        s >> p;
        x.prefix (p);

        s >> n; // x will free p in case extraction fails
        x.name (n);
      }

#else // XSDE_EXCEPTIONS

      bool
      operator<< (ocdrstream& s, const qname& x)
      {
        return s << x.prefix () && s << x.name ();
      }

      bool
      operator>> (icdrstream& s, qname& x)
      {

#ifdef XSDE_STL
        std::string p, n;
#else
        char* p;
        char* n;
#endif
        if (!(s >> p))
          return false;

        x.prefix (p);

        if (!(s >> n))
          return false; // x will free p

        x.name (n);
        return true;
      }

#endif // XSDE_EXCEPTIONS
    }
  }
}