summaryrefslogtreecommitdiff
path: root/TAO/tao/CORBA_String.h
blob: 34e32cd352ff092175d00ea101b88a7289c9b545 (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
// -*- C++ -*-
//
// $Id$


// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    CORBA_String.h
//
// = DESCRIPTION
//     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 TAO_Export CORBA_String_var
{
  // = TITLE
  //   CORBA_String var class. Provides automatic deallocation of storage
  //   for the string once it goes out of scope.
public:
  CORBA_String_var (void);
  // default constructor.

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

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

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

  ~CORBA_String_var (void);
  // destructor.

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

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

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

  operator char *();
  // access and modify.

  operator const char *() const;
  // only read privileges.

  char &operator[] (CORBA::ULong slot);
  // allows access and modification using an slot.

  char operator[] (CORBA::ULong slot) const;
  // allows only accessing thru an slot.

    // = in, out, out, and _retn operations.
    // ORBOS/97-05-15, Appendix C.2

  const char *in (void) const;
  // for in parameter.

  char *&inout (void);
  // for inout parameter.

  char *&out (void);
  // for out parameter.

  char *_retn (void);
  // for string of return type.

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

class TAO_Export CORBA_String_out
{
  // = TITLE
  //   CORBA_String_out
  //
  // = DESCRIPTION
  //   To support the memory management for "out" parameter passing
  //   mode.  ORBOS/97-05-15, Appendix C.2 defines a CORBA_String_out class
public:
  // = operations.

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

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

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

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

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

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

  operator char *&();
  // Cast.

  char *&ptr (void);
  // Return underlying instance.

private:
  char *&ptr_;
  // Instance.

  // assignment from _var disallowed
  void operator= (const CORBA_String_var &);
};

// ****************************************************************

class TAO_Export CORBA_WString_var
{
  // = TITLE
  //   CORBA_WString var class. Provides automatic deallocation of
  //   storage for wide strings
  //
public:
  CORBA_WString_var (void);
  // default constructor.

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

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

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

  ~CORBA_WString_var (void);
  // destructor.

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

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

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

  operator CORBA::WChar *();
  // access and modify.

  operator const CORBA::WChar *() const;
  // only read privileges.

  CORBA::WChar &operator[] (CORBA::ULong slot);
  // allows access and modification using an slot.

  CORBA::WChar operator[] (CORBA::ULong slot) const;
  // allows only accessing thru an slot.

    // = in, out, out, and _retn operations.
    // ORBOS/97-05-15, Appendix C.2

  const CORBA::WChar *in (void) const;
  // for in parameter.

  CORBA::WChar *&inout (void);
  // for inout parameter.

  CORBA::WChar *&out (void);
  // for out parameter.

  CORBA::WChar *_retn (void);
  // for string of return type.

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

class TAO_Export CORBA_WString_out
{
  // = TITLE
  //   CORBA_WString_out
  //
  // = DESCRIPTION
  //   To support the memory management for "out" parameter passing
  //   mode.  ORBOS/97-05-15, Appendix C.2 defines a CORBA_WString_out
  //   class
  //
public:
  // = operations.

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

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

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

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

  CORBA_WString_out &operator= (CORBA::WChar *p);
  // Assignment from a string.

  operator CORBA::WChar *&();
  // Cast.

  CORBA::WChar *&ptr (void);
  // Return underlying instance.

private:
  CORBA::WChar *&ptr_;
  // Instance.

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