Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

CDR_Stream.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   CDR_Stream.h
00006  *
00007  *  $Id: CDR_Stream.h,v 1.1.1.4.2.1 2003/04/10 14:12:27 phil Exp $
00008  *
00009  * ACE Common Data Representation (CDR) marshaling and demarshaling
00010  * classes.
00011  *
00012  * This implementation was inspired in the CDR class in SunSoft's
00013  * IIOP engine, but has a completely different implementation and a
00014  * different interface too.
00015  *
00016  * The current implementation assumes that the host has 1-byte,
00017  * 2-byte and 4-byte integral types, and that it has single
00018  * precision and double precision IEEE floats.
00019  * Those assumptions are pretty good these days, with Crays beign
00020  * the only known exception.
00021  *
00022  *  @author TAO version by
00023  *  @author Aniruddha Gokhale <gokhale@cs.wustl.edu>
00024  *  @author Carlos O'Ryan<coryan@cs.wustl.edu>
00025  *  @author ACE version by
00026  *  @author Jeff Parsons <parsons@cs.wustl.edu>
00027  *  @author Istvan Buki <istvan.buki@euronet.be>
00028  *  @author Codeset translation by
00029  *  @author Jim Rogers <jrogers@viasoft.com>
00030  */
00031 //=============================================================================
00032 
00033 #ifndef ACE_CDR_STREAM_H
00034 #define ACE_CDR_STREAM_H
00035 
00036 #include "ace/pre.h"
00037 
00038 #include "ace/CDR_Base.h"
00039 
00040 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00041 # pragma once
00042 #endif /* ACE_LACKS_PRAGMA_ONCE */
00043 
00044 #include "ace/SString.h"
00045 #include "ace/Message_Block.h"
00046 
00047 
00048 // Stuff used by the ACE CDR classes.
00049 #if defined ACE_LITTLE_ENDIAN
00050 #  define ACE_CDR_BYTE_ORDER 1
00051 // little endian encapsulation byte order has value = 1
00052 #else  /* ! ACE_LITTLE_ENDIAN */
00053 #  define ACE_CDR_BYTE_ORDER 0
00054 // big endian encapsulation byte order has value = 0
00055 #endif /* ! ACE_LITTLE_ENDIAN */
00056 
00057 
00058 class ACE_Char_Codeset_Translator;
00059 class ACE_WChar_Codeset_Translator;
00060 
00061 class ACE_InputCDR;
00062 
00063 /**
00064  * @class ACE_OutputCDR
00065  *
00066  * @brief A CDR stream for writing, i.e. for marshalling.
00067  *
00068  * This class is based on the the CORBA spec for Java (98-02-29),
00069  * java class omg.org.CORBA.portable.OutputStream.  It diverts in
00070  * a few ways:
00071  * + Operations taking arrays don't have offsets, because in C++
00072  *   it is easier to describe an array starting from x+offset.
00073  * + Operations return an error status, because exceptions are
00074  *   not widely available in C++ (yet).
00075  */
00076 class ACE_Export ACE_OutputCDR
00077 {
00078 public:
00079   /**
00080    * The Codeset translators need access to some private members to
00081    * efficiently marshal arrays
00082    * For reading from an output CDR stream.
00083    */
00084   friend class ACE_Char_Codeset_Translator;
00085   friend class ACE_WChar_Codeset_Translator;
00086   friend class ACE_InputCDR;
00087 
00088   /// Default constructor, allocates <size> bytes in the internal
00089   /// buffer, if <size> == 0 it allocates the default size.
00090   ACE_OutputCDR (size_t size = 0,
00091                  int byte_order = ACE_CDR_BYTE_ORDER,
00092                  ACE_Allocator* buffer_allocator = 0,
00093                  ACE_Allocator* data_block_allocator = 0,
00094                  ACE_Allocator* message_block_allocator = 0,
00095                  size_t memcpy_tradeoff =
00096                  ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
00097                  ACE_CDR::Octet major_version =
00098                  ACE_CDR_GIOP_MAJOR_VERSION,
00099                  ACE_CDR::Octet minor_version =
00100                  ACE_CDR_GIOP_MINOR_VERSION);
00101 
00102   /// Build a CDR stream with an initial buffer, it will *not* remove
00103   /// <data>, since it did not allocated it.  It's important to be careful
00104   /// with the alignment of <data>.
00105   /**
00106    * Create an output stream from an arbitrary buffer, care must be
00107    * exercised with alignment, because this contructor will align if
00108    * needed.  In this case <data> will not point to the start off the
00109    * output stream. begin()->rd_prt() points to the start off the
00110    * output stream.  See ACE_ptr_align_binary() to properly align a
00111    * pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment.
00112    */
00113   ACE_OutputCDR (char *data,
00114                  size_t size,
00115                  int byte_order = ACE_CDR_BYTE_ORDER,
00116                  ACE_Allocator* buffer_allocator = 0,
00117                  ACE_Allocator* data_block_allocator = 0,
00118                  ACE_Allocator* message_block_allocator = 0,
00119                  size_t memcpy_tradeoff=
00120                  ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
00121                  ACE_CDR::Octet giop_major_version =
00122                  ACE_CDR_GIOP_MAJOR_VERSION,
00123                  ACE_CDR::Octet giop_minor_version =
00124                  ACE_CDR_GIOP_MINOR_VERSION);
00125 
00126   /// Build a CDR stream with an initial Message_Block chain, it will
00127   /// *not* remove <data>, since it did not allocate it.
00128   ACE_OutputCDR (ACE_Message_Block *data,
00129                  int byte_order = ACE_CDR_BYTE_ORDER,
00130                  size_t memcpy_tradeoff=
00131                  ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
00132                  ACE_CDR::Octet giop_major_version =
00133                  ACE_CDR_GIOP_MAJOR_VERSION,
00134                  ACE_CDR::Octet giop_minor_version =
00135                  ACE_CDR_GIOP_MINOR_VERSION);
00136 
00137   /// destructor
00138   ~ACE_OutputCDR (void);
00139 
00140   /**
00141    * Disambiguate overload when inserting booleans, octets, chars, and
00142    * bounded strings.
00143    */
00144   //@{ @name Helper classes
00145 
00146   struct ACE_Export from_boolean
00147   {
00148     from_boolean (ACE_CDR::Boolean b);
00149     ACE_CDR::Boolean val_;
00150   };
00151 
00152   struct ACE_Export from_octet
00153   {
00154     from_octet (ACE_CDR::Octet o);
00155     ACE_CDR::Octet val_;
00156   };
00157 
00158   struct ACE_Export from_char
00159   {
00160     from_char (ACE_CDR::Char c);
00161     ACE_CDR::Char val_;
00162   };
00163 
00164   struct ACE_Export from_wchar
00165   {
00166     from_wchar (ACE_CDR::WChar wc);
00167     ACE_CDR::WChar val_;
00168   };
00169 
00170   struct ACE_Export from_string
00171   {
00172     from_string (ACE_CDR::Char* s,
00173                  ACE_CDR::ULong b,
00174                  ACE_CDR::Boolean nocopy = 0);
00175     from_string (const ACE_CDR::Char* s,
00176                  ACE_CDR::ULong b,
00177                  ACE_CDR::Boolean nocopy = 0);
00178     ACE_CDR::Char *val_;
00179     ACE_CDR::ULong bound_;
00180     ACE_CDR::Boolean nocopy_;
00181   };
00182 
00183   struct ACE_Export from_wstring
00184   {
00185     from_wstring (ACE_CDR::WChar* ws,
00186                   ACE_CDR::ULong b,
00187                   ACE_CDR::Boolean nocopy = 0);
00188     from_wstring (const ACE_CDR::WChar* ws,
00189                   ACE_CDR::ULong b,
00190                   ACE_CDR::Boolean nocopy = 0);
00191     ACE_CDR::WChar *val_;
00192     ACE_CDR::ULong bound_;
00193     ACE_CDR::Boolean nocopy_;
00194   };
00195   //@}
00196 
00197   // Return 0 on failure and 1 on success.
00198   //@{ @name Write operations
00199   ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x);
00200   ACE_CDR::Boolean write_char (ACE_CDR::Char x);
00201   ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x);
00202   ACE_CDR::Boolean write_octet (ACE_CDR::Octet x);
00203   ACE_CDR::Boolean write_short (ACE_CDR::Short x);
00204   ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x);
00205   ACE_CDR::Boolean write_long (ACE_CDR::Long x);
00206   ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x);
00207   ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x);
00208   ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x);
00209   ACE_CDR::Boolean write_float (ACE_CDR::Float x);
00210   ACE_CDR::Boolean write_double (const ACE_CDR::Double &x);
00211   ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x);
00212 
00213   /// For string we offer methods that accept a precomputed length.
00214   ACE_CDR::Boolean write_string (const ACE_CDR::Char *x);
00215   ACE_CDR::Boolean write_string (ACE_CDR::ULong len,
00216                                  const ACE_CDR::Char *x);
00217   ACE_CDR::Boolean write_string (const ACE_CString &x);
00218   ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x);
00219   ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length,
00220                                   const ACE_CDR::WChar *x);
00221   //@}
00222 
00223   /// Note: the portion written starts at <x> and ends
00224   ///    at <x + length>.
00225   /// The length is *NOT* stored into the CDR stream.
00226   //@{ @name Array write operations
00227   ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x,
00228                                         ACE_CDR::ULong length);
00229   ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x,
00230                                      ACE_CDR::ULong length);
00231   ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar* x,
00232                                       ACE_CDR::ULong length);
00233   ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet* x,
00234                                       ACE_CDR::ULong length);
00235   ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x,
00236                                       ACE_CDR::ULong length);
00237   ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x,
00238                                        ACE_CDR::ULong length);
00239   ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x,
00240                                      ACE_CDR::ULong length);
00241   ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x,
00242                                       ACE_CDR::ULong length);
00243   ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong* x,
00244                                          ACE_CDR::ULong length);
00245   ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x,
00246                                           ACE_CDR::ULong length);
00247   ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x,
00248                                       ACE_CDR::ULong length);
00249   ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x,
00250                                        ACE_CDR::ULong length);
00251   ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x,
00252                                            ACE_CDR::ULong length);
00253 
00254   /// Write an octet array contained inside a MB, this can be optimized
00255   /// to minimize copies.
00256   ACE_CDR::Boolean write_octet_array_mb (const ACE_Message_Block* mb);
00257   //@}
00258 
00259   /**
00260    * Return 0 on failure and 1 on success.
00261    */
00262   //@{ @name Append contents of own CDR stream to another
00263   ACE_CDR::Boolean append_boolean (ACE_InputCDR &);
00264   ACE_CDR::Boolean append_char (ACE_InputCDR &);
00265   ACE_CDR::Boolean append_wchar (ACE_InputCDR &);
00266   ACE_CDR::Boolean append_octet (ACE_InputCDR &);
00267   ACE_CDR::Boolean append_short (ACE_InputCDR &);
00268   ACE_CDR::Boolean append_ushort (ACE_InputCDR &);
00269   ACE_CDR::Boolean append_long (ACE_InputCDR &);
00270   ACE_CDR::Boolean append_ulong (ACE_InputCDR &);
00271   ACE_CDR::Boolean append_longlong (ACE_InputCDR &);
00272   ACE_CDR::Boolean append_ulonglong (ACE_InputCDR &);
00273   ACE_CDR::Boolean append_float (ACE_InputCDR &);
00274   ACE_CDR::Boolean append_double (ACE_InputCDR &);
00275   ACE_CDR::Boolean append_longdouble (ACE_InputCDR &);
00276 
00277   ACE_CDR::Boolean append_wstring (ACE_InputCDR &);
00278   ACE_CDR::Boolean append_string (ACE_InputCDR &);
00279   //@}
00280 
00281   /// Returns 0 if an error has ocurred, the only expected error is to
00282   /// run out of memory.
00283   int good_bit (void) const;
00284 
00285   /// Reuse the CDR stream to write on the old buffer.
00286   void reset (void);
00287 
00288   /// Add the length of each message block in the chain.
00289   size_t total_length (void) const;
00290 
00291   /**
00292    * Return the start of the message block chain for this CDR stream.
00293    * NOTE: The complete CDR stream is represented by a chain of
00294    * message blocks.
00295    */
00296   const ACE_Message_Block *begin (void) const;
00297 
00298   /// Return the last message in the chain that is is use.
00299   const ACE_Message_Block *end (void) const;
00300 
00301   /// Return the <current_> message block in chain.
00302   const ACE_Message_Block *current (void) const;
00303 
00304   /**
00305    * Access the underlying buffer (read only).  NOTE: This
00306    * method only returns a pointer to the first block in the
00307    * chain.
00308    */
00309   const char *buffer (void) const;
00310 
00311   /**
00312    * Return the start and size of the internal buffer.NOTE: This
00313    * method only returns information about the first block in the
00314    * chain.
00315    */
00316   size_t length (void) const;
00317 
00318   /**
00319    * Utility function to allow the user more flexibility.
00320    * Pads the stream up to the nearest <alignment>-byte boundary.
00321    * Argument MUST be a power of 2.
00322    * Returns 0 on success and -1 on failure.
00323    */
00324   int align_write_ptr (size_t alignment);
00325 
00326   /// Access the codeset translators. They can be null!
00327   ACE_Char_Codeset_Translator *char_translator (void) const;
00328   ACE_WChar_Codeset_Translator *wchar_translator (void) const;
00329 
00330   /// Set the char codeset translator.
00331   void char_translator (ACE_Char_Codeset_Translator *);
00332   /// Set the wchar codeset translator.
00333   void wchar_translator (ACE_WChar_Codeset_Translator *);
00334 
00335   /// set the global size of serialized wchars. This may be different
00336   /// than the size of a wchar_t.
00337   static void wchar_maxbytes (int );
00338 
00339   /// access the serialized size of wchars.
00340   static int wchar_maxbytes (void);
00341 
00342   /**
00343    * Return alignment of the wr_ptr(), with respect to the start of
00344    * the CDR stream.  This is not the same as the alignment of
00345    * current->wr_ptr()!
00346    */
00347   size_t current_alignment (void) const;
00348 
00349   /**
00350    * Returns (in <buf>) the next position in the buffer aligned to
00351    * <size>, it advances the Message_Block wr_ptr past the data
00352    * (i.e., <buf> + <size>). If necessary it grows the Message_Block
00353    * buffer.  Sets the good_bit to 0 and returns a -1 on failure.
00354    */
00355   int adjust (size_t size,
00356               char *&buf);
00357 
00358   /// As above, but now the size and alignment requirements may be
00359   /// different.
00360   int adjust (size_t size,
00361               size_t align,
00362               char *&buf);
00363 
00364   /// If non-zero then this stream is writing in non-native byte order,
00365   /// this is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined.
00366   int do_byte_swap (void) const;
00367 
00368   /// For use by a gateway, which creates the output stream for the
00369   /// reply to the client in its native byte order, but which must
00370   /// send the reply in the byte order of the target's reply to the
00371   /// gateway.
00372   void reset_byte_order (int byte_order);
00373 
00374   /// set GIOP version info
00375   int set_version (ACE_CDR::Octet major,
00376                    ACE_CDR::Octet minor);
00377 
00378   /// Set the underlying GIOP version..
00379   int get_version (ACE_CDR::Octet &major,
00380                    ACE_CDR::Octet &minor);
00381 private:
00382   /// disallow copying...
00383   ACE_OutputCDR (const ACE_OutputCDR& rhs);
00384   ACE_OutputCDR& operator= (const ACE_OutputCDR& rhs);
00385 
00386   ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x);
00387   ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x);
00388   ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x);
00389   ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x);
00390   ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x);
00391 
00392   /**
00393    * write an array of <length> elements, each of <size> bytes and the
00394    * start aligned at a multiple of <align>. The elements are assumed
00395    * to be packed with the right alignment restrictions.  It is mostly
00396    * designed for buffers of the basic types.
00397    *
00398    * This operation uses <memcpy>; as explained above it is expected
00399    * that using assignment is faster that <memcpy> for one element,
00400    * but for several elements <memcpy> should be more efficient, it
00401    * could be interesting to find the break even point and optimize
00402    * for that case, but that would be too platform dependent.
00403    */
00404   ACE_CDR::Boolean write_array (const void *x,
00405                                 size_t size,
00406                                 size_t align,
00407                                 ACE_CDR::ULong length);
00408 
00409 
00410   ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x,
00411                                         ACE_CDR::ULong length);
00412 
00413 
00414   /**
00415    * Grow the CDR stream. When it returns <buf> contains a pointer to
00416    * memory in the CDR stream, with at least <size> bytes ahead of it
00417    * and aligned to an <align> boundary. It moved the <wr_ptr> to <buf
00418    * + size>.
00419    */
00420   int grow_and_adjust (size_t size,
00421                        size_t align,
00422                        char *&buf);
00423 
00424 private:
00425   /// The start of the chain of message blocks.
00426   ACE_Message_Block start_;
00427 
00428   /// The current block in the chain were we are writing.
00429   ACE_Message_Block *current_;
00430 
00431   /**
00432    * Is the current block writable.  When we steal a buffer from the
00433    * user and just chain it into the message block we are not supposed
00434    * to write on it, even if it is past the start and end of the
00435    * buffer.
00436    */
00437   int current_is_writable_;
00438 
00439   /**
00440    * The current alignment as measured from the start of the buffer.
00441    * Usually this coincides with the alignment of the buffer in
00442    * memory, but, when we chain another buffer this "quasi invariant"
00443    * is broken.
00444    * The current_alignment is used to readjust the buffer following
00445    * the stolen message block.
00446    */
00447   size_t current_alignment_;
00448 
00449   /**
00450    * If not zero swap bytes at writing so the created CDR stream byte
00451    * order does *not* match the machine byte order.  The motivation
00452    * for such a beast is that in some setting a few (fast) machines
00453    * can be serving hundreds of slow machines with the opposite byte
00454    * order, so it makes sense (as a load balancing device) to put the
00455    * responsability in the writers.  THIS IS NOT A STANDARD IN CORBA,
00456    * USE AT YOUR OWN RISK
00457    */
00458   int do_byte_swap_;
00459 
00460   /// Set to 0 when an error ocurrs.
00461   int good_bit_;
00462 
00463   /// Break-even point for copying.
00464   size_t memcpy_tradeoff_;
00465 
00466 protected:
00467   /// GIOP version information
00468   ACE_CDR::Octet major_version_;
00469   ACE_CDR::Octet minor_version_;
00470 
00471   /// If not nil, invoke for translation of character and string data.
00472   ACE_Char_Codeset_Translator *char_translator_;
00473   ACE_WChar_Codeset_Translator *wchar_translator_;
00474 
00475   /**
00476    * Some wide char codesets may be defined with a maximum number
00477    * of bytes that is smaller than the size of a wchar_t. This means
00478    * that the CDR cannot simply memcpy a block of wchars to and from
00479    * the stream, but must instead realign the bytes appropriately.
00480    * In cases when wchar i/o is not allowed, such as with GIOP 1.0,
00481    * or not having a native wchar codeset defined, the maxbytes is
00482    * set to zero, indicating no wchar data is allowed.
00483    */
00484   static int wchar_maxbytes_;
00485 };
00486 
00487 // ****************************************************************
00488 
00489 /**
00490  * @class ACE_InputCDR
00491  *
00492  * @brief A CDR stream for reading, i.e. for demarshalling.
00493  *
00494  * This class is based on the the CORBA spec for Java (98-02-29),
00495  * java class omg.org.CORBA.portable.InputStream.  It diverts in a
00496  * few ways:
00497  * + Operations to retrieve basic types take parameters by
00498  * reference.
00499  * + Operations taking arrays don't have offsets, because in C++
00500  * it is easier to describe an array starting from x+offset.
00501  * + Operations return an error status, because exceptions are
00502  * not widely available in C++ (yet).
00503  */
00504 class ACE_Export ACE_InputCDR
00505 {
00506 public:
00507   /// The translator need privileged access to efficiently demarshal
00508   /// arrays and the such
00509   friend class ACE_Char_Codeset_Translator;
00510   friend class ACE_WChar_Codeset_Translator;
00511 
00512   /**
00513    * Create an input stream from an arbitrary buffer.  The buffer must
00514    * be properly aligned because this contructor will *not* work if
00515    * the buffer is aligned unproperly.See ACE_ptr_align_binary() for
00516    * instructions on how to align a pointer properly and use
00517    * ACE_CDR::MAX_ALIGNMENT for the correct alignment.
00518    */
00519   ACE_InputCDR (const char *buf,
00520                 size_t bufsiz,
00521                 int byte_order = ACE_CDR_BYTE_ORDER,
00522                 ACE_CDR::Octet major_version =
00523                 ACE_CDR_GIOP_MAJOR_VERSION,
00524                 ACE_CDR::Octet minor_version =
00525                 ACE_CDR_GIOP_MINOR_VERSION);
00526 
00527   /// Create an empty input stream. The caller is responsible for
00528   /// putting the right data and providing the right alignment.
00529   ACE_InputCDR (size_t bufsiz,
00530                 int byte_order = ACE_CDR_BYTE_ORDER,
00531                 ACE_CDR::Octet major_version =
00532                 ACE_CDR_GIOP_MAJOR_VERSION,
00533                 ACE_CDR::Octet minor_version =
00534                 ACE_CDR_GIOP_MINOR_VERSION);
00535 
00536   /// Create an input stream from an ACE_Message_Block
00537   /**
00538    * The alignment of the @arg data block is carried into the new
00539    * ACE_InputCDR object. This constructor either increments the
00540    * @arg data reference count, or copies the data (if it's a compound
00541    * message block) so the caller can release the block immediately
00542    * upon return.
00543    */
00544   ACE_InputCDR (const ACE_Message_Block *data,
00545                 int byte_order = ACE_CDR_BYTE_ORDER,
00546                 ACE_CDR::Octet major_version =
00547                 ACE_CDR_GIOP_MAJOR_VERSION,
00548                 ACE_CDR::Octet minor_version =
00549                 ACE_CDR_GIOP_MINOR_VERSION);
00550 
00551   /// Create an input stream from an ACE_Data_Block. The <flag>
00552   /// indicates whether the <data> can be deleted by the CDR stream
00553   /// or not
00554   ACE_InputCDR (ACE_Data_Block *data,
00555                 ACE_Message_Block::Message_Flags flag = 0,
00556                 int byte_order = ACE_CDR_BYTE_ORDER,
00557                 ACE_CDR::Octet major_version =
00558                 ACE_CDR_GIOP_MAJOR_VERSION,
00559                 ACE_CDR::Octet minor_version =
00560                 ACE_CDR_GIOP_MINOR_VERSION);
00561 
00562   /// Create an input stream from an ACE_Data_Block. It also sets the
00563   /// read and write pointers at the desired positions. This would be
00564   /// helpful if the applications desires to create a new CDR stream
00565   /// from a semi-processed datablock.
00566   ACE_InputCDR (ACE_Data_Block *data,
00567                 ACE_Message_Block::Message_Flags flag,
00568                 size_t read_pointer_position,
00569                 size_t write_pointer_position,
00570                 int byte_order = ACE_CDR_BYTE_ORDER,
00571                 ACE_CDR::Octet major_version =
00572                 ACE_CDR_GIOP_MAJOR_VERSION,
00573                 ACE_CDR::Octet minor_version =
00574                 ACE_CDR_GIOP_MINOR_VERSION);
00575 
00576   /**
00577    * These make a copy of the current stream state, but do not copy
00578    * the internal buffer, so the same stream can be read multiple
00579    * times efficiently.
00580    */
00581   ACE_InputCDR (const ACE_InputCDR& rhs);
00582 
00583   ACE_InputCDR& operator= (const ACE_InputCDR& rhs);
00584 
00585   /// When interpreting indirected TypeCodes it is useful to make a
00586   /// "copy" of the stream starting in the new position.
00587   ACE_InputCDR (const ACE_InputCDR& rhs,
00588                 size_t size,
00589                 ACE_CDR::Long offset);
00590 
00591   /// This creates an encapsulated stream, the first byte must be (per
00592   /// the spec) the byte order of the encapsulation.
00593   ACE_InputCDR (const ACE_InputCDR& rhs,
00594                 size_t size);
00595 
00596   /// Create an input CDR from an output CDR.
00597   ACE_InputCDR (const ACE_OutputCDR& rhs,
00598                 ACE_Allocator* buffer_allocator = 0,
00599                 ACE_Allocator* data_block_allocator = 0,
00600                 ACE_Allocator* message_block_allocator = 0);
00601 
00602   /// Helper class to transfer the contents from one input CDR to
00603   /// another without requiring any extra memory allocations, data
00604   /// copies or too many temporaries.
00605   struct ACE_Export Transfer_Contents
00606   {
00607     Transfer_Contents (ACE_InputCDR &rhs);
00608 
00609     ACE_InputCDR &rhs_;
00610   };
00611   /// Transfer the contents from <rhs> to a new CDR
00612   ACE_InputCDR (Transfer_Contents rhs);
00613 
00614   /// Destructor
00615   ~ACE_InputCDR (void);
00616 
00617   /// Disambiguate overloading when extracting octets, chars,
00618   /// booleans, and bounded strings
00619   //@{ @name Helper classes
00620 
00621   struct ACE_Export to_boolean
00622   {
00623     to_boolean (ACE_CDR::Boolean &b);
00624     ACE_CDR::Boolean &ref_;
00625   };
00626 
00627   struct ACE_Export to_char
00628   {
00629     to_char (ACE_CDR::Char &c);
00630     ACE_CDR::Char &ref_;
00631   };
00632 
00633   struct ACE_Export to_wchar
00634   {
00635     to_wchar (ACE_CDR::WChar &wc);
00636     ACE_CDR::WChar &ref_;
00637   };
00638 
00639   struct ACE_Export to_octet
00640   {
00641     to_octet (ACE_CDR::Octet &o);
00642     ACE_CDR::Octet &ref_;
00643   };
00644 
00645   struct ACE_Export to_string
00646   {
00647     /// The constructor taking a non-const string is
00648     /// now deprecated (C++ mapping 00-01-02), but we
00649     /// keep it around for backward compatibility.
00650     to_string (ACE_CDR::Char *&s,
00651                ACE_CDR::ULong b);
00652     to_string (const ACE_CDR::Char *&s,
00653                ACE_CDR::ULong b);
00654     const ACE_CDR::Char *&val_;
00655     ACE_CDR::ULong bound_;
00656   };
00657 
00658   struct ACE_Export to_wstring
00659   {
00660     /// The constructor taking a non-const wstring is
00661     /// now deprecated (C++ mapping 00-01-02), but we
00662     /// keep it around for backward compatibility.
00663     to_wstring (ACE_CDR::WChar *&ws,
00664                 ACE_CDR::ULong b);
00665     to_wstring (const ACE_CDR::WChar *&ws,
00666                 ACE_CDR::ULong b);
00667     const ACE_CDR::WChar *&val_;
00668     ACE_CDR::ULong bound_;
00669   };
00670   //@}
00671 
00672   /**
00673    * Return 0 on failure and 1 on success.
00674    */
00675   //@{ @name Read basic IDL types
00676   ACE_CDR::Boolean read_boolean (ACE_CDR::Boolean& x);
00677   ACE_CDR::Boolean read_char (ACE_CDR::Char &x);
00678   ACE_CDR::Boolean read_wchar (ACE_CDR::WChar& x);
00679   ACE_CDR::Boolean read_octet (ACE_CDR::Octet& x);
00680   ACE_CDR::Boolean read_short (ACE_CDR::Short &x);
00681   ACE_CDR::Boolean read_ushort (ACE_CDR::UShort &x);
00682   ACE_CDR::Boolean read_long (ACE_CDR::Long &x);
00683   ACE_CDR::Boolean read_ulong (ACE_CDR::ULong &x);
00684   ACE_CDR::Boolean read_longlong (ACE_CDR::LongLong& x);
00685   ACE_CDR::Boolean read_ulonglong (ACE_CDR::ULongLong& x);
00686   ACE_CDR::Boolean read_float (ACE_CDR::Float &x);
00687   ACE_CDR::Boolean read_double (ACE_CDR::Double &x);
00688   ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x);
00689 
00690   ACE_CDR::Boolean read_string (ACE_CDR::Char *&x);
00691   ACE_CDR::Boolean read_string (ACE_CString &x);
00692   ACE_CDR::Boolean read_wstring (ACE_CDR::WChar*& x);
00693   //@}
00694 
00695   /**
00696    * The buffer <x> must be large enough to contain <length>
00697    * elements.
00698    * Return 0 on failure and 1 on success.
00699    */
00700   //@{ @name Read basic IDL types arrays
00701   ACE_CDR::Boolean read_boolean_array (ACE_CDR::Boolean* x,
00702                                        ACE_CDR::ULong length);
00703   ACE_CDR::Boolean read_char_array (ACE_CDR::Char *x,
00704                                     ACE_CDR::ULong length);
00705   ACE_CDR::Boolean read_wchar_array (ACE_CDR::WChar* x,
00706                                      ACE_CDR::ULong length);
00707   ACE_CDR::Boolean read_octet_array (ACE_CDR::Octet* x,
00708                                      ACE_CDR::ULong length);
00709   ACE_CDR::Boolean read_short_array (ACE_CDR::Short *x,
00710                                      ACE_CDR::ULong length);
00711   ACE_CDR::Boolean read_ushort_array (ACE_CDR::UShort *x,
00712                                       ACE_CDR::ULong length);
00713   ACE_CDR::Boolean read_long_array (ACE_CDR::Long *x,
00714                                     ACE_CDR::ULong length);
00715   ACE_CDR::Boolean read_ulong_array (ACE_CDR::ULong *x,
00716                                      ACE_CDR::ULong length);
00717   ACE_CDR::Boolean read_longlong_array (ACE_CDR::LongLong* x,
00718                                         ACE_CDR::ULong length);
00719   ACE_CDR::Boolean read_ulonglong_array (ACE_CDR::ULongLong* x,
00720                                          ACE_CDR::ULong length);
00721   ACE_CDR::Boolean read_float_array (ACE_CDR::Float *x,
00722                                      ACE_CDR::ULong length);
00723   ACE_CDR::Boolean read_double_array (ACE_CDR::Double *x,
00724                                       ACE_CDR::ULong length);
00725   ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble* x,
00726                                           ACE_CDR::ULong length);
00727   //@}
00728 
00729   /**
00730    * Return 0 on failure and 1 on success.
00731    */
00732   //@{ @name Skip elements
00733   ACE_CDR::Boolean skip_boolean (void);
00734   ACE_CDR::Boolean skip_char (void);
00735   ACE_CDR::Boolean skip_wchar (void);
00736   ACE_CDR::Boolean skip_octet (void);
00737   ACE_CDR::Boolean skip_short (void);
00738   ACE_CDR::Boolean skip_ushort (void);
00739   ACE_CDR::Boolean skip_long (void);
00740   ACE_CDR::Boolean skip_ulong (void);
00741   ACE_CDR::Boolean skip_longlong (void);
00742   ACE_CDR::Boolean skip_ulonglong (void);
00743   ACE_CDR::Boolean skip_float (void);
00744   ACE_CDR::Boolean skip_double (void);
00745   ACE_CDR::Boolean skip_longdouble (void);
00746   //@}
00747 
00748   /**
00749    * The next field must be a string, this method skips it. It is
00750    * useful in parsing a TypeCode.
00751    * Return 0 on failure and 1 on success.
00752    */
00753   ACE_CDR::Boolean skip_wstring (void);
00754   ACE_CDR::Boolean skip_string (void);
00755 
00756   /// Skip <n> bytes in the CDR stream.
00757   /// Return 0 on failure and 1 on success.
00758   ACE_CDR::Boolean skip_bytes (size_t n);
00759 
00760   /// returns zero if a problem has been detected.
00761   int good_bit (void) const;
00762 
00763   /**
00764    * Return the start of the message block chain for this CDR stream.
00765    * NOTE: In the current implementation the chain has length 1, but
00766    * we are planning to change that.
00767    */
00768   const ACE_Message_Block* start (void) const;
00769 
00770   // = The following functions are useful to read the contents of the
00771   //   CDR stream from a socket or file.
00772 
00773   /**
00774    * Grow the internal buffer, reset <rd_ptr> to the first byte in the
00775    * new buffer that is properly aligned, and set <wr_ptr> to <rd_ptr>
00776    * + newsize
00777    */
00778   int grow (size_t newsize);
00779 
00780   /**
00781    * After reading and partially parsing the contents the user can
00782    * detect a change in the byte order, this method will let him
00783    * change it.
00784    */
00785   void reset_byte_order (int byte_order);
00786 
00787   /// Re-initialize the CDR stream, copying the contents of the chain
00788   /// of message_blocks starting from <data>.
00789   void reset (const ACE_Message_Block *data,
00790               int byte_order);
00791 
00792   /// Steal the contents from the current CDR.
00793   ACE_Message_Block *steal_contents (void);
00794 
00795   /// Steal the contents of <cdr> and make a shallow copy into this
00796   /// stream.
00797   void steal_from (ACE_InputCDR &cdr);
00798 
00799   /// Exchange data blocks with the caller of this method. The read
00800   /// and write pointers are also exchanged.
00801   /// Note: We now do only with the start_ message block.
00802   void exchange_data_blocks (ACE_InputCDR &cdr);
00803 
00804   /// Copy the data portion from the <cdr> to this cdr and return the
00805   /// data content (ie. the ACE_Data_Block) from this CDR to the
00806   /// caller. The caller is responsible for managing the memory of the
00807   /// returned ACE_Data_Block.
00808   ACE_Data_Block* clone_from (ACE_InputCDR &cdr);
00809 
00810   /// Re-initialize the CDR stream, forgetting about the old contents
00811   /// of the stream and allocating a new buffer (from the allocators).
00812   void reset_contents (void);
00813 
00814   /// Returns the current position for the rd_ptr....
00815   char* rd_ptr (void);
00816 
00817   /// Returns the current position for the wr_ptr....
00818   char* wr_ptr (void);
00819 
00820   /// Return how many bytes are left in the stream.
00821   size_t length (void) const;
00822 
00823   /**
00824    * Utility function to allow the user more flexibility.
00825    * Skips up to the nearest <alignment>-byte boundary.
00826    * Argument MUST be a power of 2.
00827    * Returns 0 on success and -1 on failure.
00828    */
00829   int align_read_ptr (size_t alignment);
00830 
00831   /// If non-zero then this stream is writing in non-native byte order,
00832   /// this is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined.
00833   int do_byte_swap (void) const;
00834 
00835   /// If <do_byte_swap> returns 0, this returns ACE_CDR_BYTE_ORDER else
00836   /// it returns !ACE_CDR_BYTE_ORDER.
00837   int byte_order (void) const;
00838 
00839   /// Access the codeset translators. They can be nil!
00840   ACE_Char_Codeset_Translator *char_translator (void) const;
00841   ACE_WChar_Codeset_Translator *wchar_translator (void) const;
00842 
00843   /// Set the codeset translators.
00844   void char_translator (ACE_Char_Codeset_Translator *);
00845   void wchar_translator (ACE_WChar_Codeset_Translator *);
00846 
00847   /**
00848    * Returns (in <buf>) the next position in the buffer aligned to
00849    * <size>, it advances the Message_Block rd_ptr past the data
00850    * (i.e., <buf> + <size>).  Sets the good_bit to 0 and returns a -1
00851    * on failure.
00852    */
00853   int adjust (size_t size,
00854               char *&buf);
00855 
00856   /// As above, but now the size and alignment requirements may be
00857   /// different.
00858   int adjust (size_t size,
00859               size_t align,
00860               char *&buf);
00861 
00862   /// Set the underlying GIOP version..
00863   int set_version (ACE_CDR::Octet major,
00864                    ACE_CDR::Octet minor);
00865 
00866   /// Set the underlying GIOP version..
00867   int get_version (ACE_CDR::Octet &major,
00868                    ACE_CDR::Octet &minor);
00869 protected:
00870   /// The start of the chain of message blocks, even though in the
00871   /// current version the chain always has length 1.
00872   ACE_Message_Block start_;
00873 
00874   /// The CDR stream byte order does not match the one on the machine,
00875   /// swapping is needed while reading.
00876   int do_byte_swap_;
00877 
00878   /// set to 0 when an error occurs.
00879   int good_bit_;
00880 
00881   /// The GIOP versions for this stream
00882   ACE_CDR::Octet major_version_;
00883   ACE_CDR::Octet minor_version_;
00884 
00885   /// If not nil, invoke for translation of character and string data.
00886   ACE_Char_Codeset_Translator *char_translator_;
00887   ACE_WChar_Codeset_Translator *wchar_translator_;
00888 
00889 private:
00890   ACE_CDR::Boolean read_1 (ACE_CDR::Octet *x);
00891   ACE_CDR::Boolean read_2 (ACE_CDR::UShort *x);
00892   ACE_CDR::Boolean read_4 (ACE_CDR::ULong *x);
00893   ACE_CDR::Boolean read_8 (ACE_CDR::ULongLong *x);
00894   ACE_CDR::Boolean read_16 (ACE_CDR::LongDouble *x);
00895 
00896   // Several types can be read using the same routines, since TAO
00897   // tries to use native types with known size for each CORBA type.
00898   // We could use void* or char* to make the interface more
00899   // consistent, but using native types let us exploit the strict
00900   // alignment requirements of CDR streams and implement the
00901   // operations using asignment.
00902 
00903   /**
00904    * Read an array of <length> elements, each of <size> bytes and the
00905    * start aligned at a multiple of <align>. The elements are assumed
00906    * to be packed with the right alignment restrictions.  It is mostly
00907    * designed for buffers of the basic types.
00908    *
00909    * This operation uses <memcpy>; as explained above it is expected
00910    * that using assignment is faster that <memcpy> for one element,
00911    * but for several elements <memcpy> should be more efficient, it
00912    * could be interesting to find the break even point and optimize
00913    * for that case, but that would be too platform dependent.
00914    */
00915   ACE_CDR::Boolean read_array (void* x,
00916                                size_t size,
00917                                size_t align,
00918                                ACE_CDR::ULong length);
00919 
00920   /**
00921    * On those occasions when the native codeset for wchar is smaller than
00922    * the size of a wchar_t, such as using UTF-16 with a 4-byte wchar_t, a
00923    * special form of reading the array is needed. Actually, this should be
00924    * a default translator.
00925    */
00926   ACE_CDR::Boolean read_wchar_array_i (ACE_CDR::WChar * x,
00927                                        ACE_CDR::ULong length);
00928 
00929   /// Move the rd_ptr ahead by <offset> bytes.
00930   void rd_ptr (size_t offset);
00931 
00932   /// Points to the continuation field of the current message block.
00933   char* end (void);
00934 };
00935 
00936 // ****************************************************************
00937 
00938 /**
00939  * @class ACE_Char_Codeset_Translator
00940  *
00941  * @brief Codeset translation routines common to both Output and Input
00942  * CDR streams.
00943  *
00944  * This class is a base class for defining codeset translation
00945  * routines to handle the character set translations required by
00946  * both CDR Input streams and CDR Output streams.
00947  *
00948  * Translators are reference counted. This allows for stateful as well
00949  * as stateless translators. Stateless translators will be allocated
00950  * once whereas CDR Streams own their own copy of a stateful translator.
00951  */
00952 class ACE_Export ACE_Char_Codeset_Translator
00953 {
00954 public:
00955   virtual ~ACE_Char_Codeset_Translator () {};
00956 
00957   /// Read a single character from the stream, converting from the
00958   /// stream codeset to the native codeset
00959   virtual ACE_CDR::Boolean read_char (ACE_InputCDR&,
00960                                       ACE_CDR::Char&) = 0;
00961 
00962   /// Read a string from the stream, including the length, converting
00963   /// the characters from the stream codeset to the native codeset
00964   virtual ACE_CDR::Boolean read_string (ACE_InputCDR&,
00965                                         ACE_CDR::Char *&) = 0;
00966 
00967   /// Read an array of characters from the stream, converting the
00968   /// characters from the stream codeset to the native codeset.
00969   virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR&,
00970                                             ACE_CDR::Char*,
00971                                             ACE_CDR::ULong) = 0;
00972 
00973   /// Write a single character to the stream, converting from the
00974   /// native codeset to the stream codeset
00975   virtual ACE_CDR::Boolean write_char (ACE_OutputCDR&,
00976                                        ACE_CDR::Char) = 0;
00977 
00978   /// Write a string to the stream, including the length, converting
00979   /// from the native codeset to the stream codeset
00980   virtual ACE_CDR::Boolean write_string (ACE_OutputCDR&,
00981                                          ACE_CDR::ULong,
00982                                          const ACE_CDR::Char*) = 0;
00983 
00984   /// Write an array of characters to the stream, converting from the
00985   /// native codeset to the stream codeset
00986   virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR&,
00987                                              const ACE_CDR::Char*,
00988                                              ACE_CDR::ULong) = 0;
00989 
00990   virtual ACE_CDR::ULong ncs () = 0;
00991   virtual ACE_CDR::ULong tcs () = 0;
00992 protected:
00993   /// Children have access to low-level routines because they cannot
00994   /// use read_char or something similar (it would recurse).
00995   ACE_CDR::Boolean read_1 (ACE_InputCDR& input,
00996                            ACE_CDR::Octet *x);
00997   ACE_CDR::Boolean write_1 (ACE_OutputCDR& output,
00998                             const ACE_CDR::Octet *x);
00999 
01000   /// Efficiently read <length> elements of size <size> each from
01001   /// <input> into <x>; the data must be aligned to <align>.
01002   ACE_CDR::Boolean read_array (ACE_InputCDR& input,
01003                                void* x,
01004                                size_t size,
01005                                size_t align,
01006                                ACE_CDR::ULong length);
01007 
01008   /**
01009    * Efficiently write <length> elements of size <size> from <x> into
01010    * <output>. Before inserting the elements enough padding is added
01011    * to ensure that the elements will be aligned to <align> in the
01012    * stream.
01013    */
01014   ACE_CDR::Boolean write_array (ACE_OutputCDR& output,
01015                                 const void *x,
01016                                 size_t size,
01017                                 size_t align,
01018                                 ACE_CDR::ULong length);
01019 
01020   /**
01021    * Exposes the stream implementation of <adjust>, this is useful in
01022    * many cases to minimize memory allocations during marshaling.
01023    * On success <buf> will contain a contiguous area in the CDR stream
01024    * that can hold <size> bytes aligned to <align>.
01025    * Results
01026    */
01027   int adjust (ACE_OutputCDR& out,
01028               size_t size,
01029               size_t align,
01030               char *&buf);
01031 
01032   /// Used by derived classes to set errors in the CDR stream.
01033   void good_bit (ACE_OutputCDR& out, int bit);
01034 
01035   /// Obtain the CDR Stream's major & minor version values.
01036   ACE_CDR::Octet major_version (ACE_InputCDR& input);
01037   ACE_CDR::Octet minor_version (ACE_InputCDR& input);
01038   ACE_CDR::Octet major_version (ACE_OutputCDR& output);
01039   ACE_CDR::Octet minor_version (ACE_OutputCDR& output);
01040 };
01041 
01042 // ****************************************************************
01043 
01044 /**
01045  * @class ACE_WChar_Codeset_Translator
01046  *
01047  * @brief Codeset translation routines common to both Output and Input
01048  * CDR streams.
01049  *
01050  * This class is a base class for defining codeset translation
01051  * routines to handle the character set translations required by
01052  * both CDR Input streams and CDR Output streams.
01053  */
01054 class ACE_Export ACE_WChar_Codeset_Translator
01055 {
01056 public:
01057   virtual ~ACE_WChar_Codeset_Translator () {}
01058 
01059   virtual ACE_CDR::Boolean read_wchar (ACE_InputCDR&,
01060                                        ACE_CDR::WChar&) = 0;
01061   virtual ACE_CDR::Boolean read_wstring (ACE_InputCDR&,
01062                                          ACE_CDR::WChar *&) = 0;
01063   virtual ACE_CDR::Boolean read_wchar_array (ACE_InputCDR&,
01064                                              ACE_CDR::WChar*,
01065                                              ACE_CDR::ULong) = 0;
01066   virtual ACE_CDR::Boolean write_wchar (ACE_OutputCDR&,
01067                                         ACE_CDR::WChar) = 0;
01068   virtual ACE_CDR::Boolean write_wstring (ACE_OutputCDR&,
01069                                           ACE_CDR::ULong,
01070                                           const ACE_CDR::WChar*) = 0;
01071   virtual ACE_CDR::Boolean write_wchar_array (ACE_OutputCDR&,
01072                                               const ACE_CDR::WChar*,
01073                                               ACE_CDR::ULong) = 0;
01074 
01075   virtual ACE_CDR::ULong ncs () = 0;
01076   virtual ACE_CDR::ULong tcs () = 0;
01077 protected:
01078   /// Children have access to low-level routines because they cannot
01079   /// use read_char or something similar (it would recurse).
01080   ACE_CDR::Boolean read_1 (ACE_InputCDR& input,
01081                            ACE_CDR::Octet *x);
01082   ACE_CDR::Boolean read_2 (ACE_InputCDR& input,
01083                            ACE_CDR::UShort *x);
01084   ACE_CDR::Boolean read_4 (ACE_InputCDR& input,
01085                            ACE_CDR::ULong *x);
01086   ACE_CDR::Boolean write_1 (ACE_OutputCDR& output,
01087                             const ACE_CDR::Octet *x);
01088   ACE_CDR::Boolean write_2 (ACE_OutputCDR& output,
01089                             const ACE_CDR::UShort *x);
01090   ACE_CDR::Boolean write_4 (ACE_OutputCDR& output,
01091                             const ACE_CDR::ULong *x);
01092 
01093   /// Efficiently read <length> elements of size <size> each from
01094   /// <input> into <x>; the data must be aligned to <align>.
01095   ACE_CDR::Boolean read_array (ACE_InputCDR& input,
01096                                void* x,
01097                                size_t size,
01098                                size_t align,
01099                                ACE_CDR::ULong length);
01100 
01101   /**
01102    * Efficiently write <length> elements of size <size> from <x> into
01103    * <output>. Before inserting the elements enough padding is added
01104    * to ensure that the elements will be aligned to <align> in the
01105    * stream.
01106    */
01107   ACE_CDR::Boolean write_array (ACE_OutputCDR& output,
01108                                 const void *x,
01109                                 size_t size,
01110                                 size_t align,
01111                                 ACE_CDR::ULong length);
01112 
01113   /**
01114    * Exposes the stream implementation of <adjust>, this is useful in
01115    * many cases to minimize memory allocations during marshaling.
01116    * On success <buf> will contain a contiguous area in the CDR stream
01117    * that can hold <size> bytes aligned to <align>.
01118    * Results
01119    */
01120   int adjust (ACE_OutputCDR& out,
01121               size_t size,
01122               size_t align,
01123               char *&buf);
01124 
01125   /// Used by derived classes to set errors in the CDR stream.
01126   void good_bit (ACE_OutputCDR& out, int bit);
01127 
01128   /// Obtain the CDR Stream's major & minor version values.
01129   ACE_CDR::Octet major_version (ACE_InputCDR& input);
01130   ACE_CDR::Octet minor_version (ACE_InputCDR& input);
01131   ACE_CDR::Octet major_version (ACE_OutputCDR& output);
01132   ACE_CDR::Octet minor_version (ACE_OutputCDR& output);
01133 
01134 };
01135 
01136 // @@ These operators should not be inlined since they force SString.h
01137 //    to be included in this header.
01138 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01139                                                const ACE_CString &x);
01140 
01141 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01142                                                ACE_CString &x);
01143 
01144 
01145 #if defined (__ACE_INLINE__)
01146 # include "ace/CDR_Stream.i"
01147 #else /* __ACE_INLINE__ */
01148 
01149 // Not used by CORBA or TAO
01150 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01151                                                ACE_CDR::Char x);
01152 // CDR output operators for primitive types
01153 
01154 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01155                                                ACE_CDR::Short x);
01156 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01157                                                ACE_CDR::UShort x);
01158 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01159                                                ACE_CDR::Long x);
01160 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01161                                                ACE_CDR::ULong x);
01162 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01163                                                ACE_CDR::LongLong x);
01164 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01165                                                ACE_CDR::ULongLong x);
01166 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR& os,
01167                                                ACE_CDR::LongDouble x);
01168 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01169                                                ACE_CDR::Float x);
01170 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01171                                                ACE_CDR::Double x);
01172 
01173 // CDR output operator from helper classes
01174 
01175 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01176                                                ACE_OutputCDR::from_boolean x);
01177 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01178                                                ACE_OutputCDR::from_char x);
01179 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01180                                                ACE_OutputCDR::from_wchar x);
01181 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01182                                                ACE_OutputCDR::from_octet x);
01183 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01184                                                ACE_OutputCDR::from_string x);
01185 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01186                                                ACE_OutputCDR::from_wstring x);
01187 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01188                                                const ACE_CDR::Char* x);
01189 extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
01190                                                const ACE_CDR::WChar* x);
01191 
01192 // Not used by CORBA or TAO
01193 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01194                                                ACE_CDR::Char &x);
01195 // CDR input operators for primitive types
01196 
01197 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01198                                                ACE_CDR::Short &x);
01199 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01200                                                ACE_CDR::UShort &x);
01201 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01202                                                ACE_CDR::Long &x);
01203 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01204                                                ACE_CDR::ULong &x);
01205 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01206                                                ACE_CDR::LongLong &x);
01207 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01208                                                ACE_CDR::ULongLong &x);
01209 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01210                                                ACE_CDR::LongDouble &x);
01211 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01212                                                ACE_CDR::Float &x);
01213 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01214                                                ACE_CDR::Double &x);
01215 
01216 // CDR input operator from helper classes
01217 
01218 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01219                                                ACE_InputCDR::to_boolean x);
01220 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01221                                                ACE_InputCDR::to_char x);
01222 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01223                                                ACE_InputCDR::to_wchar x);
01224 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01225                                                ACE_InputCDR::to_octet x);
01226 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01227                                                ACE_InputCDR::to_string x);
01228 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01229                                                ACE_InputCDR::to_wstring x);
01230 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01231                                                ACE_CDR::Char*& x);
01232 extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
01233                                                ACE_CDR::WChar*& x);
01234 
01235 #endif /* __ACE_INLINE__ */
01236 
01237 #include "ace/post.h"
01238 
01239 #endif /* ACE_CDR_STREAM_H */

Generated on Mon Jun 16 11:19:21 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002