1 #include "tao/CORBA_String.h"
2 #include "tao/String_Manager_T.h"
4 #include "ace/OS_NS_string.h"
5 #include "ace/OS_NS_wchar.h"
6 #include "ace/OS_Memory.h"
8 // FUZZ: disable check_for_streams_include
9 #include "ace/streams.h"
11 #if !defined (__ACE_INLINE__)
12 # include "tao/CORBA_String.inl"
13 #endif /* ! __ACE_INLINE__ */
15 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
17 // *************************************************************
18 // C++ iostream operators for (W)String_var and (W)String_out
19 // *************************************************************
21 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
24 operator<< (ostream
&os
, const CORBA::String_var
&sv
)
31 operator>> (istream
&is
, CORBA::String_var
&sv
)
33 is
.seekg (0, ios::end
);
34 std::streamsize
const n
= is
.tellg ();
35 sv
= CORBA::string_alloc (static_cast<CORBA::ULong
> (n
));
36 is
.seekg (0, ios::beg
);
37 is
.read (sv
.inout (), n
);
42 operator<< (ostream
&os
, CORBA::String_out
&so
)
49 operator>> (istream
&is
, CORBA::String_out
&so
)
51 is
.seekg (0, ios::end
);
52 std::streamsize
const n
= is
.tellg ();
53 so
= CORBA::string_alloc (static_cast<CORBA::ULong
> (n
));
54 is
.seekg (0, ios::beg
);
55 is
.read (so
.ptr (), n
);
61 // Until we implement WString support for platforms with a
62 // 4-byte wchar_t, we just define the following to emit
63 // the CORBA::WChars one by one.
66 operator<< (ostream
&os
, const CORBA::WString_var
&wsv
)
68 CORBA::ULong
const len
=
69 static_cast <CORBA::ULong
> (ACE_OS::strlen (wsv
.in ()));
71 for (CORBA::ULong i
= 0; i
< len
; ++i
)
80 operator>> (istream
&is
, CORBA::WString_var
&wsv
)
82 is
.seekg (0, ios::end
);
83 // @@ is.tellg()/sizeof(CORBA::WChar) instead?
84 CORBA::ULong
const len
= static_cast<CORBA::ULong
> (is
.tellg ());
85 wsv
= CORBA::wstring_alloc (len
);
86 is
.seekg (0, ios::beg
);
88 for (CORBA::ULong i
= 0; i
< len
; ++i
)
92 // Unformatted input is used to work around overloaded
93 // extraction operator (>>) ambiguities on some platforms.
94 is
.read (reinterpret_cast<char *> (&wc
), sizeof (wc
));
99 wsv
[len
] = 0; // NULL terminate
105 operator<< (ostream
&os
, CORBA::WString_out
&wso
)
107 CORBA::WChar
*tmp
= wso
.ptr ();
108 const size_t len
= ACE_OS::strlen (tmp
);
110 for (size_t i
= 0; i
< len
; ++i
)
119 operator>> (istream
&is
, CORBA::WString_out
&wso
)
121 is
.seekg (0, ios::end
);
122 // @@ is.tellg()/sizeof(CORBA::WChar) instead?
123 const CORBA::ULong len
= static_cast<CORBA::ULong
> (is
.tellg ());
124 wso
= CORBA::wstring_alloc (len
);
125 is
.seekg (0, ios::beg
);
127 for (CORBA::ULong i
= 0; i
< len
; ++i
)
131 // Unformatted input is used to work around overloaded
132 // extraction operator (>>) ambiguities on some platforms.
133 is
.read (reinterpret_cast<char *> (&wc
), sizeof (wc
));
138 wso
.ptr ()[len
] = 0; // NULL terminate
143 #endif /* ACE_HAS_CPP20 */
145 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
147 TAO_END_VERSIONED_NAMESPACE_DECL