3 //=============================================================================
7 * @author Carlos O'Ryan
10 //=============================================================================
15 #include /**/ "ace/pre.h"
17 #include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
24 #include "tao/Pseudo_VarOut_T.h"
25 #include "tao/Arg_Traits_T.h"
26 #include "tao/Object.h"
28 #include "ace/CDR_Stream.h"
30 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
45 typedef TypeCode
*TypeCode_ptr
;
48 typedef AbstractBase
*AbstractBase_ptr
;
56 * @brief Generic container for IDL types.
58 * This is the top-level class of the Any implementation. It exposes the
59 * spec-required functionality, but is mostly a wrapper for one of the
60 * template classes below.
62 class TAO_AnyTypeCode_Export Any
65 typedef Any_ptr _ptr_type
;
66 typedef Any_var _var_type
;
67 typedef Any_out _out_type
;
74 Any
&operator= (const Any
&);
75 TAO::Any_Impl
*impl () const;
77 /// Used in our destruction if we ourselves are stored in an Any.
78 static void _tao_any_destructor (void *);
80 /// These are needed for insertion and extraction of booleans,
81 /// octets, chars, and bounded strings. CORBA spec requires
82 /// that they be here, we just typedef to the already-defined
83 /// ACE_OutputCDR types.
85 typedef ACE_OutputCDR::from_boolean from_boolean
;
86 typedef ACE_OutputCDR::from_octet from_octet
;
87 typedef ACE_OutputCDR::from_char from_char
;
88 typedef ACE_OutputCDR::from_wchar from_wchar
;
89 typedef ACE_OutputCDR::from_string from_string
;
90 typedef ACE_OutputCDR::from_wstring from_wstring
;
92 /// Insertion of the special types.
94 void operator<<= (from_boolean
);
95 void operator<<= (from_char
);
96 void operator<<= (from_wchar
);
97 void operator<<= (from_octet
);
98 void operator<<= (from_string
);
99 void operator<<= (from_wstring
);
101 /// These extract octets, chars, booleans, bounded strings, and
102 /// object references. All these are defined in ACE_InputCDR.
104 typedef ACE_InputCDR::to_boolean to_boolean
;
105 typedef ACE_InputCDR::to_char to_char
;
106 typedef ACE_InputCDR::to_wchar to_wchar
;
107 typedef ACE_InputCDR::to_octet to_octet
;
108 typedef ACE_InputCDR::to_string to_string
;
109 typedef ACE_InputCDR::to_wstring to_wstring
;
111 /// These are not in ACE.
113 struct TAO_AnyTypeCode_Export to_object
115 // This signature reflects the change set out in
116 // issue 154 of the 1.3 RTF.
117 explicit to_object (Object_out obj
);
121 struct TAO_AnyTypeCode_Export to_abstract_base
123 explicit to_abstract_base (AbstractBase_ptr
&obj
);
124 AbstractBase_ptr
&ref_
;
127 struct TAO_AnyTypeCode_Export to_value
129 explicit to_value (ValueBase
*&base
);
133 /// Extraction of the special types.
135 Boolean
operator>>= (to_boolean
) const;
136 Boolean
operator>>= (to_octet
) const;
137 Boolean
operator>>= (to_char
) const;
138 Boolean
operator>>= (to_wchar
) const;
139 Boolean
operator>>= (to_string
) const;
140 Boolean
operator>>= (to_wstring
) const;
141 Boolean
operator>>= (to_object
) const;
142 Boolean
operator>>= (to_abstract_base
) const;
143 Boolean
operator>>= (to_value
) const;
145 /// TAO-specific signature.
146 void replace (TAO::Any_Impl
*);
148 /// Return TypeCode of the element stored in the Any.
149 TypeCode_ptr
type () const;
151 /// For use along with <<= of a value of aliased type when the alias must
153 void type (TypeCode_ptr
);
155 /// TAO extension, does not return a duplicate.
156 CORBA::TypeCode_ptr
_tao_get_typecode () const;
159 void _tao_set_typecode (const CORBA::TypeCode_ptr
);
161 int _tao_byte_order () const;
164 CORBA::Boolean
checked_to_object (CORBA::Object_ptr
&) const;
165 CORBA::Boolean
checked_to_value (CORBA::ValueBase
*&) const;
166 CORBA::Boolean
checked_to_abstract_base (CORBA::AbstractBase_ptr
&) const;
168 // Unimplemented - hides unsigned char insert/extract.
169 void operator<<= (unsigned char);
170 CORBA::Boolean
operator>>= (unsigned char&) const;
173 TAO::Any_Impl
*impl_
{};
175 friend class TAO_Marshal_Any
;
179 * @class CORBA::Any_var
181 * @brief Provide for automatic storage deallocation on going out of
184 class TAO_AnyTypeCode_Export Any_var
189 Any_var (const Any_var
&);
192 Any_var
&operator= (Any
*);
195 * Assignment from an Any_var
196 * This operation requires memory allocation.
197 * If the allocation fails, *this is returned
200 Any_var
&operator= (const Any_var
&);
202 /// Arrow operator (smart pointer).
206 operator const Any
*() const;
211 /// For in Any parameter.
212 const Any
&in () const;
214 /// For inout Any parameter.
217 /// For out Any parameter.
220 /// For Any return type.
223 /// TAO specific extension
231 * @class CORBA::Any_out
233 * @brief CORBA::Any_out
235 * The _out class for CORBA::Any. This is used to help in
236 * managing the out parameters.
238 class TAO_AnyTypeCode_Export Any_out
243 Any_out (const Any_out
&);
245 /// Assignment from a Any_out.
246 Any_out
&operator= (const Any_out
&s
);
248 /// Assignment from a Any.
249 Any_out
&operator= (Any
*);
254 /// Return underlying instance.
260 /// Assignment from _var disallowed.
261 void operator= (const Any_var
&);
269 TAO_AnyTypeCode_Export
CORBA::Boolean
270 operator<< (TAO_OutputCDR
&, const CORBA::Any
&);
272 TAO_AnyTypeCode_Export
CORBA::Boolean
273 operator>> (TAO_InputCDR
&, CORBA::Any
&);
275 #if defined (GEN_OSTREAM_OPS)
277 // Used in optionally generated ostream operators (for debugging).
278 TAO_AnyTypeCode_Export
std::ostream
&
279 operator<< (std::ostream
&, const CORBA::Any
&);
281 #endif /* GEN_OSTREAM_OPS */
285 /// Typesafe insertion.
287 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::Short
);
288 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::UShort
);
289 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::Long
);
290 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::ULong
);
291 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::LongLong
);
292 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::ULongLong
);
293 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::Float
);
294 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::Double
);
295 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::LongDouble
);
296 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, const CORBA::Any
&);
297 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::Any
*);
298 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, const char *);
299 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, const CORBA::WChar
*);
300 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::TypeCode_ptr
);
301 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::TypeCode_ptr
*);
302 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, const CORBA::Object_ptr
);
303 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, CORBA::Object_ptr
*);
304 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, const std::string
&);
305 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, std::string
*);
306 #if !defined(ACE_LACKS_STD_WSTRING)
307 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, const std::wstring
&);
308 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any
&, std::wstring
*);
311 /// Typesafe extraction.
313 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
315 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
317 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
319 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
321 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
323 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
325 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
327 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
329 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
330 CORBA::LongDouble
&);
331 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
332 const CORBA::Any
*&);
333 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
334 CORBA::TypeCode_ptr
&);
335 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
336 const CORBA::Char
*&);
337 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
338 const CORBA::WChar
*&);
339 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
341 #if !defined(ACE_LACKS_STD_WSTRING)
342 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any
&,
348 TAO_END_VERSIONED_NAMESPACE_DECL
350 #if defined (__ACE_INLINE__)
351 # include "tao/AnyTypeCode/Any.inl"
354 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
358 /// Copying versions of insertion operators for basic types
359 /// must also be defined for CORBA::Any_var.
361 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Short
);
362 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::UShort
);
363 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Long
);
364 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::ULong
);
365 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::LongLong
);
366 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::ULongLong
);
367 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Float
);
368 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Double
);
369 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, const CORBA::Any
*&);
370 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, const char *);
371 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::TypeCode_ptr
);
372 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, const CORBA::Object_ptr
);
373 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, ACE_OutputCDR::from_boolean
);
374 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Any::from_char
);
375 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Any::from_wchar
);
376 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Any::from_octet
);
377 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Any::from_string
);
378 TAO_AnyTypeCode_Export
void operator<<= (CORBA::Any_var
&, CORBA::Any::from_wstring
);
380 /// These are not required by the spec, but will make users
381 /// of other ORBs that are used to them more comfortable.
383 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
385 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
387 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
389 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
391 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
393 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
395 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
397 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
399 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
401 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
402 CORBA::TypeCode_ptr
&);
403 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
405 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
406 const CORBA::WChar
*&);
407 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
408 CORBA::Any::to_boolean
);
409 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
410 CORBA::Any::to_octet
);
411 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
412 CORBA::Any::to_char
);
413 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
414 CORBA::Any::to_wchar
);
415 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
416 CORBA::Any::to_string
);
417 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
418 CORBA::Any::to_wstring
);
419 TAO_AnyTypeCode_Export
CORBA::Boolean
operator>>= (const CORBA::Any_var
&,
420 CORBA::Any::to_object
);
423 TAO_END_VERSIONED_NAMESPACE_DECL
425 #endif /* __ACE_INLINE__ */
427 #include /**/ "ace/post.h"
429 #endif /* TAO_ANY_H */