summaryrefslogtreecommitdiff
path: root/TAO/tao/CORBA_String.h
blob: 2b384b952b6a24e315ec6ec0e258d38627f069d0 (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
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
// -*- C++ -*-


//=============================================================================
/**
 *  @file    CORBA_String.h
 *
 *  $Id$
 *
 *   Header file for the CORBA string types.
 *
 *
 */
//=============================================================================



#ifndef TAO_CORBA_STRING_H
#define TAO_CORBA_STRING_H

#include "ace/pre.h"

#include "tao/corbafwd.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.
#if defined (ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION)
#include "ace/streams.h"
#endif /* ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION */


/**
 * @class CORBA_String_var
 *
 * @brief CORBA_String var class. Provides automatic deallocation of storage
 * for the string once it goes out of scope.
 */
class TAO_Export CORBA_String_var
{
public:
  /// default constructor.
  CORBA_String_var (void);

  /// constructor, owns p.
  CORBA_String_var (char *p);

  /// constructor. Makes a copy of p.
  CORBA_String_var (const char *p);

  /// copy constructor.
  CORBA_String_var (const CORBA_String_var &s);

  /// destructor.
  ~CORBA_String_var (void);

  /// assignment operator.
  CORBA_String_var &operator= (char *p);

  /// assignment to a const char*.  Makes a copy.
  CORBA_String_var &operator= (const char *p);

  /// assignment operator.
  CORBA_String_var &operator= (const CORBA_String_var &s);

  /// access and modify.
  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);

private:
  /// instance.
  char *ptr_;
};

/**
 * @class CORBA_String_out
 *
 * @brief CORBA_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 CORBA_String_out
{
public:
  // = operations.

  /// Construction from a reference to a string.
  CORBA_String_out (char *&p);

  /// Construction from a var.
  CORBA_String_out (CORBA_String_var &p);

  /// Copy constructor.
  CORBA_String_out (const CORBA_String_out &s);

  /// Assignment from a string_out.
  CORBA_String_out &operator= (const CORBA_String_out &s);

  /// Assignment from a string.
  CORBA_String_out &operator= (char *p);

  /// Assignment from a constant char*.
  CORBA_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 CORBA_WString_var
 *
 * @brief CORBA_WString var class. Provides automatic deallocation of
 * storage for wide strings
 */
class TAO_Export CORBA_WString_var
{
public:
  /// default constructor.
  CORBA_WString_var (void);

  /// constructor, owns p.
  CORBA_WString_var (CORBA::WChar *p);

  /// constructor. Makes a copy of p.
  CORBA_WString_var (const CORBA::WChar *p);

  /// copy constructor.
  CORBA_WString_var (const CORBA_WString_var &s);

  /// destructor.
  ~CORBA_WString_var (void);

  /// assignment operator.
  CORBA_WString_var &operator= (CORBA::WChar *p);

  /// assignment to a const char*.  Makes a copy.
  CORBA_WString_var &operator= (const CORBA::WChar *p);

  /// assignment operator.
  CORBA_WString_var &operator= (const CORBA_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);

private:
  /// instance.
  CORBA::WChar *ptr_;
};

/**
 * @class CORBA_WString_out
 *
 * @brief CORBA_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 CORBA_WString_out
{
public:
  // = operations.

  /// Construction from a reference to a string.
  CORBA_WString_out (CORBA::WChar *&p);

  /// Construction from a var.
  CORBA_WString_out (CORBA_WString_var &p);

  /// Copy constructor.
  CORBA_WString_out (const CORBA_WString_out &s);

  /// Assignment from a string_out.
  CORBA_WString_out &operator= (const CORBA_WString_out &s);

  /// Assignment from a string.
  CORBA_WString_out &operator= (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 &);
};

# 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 */

#if defined (__ACE_INLINE__)
# include "tao/CORBA_String.inl"
#endif /* ! __ACE_INLINE__ */


#include "ace/post.h"

#endif  /* TAO_CORBA_STRING_H */