3 //=============================================================================
7 * $Id: CDR_Stream.h 82350 2008-07-22 07:36:47Z johnnyw $
9 * ACE Common Data Representation (CDR) marshaling and demarshaling
12 * This implementation was inspired in the CDR class in SunSoft's
13 * IIOP engine, but has a completely different implementation and a
14 * different interface too.
16 * The current implementation assumes that the host has 1-byte,
17 * 2-byte and 4-byte integral types, and that it has single
18 * precision and double precision IEEE floats.
19 * Those assumptions are pretty good these days, with Crays being
20 * the only known exception.
24 * ACE_LACKS_CDR_ALIGNMENT
25 * @author Arvind S. Krishna <arvindk@dre.vanderbilt.edu>
27 * CDR stream ignores alignment when marshaling data. Use this option
28 * only when ACE_DISABLE_SWAP_ON_READ can be enabled. This option requires
29 * ACE CDR engine to do both marshaling and demarshaling.
32 * @author TAO version by Aniruddha Gokhale <gokhale@cs.wustl.edu>
33 * @author Carlos O'Ryan <coryan@cs.wustl.edu>
34 * @author ACE version by Jeff Parsons <parsons@cs.wustl.edu>
35 * @author Istvan Buki <istvan.buki@euronet.be>
36 * @author Codeset translation by Jim Rogers <jrogers@viasoft.com>
38 //=============================================================================
40 #ifndef ACE_CDR_STREAM_H
41 #define ACE_CDR_STREAM_H
43 #include /**/ "ace/pre.h"
45 #include "ace/CDR_Base.h"
47 #if !defined (ACE_LACKS_PRAGMA_ONCE)
49 #endif /* ACE_LACKS_PRAGMA_ONCE */
51 #include "ace/SStringfwd.h"
52 #include "ace/Message_Block.h"
54 #if defined (GEN_OSTREAM_OPS)
55 #include "ace/streams.h"
56 #endif /* GEN_OSTREAM_OPS */
58 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
59 #include "Monitor_Size.h"
60 #endif /* ACE_HAS_MONITOR_POINTS==1 */
63 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
65 class ACE_Char_Codeset_Translator
;
66 class ACE_WChar_Codeset_Translator
;
71 * @class ACE_OutputCDR
73 * @brief A CDR stream for marshalling data, most often for transmission to
74 * another system which may or may not have the same byte order.
76 * This class is based on the the CORBA spec for Java (98-02-29),
77 * java class omg.org.CORBA.portable.OutputStream. It diverts in
79 * @li Operations taking arrays don't have offsets, because in C++
80 * it is easier to describe an array starting from x+offset.
81 * @li Operations return an error status, because exceptions are
82 * not widely available in C++ (yet).
84 class ACE_Export ACE_OutputCDR
88 * The Codeset translators need access to some private members to
89 * efficiently marshal arrays
90 * For reading from an output CDR stream.
92 friend class ACE_Char_Codeset_Translator
;
93 friend class ACE_WChar_Codeset_Translator
;
94 friend class ACE_InputCDR
;
97 * Default constructor; allows one to set byte ordering, allocators, and
100 * @param size Causes constructor to preallocate @a size bytes; if
101 * @a size is 0 it allocates the default size.
103 * @param byte_order The byte order that data will have within this
104 * object. Unless otherwise specified, the byte order
105 * will be the order native to the hardware this is
106 * executed on. To force the marshalled data to have
107 * a specific order, specify one of the values defined
108 * in ACE_CDR::Byte_Order.
109 * @note The @c ACE_ENABLE_SWAP_ON_WRITE config macro
110 * must be set for any local byte swapping to occur
111 * as data is inserted into an ACE_OutputCDR object.
113 ACE_OutputCDR (size_t size
= 0,
114 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
115 ACE_Allocator
* buffer_allocator
= 0,
116 ACE_Allocator
* data_block_allocator
= 0,
117 ACE_Allocator
* message_block_allocator
= 0,
118 size_t memcpy_tradeoff
= ACE_DEFAULT_CDR_MEMCPY_TRADEOFF
,
119 ACE_CDR::Octet major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
120 ACE_CDR::Octet minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
122 /// Build a CDR stream with an initial buffer, it will *not* remove
123 /// <data>, since it did not allocated it. It's important to be careful
124 /// with the alignment of <data>.
126 * Create an output stream from an arbitrary buffer, care must be
127 * exercised with alignment, because this contructor will align if
128 * needed. In this case @a data will not point to the start of the
129 * output stream. @c begin()->rd_ptr() points to the start of the
130 * output stream. See @c ACE_ptr_align_binary() to properly align a
131 * pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment.
133 ACE_OutputCDR (char *data
,
135 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
136 ACE_Allocator
* buffer_allocator
= 0,
137 ACE_Allocator
* data_block_allocator
= 0,
138 ACE_Allocator
* message_block_allocator
= 0,
139 size_t memcpy_tradeoff
= ACE_DEFAULT_CDR_MEMCPY_TRADEOFF
,
140 ACE_CDR::Octet giop_major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
141 ACE_CDR::Octet giop_minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
143 /// Build a CDR stream with an initial data block, it will *not* remove
144 /// <data_block>, since it did not allocated it. It's important to be
145 // careful with the alignment of <data_block>.
147 * Create an output stream from an arbitrary data block, care must be
148 * exercised with alignment, because this contructor will align if
149 * needed. In this case @a data_block will not point to the
150 * start of the output stream. begin()->rd_ptr() points to the start
151 * off the output stream. See ACE_ptr_align_binary() to properly align a
152 * pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment.
154 ACE_OutputCDR (ACE_Data_Block
*data_block
,
155 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
156 ACE_Allocator
* message_block_allocator
= 0,
157 size_t memcpy_tradeoff
= ACE_DEFAULT_CDR_MEMCPY_TRADEOFF
,
158 ACE_CDR::Octet giop_major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
159 ACE_CDR::Octet giop_minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
161 /// Build a CDR stream with an initial Message_Block chain, it will
162 /// *not* remove @a data, since it did not allocate it.
163 ACE_OutputCDR (ACE_Message_Block
*data
,
164 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
165 size_t memcpy_tradeoff
= ACE_DEFAULT_CDR_MEMCPY_TRADEOFF
,
166 ACE_CDR::Octet giop_major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
167 ACE_CDR::Octet giop_minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
170 ~ACE_OutputCDR (void);
173 * Disambiguate overload when inserting booleans, octets, chars, and
176 //@{ @name Helper classes
178 struct ACE_Export from_boolean
180 explicit from_boolean (ACE_CDR::Boolean b
);
181 ACE_CDR::Boolean val_
;
184 struct ACE_Export from_octet
186 explicit from_octet (ACE_CDR::Octet o
);
190 struct ACE_Export from_char
192 explicit from_char (ACE_CDR::Char c
);
196 struct ACE_Export from_wchar
198 explicit from_wchar (ACE_CDR::WChar wc
);
202 struct ACE_Export from_string
204 from_string (ACE_CDR::Char
* s
,
206 ACE_CDR::Boolean nocopy
= 0);
207 from_string (const ACE_CDR::Char
* s
,
209 ACE_CDR::Boolean nocopy
= 0);
211 ACE_CDR::ULong bound_
;
212 ACE_CDR::Boolean nocopy_
;
215 struct ACE_Export from_wstring
217 from_wstring (ACE_CDR::WChar
* ws
,
219 ACE_CDR::Boolean nocopy
= 0);
220 from_wstring (const ACE_CDR::WChar
* ws
,
222 ACE_CDR::Boolean nocopy
= 0);
223 ACE_CDR::WChar
*val_
;
224 ACE_CDR::ULong bound_
;
225 ACE_CDR::Boolean nocopy_
;
230 * @{ @name Write operations
231 * Return 0 on failure and 1 on success.
233 ACE_CDR::Boolean
write_boolean (ACE_CDR::Boolean x
);
234 ACE_CDR::Boolean
write_char (ACE_CDR::Char x
);
235 ACE_CDR::Boolean
write_wchar (ACE_CDR::WChar x
);
236 ACE_CDR::Boolean
write_octet (ACE_CDR::Octet x
);
237 ACE_CDR::Boolean
write_short (ACE_CDR::Short x
);
238 ACE_CDR::Boolean
write_ushort (ACE_CDR::UShort x
);
239 ACE_CDR::Boolean
write_long (ACE_CDR::Long x
);
240 ACE_CDR::Boolean
write_ulong (ACE_CDR::ULong x
);
241 ACE_CDR::Boolean
write_longlong (const ACE_CDR::LongLong
&x
);
242 ACE_CDR::Boolean
write_ulonglong (const ACE_CDR::ULongLong
&x
);
243 ACE_CDR::Boolean
write_float (ACE_CDR::Float x
);
244 ACE_CDR::Boolean
write_double (const ACE_CDR::Double
&x
);
245 ACE_CDR::Boolean
write_longdouble (const ACE_CDR::LongDouble
&x
);
247 /// For string we offer methods that accept a precomputed length.
248 ACE_CDR::Boolean
write_string (const ACE_CDR::Char
*x
);
249 ACE_CDR::Boolean
write_string (ACE_CDR::ULong len
,
250 const ACE_CDR::Char
*x
);
251 ACE_CDR::Boolean
write_string (const ACE_CString
&x
);
252 ACE_CDR::Boolean
write_wstring (const ACE_CDR::WChar
*x
);
253 ACE_CDR::Boolean
write_wstring (ACE_CDR::ULong length
,
254 const ACE_CDR::WChar
*x
);
257 /// @note the portion written starts at <x> and ends
259 /// The length is *NOT* stored into the CDR stream.
260 //@{ @name Array write operations
261 ACE_CDR::Boolean
write_boolean_array (const ACE_CDR::Boolean
*x
,
262 ACE_CDR::ULong length
);
263 ACE_CDR::Boolean
write_char_array (const ACE_CDR::Char
*x
,
264 ACE_CDR::ULong length
);
265 ACE_CDR::Boolean
write_wchar_array (const ACE_CDR::WChar
* x
,
266 ACE_CDR::ULong length
);
267 ACE_CDR::Boolean
write_octet_array (const ACE_CDR::Octet
* x
,
268 ACE_CDR::ULong length
);
269 ACE_CDR::Boolean
write_short_array (const ACE_CDR::Short
*x
,
270 ACE_CDR::ULong length
);
271 ACE_CDR::Boolean
write_ushort_array (const ACE_CDR::UShort
*x
,
272 ACE_CDR::ULong length
);
273 ACE_CDR::Boolean
write_long_array (const ACE_CDR::Long
*x
,
274 ACE_CDR::ULong length
);
275 ACE_CDR::Boolean
write_ulong_array (const ACE_CDR::ULong
*x
,
276 ACE_CDR::ULong length
);
277 ACE_CDR::Boolean
write_longlong_array (const ACE_CDR::LongLong
* x
,
278 ACE_CDR::ULong length
);
279 ACE_CDR::Boolean
write_ulonglong_array (const ACE_CDR::ULongLong
*x
,
280 ACE_CDR::ULong length
);
281 ACE_CDR::Boolean
write_float_array (const ACE_CDR::Float
*x
,
282 ACE_CDR::ULong length
);
283 ACE_CDR::Boolean
write_double_array (const ACE_CDR::Double
*x
,
284 ACE_CDR::ULong length
);
285 ACE_CDR::Boolean
write_longdouble_array (const ACE_CDR::LongDouble
* x
,
286 ACE_CDR::ULong length
);
288 /// Write an octet array contained inside a MB, this can be optimized
289 /// to minimize copies.
290 ACE_CDR::Boolean
write_octet_array_mb (const ACE_Message_Block
* mb
);
294 * @{ @name Placeholder/replace operations
295 * Facilitates writing a placeholder into a CDR stream to be replaced
296 * later with a different value.
298 * @note An example use for this facility is:
301 ... // insert values...
302 char *pos = strm.write_long_placeholder ();
303 ... // insert more values
304 ACE_CDR::Long real_val; // Somehow assign the "correct" value
305 strm.replace (real_val, pos); // Replace earlier placeholder
310 * Write a placeholder into the stream. The placeholder's pointer
311 * is returned so it may later be passed as the @a loc argument to
313 * These methods align the stream's write pointer properly prior to
314 * writing the placeholder.
316 * @retval Pointer to the placeholder; 0 if there is not enough space
317 * in the stream and memory could not be allocated.
319 char* write_long_placeholder (void);
320 char* write_short_placeholder (void);
323 * Writes a new value into a specific location. This is commonly
324 * used to update a prior "placeholder" location in the stream.
325 * The specified location is assumed to have proper CDR alignment for the
326 * type to insert. This requirement is satisfied by using one of the
327 * placeholder-writing methods to align the stream for the anticipated
328 * value and obtain the correct location.
329 * Treatment of @a x with repect to byte swapping is the same as for when
330 * any value is inserted.
332 * @param x The value to insert into the specified location.
333 * @param loc The location at which to insert @a x. @a loc must be a valid
334 * position within the stream's current set of message blocks.
336 * @sa write_long_placeholder(), write_short_placeholder ()
338 ACE_CDR::Boolean
replace (ACE_CDR::Long x
, char* loc
);
339 ACE_CDR::Boolean
replace (ACE_CDR::Short x
, char* loc
);
343 * Return 0 on failure and 1 on success.
345 //@{ @name Append contents of own CDR stream to another
346 ACE_CDR::Boolean
append_boolean (ACE_InputCDR
&);
347 ACE_CDR::Boolean
append_char (ACE_InputCDR
&);
348 ACE_CDR::Boolean
append_wchar (ACE_InputCDR
&);
349 ACE_CDR::Boolean
append_octet (ACE_InputCDR
&);
350 ACE_CDR::Boolean
append_short (ACE_InputCDR
&);
351 ACE_CDR::Boolean
append_ushort (ACE_InputCDR
&);
352 ACE_CDR::Boolean
append_long (ACE_InputCDR
&);
353 ACE_CDR::Boolean
append_ulong (ACE_InputCDR
&);
354 ACE_CDR::Boolean
append_longlong (ACE_InputCDR
&);
355 ACE_CDR::Boolean
append_ulonglong (ACE_InputCDR
&);
356 ACE_CDR::Boolean
append_float (ACE_InputCDR
&);
357 ACE_CDR::Boolean
append_double (ACE_InputCDR
&);
358 ACE_CDR::Boolean
append_longdouble (ACE_InputCDR
&);
360 ACE_CDR::Boolean
append_wstring (ACE_InputCDR
&);
361 ACE_CDR::Boolean
append_string (ACE_InputCDR
&);
364 /// Returns @c false if an error has ocurred.
366 * @note The only expected error is to run out of memory.
368 bool good_bit (void) const;
370 /// Reuse the CDR stream to write on the old buffer.
373 /// Add the length of each message block in the chain.
374 size_t total_length (void) const;
377 * Return the start of the message block chain for this CDR stream.
378 * @note The complete CDR stream is represented by a chain of
381 const ACE_Message_Block
*begin (void) const;
383 /// Return the last message in the chain that is is use.
384 const ACE_Message_Block
*end (void) const;
386 /// Return the <current_> message block in chain.
387 const ACE_Message_Block
*current (void) const;
389 /// Replace the message block chain with a single message block.
391 * Upon successful completion, there will be a single message block
392 * containing the data from the complete message block chain.
394 * @note The only expected error is to run out of memory.
396 int consolidate (void);
399 * Access the underlying buffer (read only). @note This
400 * method only returns a pointer to the first block in the
403 const char *buffer (void) const;
406 * Return the size of first message block in the block chain. @note This
407 * method only returns information about the first block in the
410 size_t length (void) const;
413 * Utility function to allow the user more flexibility.
414 * Pads the stream up to the nearest <alignment>-byte boundary.
415 * Argument MUST be a power of 2.
416 * Returns 0 on success and -1 on failure.
418 int align_write_ptr (size_t alignment
);
420 /// Access the codeset translators. They can be null!
421 ACE_Char_Codeset_Translator
*char_translator (void) const;
422 ACE_WChar_Codeset_Translator
*wchar_translator (void) const;
424 /// Set the char codeset translator.
425 void char_translator (ACE_Char_Codeset_Translator
*);
426 /// Set the wchar codeset translator.
427 void wchar_translator (ACE_WChar_Codeset_Translator
*);
429 /// set the global size of serialized wchars. This may be different
430 /// than the size of a wchar_t.
431 static void wchar_maxbytes (size_t max_bytes
);
433 /// access the serialized size of wchars.
434 static size_t wchar_maxbytes (void);
437 * Return alignment of the wr_ptr(), with respect to the start of
438 * the CDR stream. This is not the same as the alignment of
441 size_t current_alignment (void) const;
443 void current_alignment (size_t current_alignment
);
446 * Returns (in @a buf) the next position in the buffer aligned to
447 * @a size, it advances the Message_Block wr_ptr past the data
448 * (i.e., @a buf + @a size). If necessary it grows the Message_Block
449 * buffer. Sets the good_bit to false and returns a -1 on failure.
451 int adjust (size_t size
,
454 /// As above, but now the size and alignment requirements may be
456 int adjust (size_t size
,
460 /// Returns true if this stream is writing in non-native byte order
461 /// and false otherwise. For example, it would be true if either
462 /// ACE_ENABLE_SWAP_ON_WRITE is defined or a specific byte order was
463 /// specified for this stream.
464 bool do_byte_swap (void) const;
466 /// Returns the byte order this stream is marshaling data in. Will be one
467 /// of the values in ACE_CDR::Byte_Order.
468 int byte_order (void) const;
470 /// For use by a gateway, which creates the output stream for the
471 /// reply to the client in its native byte order, but which must
472 /// send the reply in the byte order of the target's reply to the
474 void reset_byte_order (int byte_order
);
476 /// set GIOP version info
477 void set_version (ACE_CDR::Octet major
, ACE_CDR::Octet minor
);
479 /// Set the underlying GIOP version..
480 void get_version (ACE_CDR::Octet
&major
, ACE_CDR::Octet
&minor
);
482 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
483 /// Register and unregister our buffer size monitor.
484 void register_monitor (const char* id
);
485 void unregister_monitor (void);
486 #endif /* ACE_HAS_MONITOR_POINTS==1 */
490 // Find the message block in the chain of message blocks
491 // that the provide location locates.
492 ACE_Message_Block
* find (char* loc
);
494 /// disallow copying...
495 ACE_OutputCDR (const ACE_OutputCDR
& rhs
);
496 ACE_OutputCDR
& operator= (const ACE_OutputCDR
& rhs
);
498 ACE_CDR::Boolean
write_1 (const ACE_CDR::Octet
*x
);
499 ACE_CDR::Boolean
write_2 (const ACE_CDR::UShort
*x
);
500 ACE_CDR::Boolean
write_4 (const ACE_CDR::ULong
*x
);
501 ACE_CDR::Boolean
write_8 (const ACE_CDR::ULongLong
*x
);
502 ACE_CDR::Boolean
write_16 (const ACE_CDR::LongDouble
*x
);
505 * write an array of @a length elements, each of @a size bytes and the
506 * start aligned at a multiple of <align>. The elements are assumed
507 * to be packed with the right alignment restrictions. It is mostly
508 * designed for buffers of the basic types.
510 * This operation uses <memcpy>; as explained above it is expected
511 * that using assignment is faster that <memcpy> for one element,
512 * but for several elements <memcpy> should be more efficient, it
513 * could be interesting to find the break even point and optimize
514 * for that case, but that would be too platform dependent.
516 ACE_CDR::Boolean
write_array (const void *x
,
519 ACE_CDR::ULong length
);
522 ACE_CDR::Boolean
write_wchar_array_i (const ACE_CDR::WChar
* x
,
523 ACE_CDR::ULong length
);
527 * Grow the CDR stream. When it returns @a buf contains a pointer to
528 * memory in the CDR stream, with at least @a size bytes ahead of it
529 * and aligned to an <align> boundary. It moved the <wr_ptr> to <buf
532 int grow_and_adjust (size_t size
,
537 /// The start of the chain of message blocks.
538 ACE_Message_Block start_
;
540 /// The current block in the chain where we are writing.
541 ACE_Message_Block
*current_
;
543 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
545 * The current alignment as measured from the start of the buffer.
546 * Usually this coincides with the alignment of the buffer in
547 * memory, but, when we chain another buffer this "quasi invariant"
549 * The current_alignment is used to readjust the buffer following
550 * the stolen message block.
552 size_t current_alignment_
;
553 #endif /* ACE_LACKS_CDR_ALIGNMENT */
556 * Is the current block writable. When we steal a buffer from the
557 * user and just chain it into the message block we are not supposed
558 * to write on it, even if it is past the start and end of the
561 bool current_is_writable_
;
564 * If not zero swap bytes at writing so the created CDR stream byte
565 * order does *not* match the machine byte order. The motivation
566 * for such a beast is that in some setting a few (fast) machines
567 * can be serving hundreds of slow machines with the opposite byte
568 * order, so it makes sense (as a load balancing device) to put the
569 * responsibility in the writers. THIS IS NOT A STANDARD IN CORBA,
570 * USE AT YOUR OWN RISK
574 /// Set to false when an error ocurrs.
577 /// Break-even point for copying.
578 size_t const memcpy_tradeoff_
;
580 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
581 ACE::Monitor_Control::Size_Monitor
*monitor_
;
582 #endif /* ACE_HAS_MONITOR_POINTS==1 */
585 /// GIOP version information
586 ACE_CDR::Octet major_version_
;
587 ACE_CDR::Octet minor_version_
;
589 /// If not nil, invoke for translation of character and string data.
590 ACE_Char_Codeset_Translator
*char_translator_
;
591 ACE_WChar_Codeset_Translator
*wchar_translator_
;
594 * Some wide char codesets may be defined with a maximum number
595 * of bytes that is smaller than the size of a wchar_t. This means
596 * that the CDR cannot simply memcpy a block of wchars to and from
597 * the stream, but must instead realign the bytes appropriately.
598 * In cases when wchar i/o is not allowed, such as with GIOP 1.0,
599 * or not having a native wchar codeset defined, the maxbytes is
600 * set to zero, indicating no wchar data is allowed.
602 static size_t wchar_maxbytes_
;
606 // ****************************************************************
609 * @class ACE_InputCDR
611 * @brief A CDR stream for demarshalling CDR-encoded data.
613 * This class is based on the the CORBA spec for Java (98-02-29),
614 * java class omg.org.CORBA.portable.InputStream. It diverts in a
616 * @li Operations to retrieve basic types take parameters by
618 * @li Operations taking arrays don't have offsets, because in C++
619 * it is easier to describe an array starting from x+offset.
620 * @li Operations return an error status, because exceptions are
621 * not widely available in C++ (yet).
623 class ACE_Export ACE_InputCDR
626 // The translators need privileged access to efficiently demarshal
628 friend class ACE_Char_Codeset_Translator
;
629 friend class ACE_WChar_Codeset_Translator
;
632 * Create an input stream from an arbitrary buffer. The buffer must
633 * be properly aligned because this contructor will *not* work if
634 * the buffer is aligned unproperly.See ACE_ptr_align_binary() for
635 * instructions on how to align a pointer properly and use
636 * ACE_CDR::MAX_ALIGNMENT for the correct alignment.
638 ACE_InputCDR (const char *buf
,
640 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
641 ACE_CDR::Octet major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
642 ACE_CDR::Octet minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
644 /// Create an empty input stream. The caller is responsible for
645 /// putting the right data and providing the right alignment.
646 ACE_InputCDR (size_t bufsiz
,
647 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
648 ACE_CDR::Octet major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
649 ACE_CDR::Octet minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
651 /// Create an input stream from an ACE_Message_Block
653 * The alignment of the @a data block is carried into the new
654 * ACE_InputCDR object. This constructor either increments the
655 * @a data reference count, or copies the data (if it's a compound
656 * message block) so the caller can release the block immediately
659 ACE_InputCDR (const ACE_Message_Block
*data
,
660 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
661 ACE_CDR::Octet major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
662 ACE_CDR::Octet minor_version
= ACE_CDR_GIOP_MINOR_VERSION
,
665 /// Create an input stream from an ACE_Data_Block. The <flag>
666 /// indicates whether the <data> can be deleted by the CDR stream
668 ACE_InputCDR (ACE_Data_Block
*data
,
669 ACE_Message_Block::Message_Flags flag
= 0,
670 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
671 ACE_CDR::Octet major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
672 ACE_CDR::Octet minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
674 /// Create an input stream from an ACE_Data_Block. It also sets the
675 /// read and write pointers at the desired positions. This would be
676 /// helpful if the applications desires to create a new CDR stream
677 /// from a semi-processed datablock.
678 ACE_InputCDR (ACE_Data_Block
*data
,
679 ACE_Message_Block::Message_Flags flag
,
680 size_t read_pointer_position
,
681 size_t write_pointer_position
,
682 int byte_order
= ACE_CDR::BYTE_ORDER_NATIVE
,
683 ACE_CDR::Octet major_version
= ACE_CDR_GIOP_MAJOR_VERSION
,
684 ACE_CDR::Octet minor_version
= ACE_CDR_GIOP_MINOR_VERSION
);
687 * These make a copy of the current stream state, but do not copy
688 * the internal buffer, so the same stream can be read multiple
691 ACE_InputCDR (const ACE_InputCDR
& rhs
);
693 ACE_InputCDR
& operator= (const ACE_InputCDR
& rhs
);
695 /// When interpreting indirected TypeCodes it is useful to make a
696 /// "copy" of the stream starting in the new position.
697 ACE_InputCDR (const ACE_InputCDR
& rhs
,
699 ACE_CDR::Long offset
);
701 /// This creates an encapsulated stream, the first byte must be (per
702 /// the spec) the byte order of the encapsulation.
703 ACE_InputCDR (const ACE_InputCDR
& rhs
,
706 /// Create an input CDR from an output CDR.
707 ACE_InputCDR (const ACE_OutputCDR
& rhs
,
708 ACE_Allocator
* buffer_allocator
= 0,
709 ACE_Allocator
* data_block_allocator
= 0,
710 ACE_Allocator
* message_block_allocator
= 0);
712 /// Helper class to transfer the contents from one input CDR to
713 /// another without requiring any extra memory allocations, data
714 /// copies or too many temporaries.
715 struct ACE_Export Transfer_Contents
717 Transfer_Contents (ACE_InputCDR
&rhs
);
721 /// Transfer the contents from <rhs> to a new CDR
722 ACE_InputCDR (Transfer_Contents rhs
);
725 ~ACE_InputCDR (void);
727 /// Disambiguate overloading when extracting octets, chars,
728 /// booleans, and bounded strings
729 //@{ @name Helper classes
731 struct ACE_Export to_boolean
733 explicit to_boolean (ACE_CDR::Boolean
&b
);
734 ACE_CDR::Boolean
&ref_
;
737 struct ACE_Export to_char
739 explicit to_char (ACE_CDR::Char
&c
);
743 struct ACE_Export to_wchar
745 explicit to_wchar (ACE_CDR::WChar
&wc
);
746 ACE_CDR::WChar
&ref_
;
749 struct ACE_Export to_octet
751 explicit to_octet (ACE_CDR::Octet
&o
);
752 ACE_CDR::Octet
&ref_
;
755 struct ACE_Export to_string
758 * @deprecated The constructor taking a non-const string is now
759 * deprecated (C++ mapping 00-01-02), but we keep it
760 * around for backward compatibility.
762 to_string (ACE_CDR::Char
*&s
,
764 to_string (const ACE_CDR::Char
*&s
,
766 const ACE_CDR::Char
*&val_
;
767 ACE_CDR::ULong bound_
;
770 struct ACE_Export to_wstring
772 /// The constructor taking a non-const wstring is
773 /// now deprecated (C++ mapping 00-01-02), but we
774 /// keep it around for backward compatibility.
775 to_wstring (ACE_CDR::WChar
*&ws
,
777 to_wstring (const ACE_CDR::WChar
*&ws
,
779 const ACE_CDR::WChar
*&val_
;
780 ACE_CDR::ULong bound_
;
785 * Return @c false on failure and @c true on success.
787 //@{ @name Read basic IDL types
788 ACE_CDR::Boolean
read_boolean (ACE_CDR::Boolean
& x
);
789 ACE_CDR::Boolean
read_char (ACE_CDR::Char
&x
);
790 ACE_CDR::Boolean
read_wchar (ACE_CDR::WChar
& x
);
791 ACE_CDR::Boolean
read_octet (ACE_CDR::Octet
& x
);
792 ACE_CDR::Boolean
read_short (ACE_CDR::Short
&x
);
793 ACE_CDR::Boolean
read_ushort (ACE_CDR::UShort
&x
);
794 ACE_CDR::Boolean
read_long (ACE_CDR::Long
&x
);
795 ACE_CDR::Boolean
read_ulong (ACE_CDR::ULong
&x
);
796 ACE_CDR::Boolean
read_longlong (ACE_CDR::LongLong
& x
);
797 ACE_CDR::Boolean
read_ulonglong (ACE_CDR::ULongLong
& x
);
798 ACE_CDR::Boolean
read_float (ACE_CDR::Float
&x
);
799 ACE_CDR::Boolean
read_double (ACE_CDR::Double
&x
);
800 ACE_CDR::Boolean
read_longdouble (ACE_CDR::LongDouble
&x
);
802 ACE_CDR::Boolean
read_string (ACE_CDR::Char
*&x
);
803 ACE_CDR::Boolean
read_string (ACE_CString
&x
);
804 ACE_CDR::Boolean
read_wstring (ACE_CDR::WChar
*& x
);
808 * The buffer @a x must be large enough to contain @a length
810 * Return @c false on failure and @c true on success.
812 //@{ @name Read basic IDL types arrays
813 ACE_CDR::Boolean
read_boolean_array (ACE_CDR::Boolean
* x
,
814 ACE_CDR::ULong length
);
815 ACE_CDR::Boolean
read_char_array (ACE_CDR::Char
*x
,
816 ACE_CDR::ULong length
);
817 ACE_CDR::Boolean
read_wchar_array (ACE_CDR::WChar
* x
,
818 ACE_CDR::ULong length
);
819 ACE_CDR::Boolean
read_octet_array (ACE_CDR::Octet
* x
,
820 ACE_CDR::ULong length
);
821 ACE_CDR::Boolean
read_short_array (ACE_CDR::Short
*x
,
822 ACE_CDR::ULong length
);
823 ACE_CDR::Boolean
read_ushort_array (ACE_CDR::UShort
*x
,
824 ACE_CDR::ULong length
);
825 ACE_CDR::Boolean
read_long_array (ACE_CDR::Long
*x
,
826 ACE_CDR::ULong length
);
827 ACE_CDR::Boolean
read_ulong_array (ACE_CDR::ULong
*x
,
828 ACE_CDR::ULong length
);
829 ACE_CDR::Boolean
read_longlong_array (ACE_CDR::LongLong
* x
,
830 ACE_CDR::ULong length
);
831 ACE_CDR::Boolean
read_ulonglong_array (ACE_CDR::ULongLong
* x
,
832 ACE_CDR::ULong length
);
833 ACE_CDR::Boolean
read_float_array (ACE_CDR::Float
*x
,
834 ACE_CDR::ULong length
);
835 ACE_CDR::Boolean
read_double_array (ACE_CDR::Double
*x
,
836 ACE_CDR::ULong length
);
837 ACE_CDR::Boolean
read_longdouble_array (ACE_CDR::LongDouble
* x
,
838 ACE_CDR::ULong length
);
842 * Return @c false on failure and @c true on success.
844 //@{ @name Skip elements
845 ACE_CDR::Boolean
skip_boolean (void);
846 ACE_CDR::Boolean
skip_char (void);
847 ACE_CDR::Boolean
skip_wchar (void);
848 ACE_CDR::Boolean
skip_octet (void);
849 ACE_CDR::Boolean
skip_short (void);
850 ACE_CDR::Boolean
skip_ushort (void);
851 ACE_CDR::Boolean
skip_long (void);
852 ACE_CDR::Boolean
skip_ulong (void);
853 ACE_CDR::Boolean
skip_longlong (void);
854 ACE_CDR::Boolean
skip_ulonglong (void);
855 ACE_CDR::Boolean
skip_float (void);
856 ACE_CDR::Boolean
skip_double (void);
857 ACE_CDR::Boolean
skip_longdouble (void);
861 * The next field must be a string, this method skips it. It is
862 * useful in parsing a TypeCode.
863 * @return @c false on failure and @c true on success.
865 ACE_CDR::Boolean
skip_wstring (void);
866 ACE_CDR::Boolean
skip_string (void);
868 /// Skip @a n bytes in the CDR stream.
870 * @return @c false on failure and @c true on success.
872 ACE_CDR::Boolean
skip_bytes (size_t n
);
874 /// returns @c false if a problem has been detected.
875 bool good_bit (void) const;
878 * @return The start of the message block chain for this CDR
881 * @note In the current implementation the chain has length 1, but
882 * we are planning to change that.
884 const ACE_Message_Block
* start (void) const;
886 // = The following functions are useful to read the contents of the
887 // CDR stream from a socket or file.
890 * Grow the internal buffer, reset @c rd_ptr to the first byte in
891 * the new buffer that is properly aligned, and set @c wr_ptr to @c
892 * rd_ptr @c + @c newsize
894 int grow (size_t newsize
);
897 * After reading and partially parsing the contents the user can
898 * detect a change in the byte order, this method will let him/her
901 void reset_byte_order (int byte_order
);
903 /// Re-initialize the CDR stream, copying the contents of the chain
904 /// of message_blocks starting from @a data.
905 void reset (const ACE_Message_Block
*data
,
908 /// Steal the contents from the current CDR.
909 ACE_Message_Block
*steal_contents (void);
911 /// Steal the contents of @a cdr and make a shallow copy into this
913 void steal_from (ACE_InputCDR
&cdr
);
915 /// Exchange data blocks with the caller of this method. The read
916 /// and write pointers are also exchanged.
918 * @note We now do only with the start_ message block.
920 void exchange_data_blocks (ACE_InputCDR
&cdr
);
922 /// Copy the data portion from the @c cdr to this cdr and return the
923 /// data content (ie. the ACE_Data_Block) from this CDR to the
926 * @note The caller is responsible for managing the memory of the
927 * returned ACE_Data_Block.
929 ACE_Data_Block
* clone_from (ACE_InputCDR
&cdr
);
931 /// Re-initialize the CDR stream, forgetting about the old contents
932 /// of the stream and allocating a new buffer (from the allocators).
933 void reset_contents (void);
935 /// Returns the current position for the @c rd_ptr.
938 /// Returns the current position for the @c wr_ptr.
941 /// Return how many bytes are left in the stream.
942 size_t length (void) const;
945 * Utility function to allow the user more flexibility.
946 * Skips up to the nearest @a alignment-byte boundary.
947 * Argument MUST be a power of 2.
949 * @return 0 on success and -1 on failure.
951 int align_read_ptr (size_t alignment
);
953 /// If @c true then this stream is writing in non-native byte order.
954 /// This is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined.
955 bool do_byte_swap (void) const;
957 /// If @c do_byte_swap() returns @c false, this returns
958 /// ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER.
959 int byte_order (void) const;
961 /// Access the codeset translators. They can be nil!
962 ACE_Char_Codeset_Translator
*char_translator (void) const;
963 ACE_WChar_Codeset_Translator
*wchar_translator (void) const;
965 /// Set the codeset translators.
966 void char_translator (ACE_Char_Codeset_Translator
*);
967 void wchar_translator (ACE_WChar_Codeset_Translator
*);
970 * Returns (in @a buf) the next position in the buffer aligned to
971 * @a size. It advances the Message_Block @c rd_ptr past the data
972 * (i.e., @c buf @c + @c size). Sets the good_bit to @c false and
973 * returns a -1 on failure.
975 int adjust (size_t size
,
978 /// As above, but now the size and alignment requirements may be
980 int adjust (size_t size
,
984 /// Set the underlying GIOP version..
985 void set_version (ACE_CDR::Octet major
, ACE_CDR::Octet minor
);
987 /// Set the underlying GIOP version..
988 void get_version (ACE_CDR::Octet
&major
, ACE_CDR::Octet
&minor
);
990 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
991 /// Register and unregister our buffer size monitor.
992 void register_monitor (const char* id
);
993 void unregister_monitor (void);
994 #endif /* ACE_HAS_MONITOR_POINTS==1 */
998 /// The start of the chain of message blocks, even though in the
999 /// current version the chain always has length 1.
1000 ACE_Message_Block start_
;
1002 /// The CDR stream byte order does not match the one on the machine,
1003 /// swapping is needed while reading.
1006 /// set to @c false when an error occurs.
1009 /// The GIOP versions for this stream
1010 ACE_CDR::Octet major_version_
;
1011 ACE_CDR::Octet minor_version_
;
1013 /// If not nil, invoke for translation of character and string data.
1014 ACE_Char_Codeset_Translator
*char_translator_
;
1015 ACE_WChar_Codeset_Translator
*wchar_translator_
;
1017 #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
1018 ACE::Monitor_Control::Size_Monitor
*monitor_
;
1019 #endif /* ACE_HAS_MONITOR_POINTS==1 */
1023 ACE_CDR::Boolean
read_1 (ACE_CDR::Octet
*x
);
1024 ACE_CDR::Boolean
read_2 (ACE_CDR::UShort
*x
);
1025 ACE_CDR::Boolean
read_4 (ACE_CDR::ULong
*x
);
1026 ACE_CDR::Boolean
read_8 (ACE_CDR::ULongLong
*x
);
1027 ACE_CDR::Boolean
read_16 (ACE_CDR::LongDouble
*x
);
1029 // Several types can be read using the same routines, since TAO
1030 // tries to use native types with known size for each CORBA type.
1031 // We could use void* or char* to make the interface more
1032 // consistent, but using native types let us exploit the strict
1033 // alignment requirements of CDR streams and implement the
1034 // operations using asignment.
1037 * Read an array of @a length elements, each of @a size bytes and the
1038 * start aligned at a multiple of <align>. The elements are assumed
1039 * to be packed with the right alignment restrictions. It is mostly
1040 * designed for buffers of the basic types.
1042 * This operation uses <memcpy>; as explained above it is expected
1043 * that using assignment is faster that <memcpy> for one element,
1044 * but for several elements <memcpy> should be more efficient, it
1045 * could be interesting to find the break even point and optimize
1046 * for that case, but that would be too platform dependent.
1048 ACE_CDR::Boolean
read_array (void* x
,
1051 ACE_CDR::ULong length
);
1054 * On those occasions when the native codeset for wchar is smaller than
1055 * the size of a wchar_t, such as using UTF-16 with a 4-byte wchar_t, a
1056 * special form of reading the array is needed. Actually, this should be
1057 * a default translator.
1059 ACE_CDR::Boolean
read_wchar_array_i (ACE_CDR::WChar
* x
,
1060 ACE_CDR::ULong length
);
1062 /// Move the rd_ptr ahead by @a offset bytes.
1063 void rd_ptr (size_t offset
);
1065 /// Points to the continuation field of the current message block.
1069 // ****************************************************************
1072 * @class ACE_Char_Codeset_Translator
1074 * @brief Codeset translation routines common to both Output and Input
1077 * This class is a base class for defining codeset translation
1078 * routines to handle the character set translations required by
1079 * both CDR Input streams and CDR Output streams.
1081 * Translators are reference counted. This allows for stateful as well
1082 * as stateless translators. Stateless translators will be allocated
1083 * once whereas CDR Streams own their own copy of a stateful translator.
1085 class ACE_Export ACE_Char_Codeset_Translator
1088 virtual ~ACE_Char_Codeset_Translator ();
1090 /// Read a single character from the stream, converting from the
1091 /// stream codeset to the native codeset
1092 virtual ACE_CDR::Boolean
read_char (ACE_InputCDR
&,
1093 ACE_CDR::Char
&) = 0;
1095 /// Read a string from the stream, including the length, converting
1096 /// the characters from the stream codeset to the native codeset
1097 virtual ACE_CDR::Boolean
read_string (ACE_InputCDR
&,
1098 ACE_CDR::Char
*&) = 0;
1100 /// Read an array of characters from the stream, converting the
1101 /// characters from the stream codeset to the native codeset.
1102 virtual ACE_CDR::Boolean
read_char_array (ACE_InputCDR
&,
1104 ACE_CDR::ULong
) = 0;
1106 /// Write a single character to the stream, converting from the
1107 /// native codeset to the stream codeset
1108 virtual ACE_CDR::Boolean
write_char (ACE_OutputCDR
&,
1111 /// Write a string to the stream, including the length, converting
1112 /// from the native codeset to the stream codeset
1113 virtual ACE_CDR::Boolean
write_string (ACE_OutputCDR
&,
1115 const ACE_CDR::Char
*) = 0;
1117 /// Write an array of characters to the stream, converting from the
1118 /// native codeset to the stream codeset
1119 virtual ACE_CDR::Boolean
write_char_array (ACE_OutputCDR
&,
1120 const ACE_CDR::Char
*,
1121 ACE_CDR::ULong
) = 0;
1123 virtual ACE_CDR::ULong
ncs () = 0;
1124 virtual ACE_CDR::ULong
tcs () = 0;
1126 /// Children have access to low-level routines because they cannot
1127 /// use read_char or something similar (it would recurse).
1128 ACE_CDR::Boolean
read_1 (ACE_InputCDR
& input
,
1130 ACE_CDR::Boolean
write_1 (ACE_OutputCDR
& output
,
1131 const ACE_CDR::Octet
*x
);
1133 /// Efficiently read @a length elements of size @a size each from
1134 /// <input> into <x>; the data must be aligned to <align>.
1135 ACE_CDR::Boolean
read_array (ACE_InputCDR
& input
,
1139 ACE_CDR::ULong length
);
1142 * Efficiently write @a length elements of size @a size from <x> into
1143 * <output>. Before inserting the elements enough padding is added
1144 * to ensure that the elements will be aligned to <align> in the
1147 ACE_CDR::Boolean
write_array (ACE_OutputCDR
& output
,
1151 ACE_CDR::ULong length
);
1154 * Exposes the stream implementation of <adjust>, this is useful in
1155 * many cases to minimize memory allocations during marshaling.
1156 * On success @a buf will contain a contiguous area in the CDR stream
1157 * that can hold @a size bytes aligned to <align>.
1160 int adjust (ACE_OutputCDR
& out
,
1165 /// Used by derived classes to set errors in the CDR stream.
1166 void good_bit (ACE_OutputCDR
& out
, bool bit
);
1168 /// Obtain the CDR Stream's major & minor version values.
1169 ACE_CDR::Octet
major_version (ACE_InputCDR
& input
);
1170 ACE_CDR::Octet
minor_version (ACE_InputCDR
& input
);
1171 ACE_CDR::Octet
major_version (ACE_OutputCDR
& output
);
1172 ACE_CDR::Octet
minor_version (ACE_OutputCDR
& output
);
1175 // ****************************************************************
1178 * @class ACE_WChar_Codeset_Translator
1180 * @brief Codeset translation routines common to both Output and Input
1183 * This class is a base class for defining codeset translation
1184 * routines to handle the character set translations required by
1185 * both CDR Input streams and CDR Output streams.
1187 class ACE_Export ACE_WChar_Codeset_Translator
1190 virtual ~ACE_WChar_Codeset_Translator ();
1192 virtual ACE_CDR::Boolean
read_wchar (ACE_InputCDR
&,
1193 ACE_CDR::WChar
&) = 0;
1194 virtual ACE_CDR::Boolean
read_wstring (ACE_InputCDR
&,
1195 ACE_CDR::WChar
*&) = 0;
1196 virtual ACE_CDR::Boolean
read_wchar_array (ACE_InputCDR
&,
1198 ACE_CDR::ULong
) = 0;
1199 virtual ACE_CDR::Boolean
write_wchar (ACE_OutputCDR
&,
1200 ACE_CDR::WChar
) = 0;
1201 virtual ACE_CDR::Boolean
write_wstring (ACE_OutputCDR
&,
1203 const ACE_CDR::WChar
*) = 0;
1204 virtual ACE_CDR::Boolean
write_wchar_array (ACE_OutputCDR
&,
1205 const ACE_CDR::WChar
*,
1206 ACE_CDR::ULong
) = 0;
1208 virtual ACE_CDR::ULong
ncs () = 0;
1209 virtual ACE_CDR::ULong
tcs () = 0;
1211 /// Children have access to low-level routines because they cannot
1212 /// use read_char or something similar (it would recurse).
1213 ACE_CDR::Boolean
read_1 (ACE_InputCDR
& input
,
1215 ACE_CDR::Boolean
read_2 (ACE_InputCDR
& input
,
1216 ACE_CDR::UShort
*x
);
1217 ACE_CDR::Boolean
read_4 (ACE_InputCDR
& input
,
1219 ACE_CDR::Boolean
write_1 (ACE_OutputCDR
& output
,
1220 const ACE_CDR::Octet
*x
);
1221 ACE_CDR::Boolean
write_2 (ACE_OutputCDR
& output
,
1222 const ACE_CDR::UShort
*x
);
1223 ACE_CDR::Boolean
write_4 (ACE_OutputCDR
& output
,
1224 const ACE_CDR::ULong
*x
);
1226 /// Efficiently read @a length elements of size @a size each from
1227 /// <input> into <x>; the data must be aligned to <align>.
1228 ACE_CDR::Boolean
read_array (ACE_InputCDR
& input
,
1232 ACE_CDR::ULong length
);
1235 * Efficiently write @a length elements of size @a size from <x> into
1236 * <output>. Before inserting the elements enough padding is added
1237 * to ensure that the elements will be aligned to <align> in the
1240 ACE_CDR::Boolean
write_array (ACE_OutputCDR
& output
,
1244 ACE_CDR::ULong length
);
1247 * Exposes the stream implementation of <adjust>, this is useful in
1248 * many cases to minimize memory allocations during marshaling.
1249 * On success @a buf will contain a contiguous area in the CDR stream
1250 * that can hold @a size bytes aligned to <align>.
1253 int adjust (ACE_OutputCDR
& out
,
1258 /// Used by derived classes to set errors in the CDR stream.
1259 void good_bit (ACE_OutputCDR
& out
, bool bit
);
1261 /// Obtain the CDR Stream's major & minor version values.
1262 ACE_CDR::Octet
major_version (ACE_InputCDR
& input
);
1263 ACE_CDR::Octet
minor_version (ACE_InputCDR
& input
);
1264 ACE_CDR::Octet
major_version (ACE_OutputCDR
& output
);
1265 ACE_CDR::Octet
minor_version (ACE_OutputCDR
& output
);
1269 // @@ These operators should not be inlined since they force SString.h
1270 // to be included in this header.
1271 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1272 const ACE_CString
&x
);
1274 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1278 ACE_END_VERSIONED_NAMESPACE_DECL
1280 #if defined (__ACE_INLINE__)
1281 # include "ace/CDR_Stream.inl"
1282 #else /* __ACE_INLINE__ */
1284 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
1286 // Not used by CORBA or TAO
1287 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1289 // CDR output operators for primitive types
1291 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1293 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1295 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1297 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1299 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1300 ACE_CDR::LongLong x
);
1301 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1302 ACE_CDR::ULongLong x
);
1303 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
& os
,
1304 ACE_CDR::LongDouble x
);
1305 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1307 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1310 // CDR output operator from helper classes
1312 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1313 ACE_OutputCDR::from_boolean x
);
1314 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1315 ACE_OutputCDR::from_char x
);
1316 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1317 ACE_OutputCDR::from_wchar x
);
1318 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1319 ACE_OutputCDR::from_octet x
);
1320 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1321 ACE_OutputCDR::from_string x
);
1322 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1323 ACE_OutputCDR::from_wstring x
);
1324 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1325 const ACE_CDR::Char
* x
);
1326 extern ACE_Export
ACE_CDR::Boolean
operator<< (ACE_OutputCDR
&os
,
1327 const ACE_CDR::WChar
* x
);
1329 // Not used by CORBA or TAO
1330 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1332 // CDR input operators for primitive types
1334 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1336 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1337 ACE_CDR::UShort
&x
);
1338 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1340 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1342 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1343 ACE_CDR::LongLong
&x
);
1344 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1345 ACE_CDR::ULongLong
&x
);
1346 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1347 ACE_CDR::LongDouble
&x
);
1348 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1350 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1351 ACE_CDR::Double
&x
);
1353 // CDR input operator from helper classes
1355 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1356 ACE_InputCDR::to_boolean x
);
1357 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1358 ACE_InputCDR::to_char x
);
1359 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1360 ACE_InputCDR::to_wchar x
);
1361 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1362 ACE_InputCDR::to_octet x
);
1363 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1364 ACE_InputCDR::to_string x
);
1365 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1366 ACE_InputCDR::to_wstring x
);
1367 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1369 extern ACE_Export
ACE_CDR::Boolean
operator>> (ACE_InputCDR
&is
,
1370 ACE_CDR::WChar
*& x
);
1372 ACE_END_VERSIONED_NAMESPACE_DECL
1374 #endif /* __ACE_INLINE__ */
1376 #if defined (GEN_OSTREAM_OPS)
1378 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
1380 // ostream insertion operators for debugging code generated from IDL. All
1381 // but these below are either in generated code itself or are unambiguous
1384 ACE_Export
std::ostream
& operator<< (std::ostream
&os
,
1385 ACE_OutputCDR::from_boolean x
);
1387 ACE_Export
std::ostream
& operator<< (std::ostream
&os
,
1388 ACE_OutputCDR::from_char x
);
1390 ACE_Export
std::ostream
& operator<< (std::ostream
&os
,
1391 ACE_OutputCDR::from_wchar x
);
1393 ACE_Export
std::ostream
& operator<< (std::ostream
&os
,
1394 ACE_OutputCDR::from_octet x
);
1396 ACE_END_VERSIONED_NAMESPACE_DECL
1398 #endif /* GEN_OSTREAM_OPS */
1400 #include /**/ "ace/post.h"
1402 #endif /* ACE_CDR_STREAM_H */