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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#include "tao/CORBA_String.h"
#include "tao/String_Manager_T.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_wchar.h"
#include "ace/OS_Memory.h"
// FUZZ: disable check_for_streams_include
#include "ace/streams.h"
#if !defined (__ACE_INLINE__)
# include "tao/CORBA_String.inl"
#endif /* ! __ACE_INLINE__ */
ACE_RCSID (tao,
CORBA_String,
"$Id$")
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
// *************************************************************
// C++ iostream operators for (W)String_var and (W)String_out
// *************************************************************
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
ostream &
operator<< (ostream &os, const CORBA::String_var &sv)
{
os << sv.in ();
return os;
}
istream &
operator>> (istream &is, CORBA::String_var &sv)
{
is.seekg (0, ios::end);
sv = CORBA::string_alloc (is.tellg ());
is.seekg (0, ios::beg);
is >> sv.inout ();
return is;
}
ostream &
operator<< (ostream &os, CORBA::String_out &so)
{
os << so.ptr ();
return os;
}
istream &
operator>> (istream &is, CORBA::String_out &so)
{
is.seekg (0, ios::end);
so = CORBA::string_alloc (is.tellg ());
is.seekg (0, ios::beg);
is >> so.ptr ();
return is;
}
// Until we implement WString support for platforms with a
// 4-byte wchar_t, we just define the following to emit
// the CORBA::WChars one by one.
ostream &
operator<< (ostream &os, const CORBA::WString_var &wsv)
{
CORBA::ULong const len =
static_cast <CORBA::ULong> (ACE_OS::strlen (wsv.in ()));
for (CORBA::ULong i = 0; i < len; ++i)
{
os << wsv[i];
}
return os;
}
istream &
operator>> (istream &is, CORBA::WString_var &wsv)
{
is.seekg (0, ios::end);
// @@ is.tellg()/sizeof(CORBA::WChar) instead?
CORBA::ULong const len = is.tellg ();
wsv = CORBA::wstring_alloc (len);
is.seekg (0, ios::beg);
for (CORBA::ULong i = 0; i < len; ++i)
{
CORBA::WChar wc = 0;
// Unformatted input is used to work around overloaded
// extraction operator (>>) ambiguities on some platforms.
is.read (reinterpret_cast<char *> (&wc), sizeof (wc));
wsv[i] = wc;
}
wsv[len] = 0; // NULL terminate
return is;
}
ostream &
operator<< (ostream &os, CORBA::WString_out &wso)
{
CORBA::WChar *tmp = wso.ptr ();
const size_t len = ACE_OS::strlen (tmp);
for (size_t i = 0; i < len; ++i)
{
os << tmp[i];
}
return os;
}
istream &
operator>> (istream &is, CORBA::WString_out &wso)
{
is.seekg (0, ios::end);
// @@ is.tellg()/sizeof(CORBA::WChar) instead?
const CORBA::ULong len = is.tellg ();
wso = CORBA::wstring_alloc (len);
is.seekg (0, ios::beg);
for (CORBA::ULong i = 0; i < len; ++i)
{
CORBA::WChar wc = 0;
// Unformatted input is used to work around overloaded
// extraction operator (>>) ambiguities on some platforms.
is.read (reinterpret_cast<char *> (&wc), sizeof (wc));
wso.ptr ()[i] = wc;
}
wso.ptr ()[len] = 0; // NULL terminate
return is;
}
#endif /* ACE_LACKS_IOSTREAM_TOTALLY */
TAO_END_VERSIONED_NAMESPACE_DECL
|