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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
// -*- C++ -*-
//=============================================================================
/**
* @file CORBA_String.h
*
* $Id$
*
* Header file for the CORBA string types.
*
* @author DOC Group at Wash U, UCI, and Vanderbilt U.
*/
//=============================================================================
#ifndef TAO_CORBA_STRING_H
#define TAO_CORBA_STRING_H
#include /**/ "ace/pre.h"
#include "tao/TAO_Export.h"
#include "tao/Basic_Types.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
// For the (W)String_var and (W)String_out iostream operators.
#include "ace/iosfwd.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
class TAO_String_Manager;
class TAO_WString_Manager;
namespace CORBA
{
/**
* @name CORBA String Memory Management
*
* CORBA string memory management functions.
*/
//@{
TAO_Export char * string_alloc (ULong len);
TAO_Export char * string_dup (const char *);
TAO_Export void string_free (char *);
//@}
/**
* @name CORBA Wide String Memory Management
*
* CORBA wide string memory management functions.
*/
//@{
TAO_Export WChar * wstring_alloc (ULong len);
TAO_Export WChar * wstring_dup (const WChar * const);
TAO_Export void wstring_free (WChar * const);
//@}
/**
* @class String_var
*
* @brief CORBA::String var class.
*
* Provides automatic deallocation of storage for the string once it
* goes out of scope.
*/
class TAO_Export String_var
{
public:
/// Default constructor.
String_var (void);
/// Constructor, owns p.
String_var (char *p);
/// constructor. Makes a copy of p.
String_var (const char *p);
/// copy constructor.
String_var (const String_var &s);
/// destructor.
~String_var (void);
/// assignment operator.
String_var &operator= (char *p);
/// assignment to a const char*. Makes a copy.
String_var &operator= (const char *p);
/// assignment operator.
String_var &operator= (const String_var &s);
/// Spec-defined read/write version.
operator char *&();
/// only read privileges.
operator const char *() const;
/// allows access and modification using an slot.
char &operator[] (CORBA::ULong slot);
/// allows only accessing thru an slot.
char operator[] (CORBA::ULong slot) const;
// = in, out, out, and _retn operations.
// ORBOS/97-05-15, Appendix C.2
/// for in parameter.
const char *in (void) const;
/// for inout parameter.
char *&inout (void);
/// for out parameter.
char *&out (void);
/// for string of return type.
char *_retn (void);
/// TAO extension.
char *ptr (void);
private:
/// instance.
char *ptr_;
};
/**
* @class String_out
*
* @brief String_out
*
* To support the memory management for "out" parameter passing
* mode. ORBOS/97-05-15, Appendix C.2 defines a CORBA::String_out
* class
*/
class TAO_Export String_out
{
public:
/// Construction from a reference to a string.
String_out (char *&p);
/// Construction from a var.
String_out (CORBA::String_var &p);
/// Construction from a TAO_String_Manager.
String_out (TAO_String_Manager &p);
/// Copy constructor.
String_out (const String_out &s);
/// Assignment from a string_out.
String_out &operator= (const String_out &s);
/// Assignment from a string.
String_out &operator= (char *p);
/// Assignment from a constant char*.
String_out& operator= (const char* p);
/// Cast.
operator char *&();
/// Return underlying instance.
char *&ptr (void);
private:
/// Instance.
char *&ptr_;
// assignment from _var disallowed
void operator= (const CORBA::String_var &);
};
// ****************************************************************
/**
* @class WString_var
*
* @brief CORBA::WString var class.
*
* Provides automatic deallocation of storage for wide strings.
*/
class TAO_Export WString_var
{
public:
/// default constructor.
WString_var (void);
/// constructor, owns p.
WString_var (CORBA::WChar *p);
/// constructor. Makes a copy of p.
WString_var (const CORBA::WChar *p);
/// copy constructor.
WString_var (const WString_var &s);
/// destructor.
~WString_var (void);
/// assignment operator.
WString_var &operator= (CORBA::WChar *p);
/// assignment to a const char*. Makes a copy.
WString_var &operator= (const CORBA::WChar *p);
/// assignment operator.
WString_var &operator= (const WString_var &s);
/// access and modify.
operator CORBA::WChar *&();
/// only read privileges.
operator const CORBA::WChar *() const;
/// allows access and modification using an slot.
CORBA::WChar &operator[] (CORBA::ULong slot);
/// allows only accessing thru an slot.
CORBA::WChar operator[] (CORBA::ULong slot) const;
// = in, out, out, and _retn operations.
// ORBOS/97-05-15, Appendix C.2
/// for in parameter.
const CORBA::WChar *in (void) const;
/// for inout parameter.
CORBA::WChar *&inout (void);
/// for out parameter.
CORBA::WChar *&out (void);
/// for string of return type.
CORBA::WChar *_retn (void);
/// TAO extension.
CORBA::WChar *ptr (void);
private:
/// instance.
CORBA::WChar *ptr_;
};
/**
* @class WString_out
*
* @brief WString_out
*
* To support the memory management for "out" parameter passing
* mode. ORBOS/97-05-15, Appendix C.2 defines a CORBA::WString_out
* class.
*/
class TAO_Export WString_out
{
public:
/// Construction from a reference to a string.
WString_out (CORBA::WChar *&p);
/// Construction from a var.
WString_out (CORBA::WString_var &p);
/// Construction from a TAO_WString_Manager.
WString_out (TAO_WString_Manager &p);
/// Copy constructor.
WString_out (const WString_out &s);
/// Assignment from a string_out.
WString_out &operator= (const WString_out &s);
/// Assignment from a string.
WString_out &operator= (CORBA::WChar *p);
/// Assignment from a constant CORBA::WChar*.
WString_out& operator= (const CORBA::WChar *p);
/// Cast.
operator CORBA::WChar *&();
/// Return underlying instance.
CORBA::WChar *&ptr (void);
private:
/// Instance.
CORBA::WChar *&ptr_;
// assignment from _var disallowed
void operator= (const CORBA::WString_var &);
};
} // End CORBA namespace.
namespace TAO
{
/**
* @struct TAO-specific @c {W}String_var Equality Functor
*
* This functor exist to simplify usage of @c {W}String_var in
* containers.
*/
struct String_Var_Equal_To
{
bool operator() (CORBA::String_var const & lhs,
CORBA::String_var const & rhs) const;
bool operator() (CORBA::WString_var const & lhs,
CORBA::WString_var const & rhs) const;
};
}
# if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
TAO_Export ostream &
operator<< (ostream &, const CORBA::String_var &);
TAO_Export istream &
operator>> (istream &, CORBA::String_var &);
TAO_Export ostream &
operator<< (ostream &, CORBA::String_out &);
TAO_Export istream &
operator>> (istream &, CORBA::String_out &);
TAO_Export ostream &
operator<< (ostream &, const CORBA::WString_var &);
TAO_Export istream &
operator>> (istream &, CORBA::WString_var &);
TAO_Export ostream &
operator<< (ostream &, CORBA::WString_out &);
TAO_Export istream &
operator>> (istream &, CORBA::WString_out &);
# endif /* ACE_LACKS_IOSTREAM_TOTALLY */
TAO_END_VERSIONED_NAMESPACE_DECL
#if defined (__ACE_INLINE__)
# include "tao/CORBA_String.inl"
#endif /* ! __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* TAO_CORBA_STRING_H */
|