ACE_SizeCDR Class Reference

A CDR stream for calculating size of the representation. More...

#include <CDR_Size.h>

List of all members.
ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x, ACE_CDR::ULong length)
ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble *x, ACE_CDR::ULong length)
void adjust (size_t size)
void adjust (size_t size, size_t align)
ACE_CDR::Octet major_version_
 GIOP version information.
ACE_CDR::Octet minor_version_
 ACE_SizeCDR (const ACE_SizeCDR &rhs)
 disallow copying...
ACE_SizeCDRoperator= (const ACE_SizeCDR &rhs)
ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x)
ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x)
ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x)
ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x)
ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x)
ACE_CDR::Boolean write_array (const void *x, size_t size, size_t align, ACE_CDR::ULong length)
ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar *x, ACE_CDR::ULong length)
bool good_bit_
 Set to false when an error ocurrs.
size_t size_
 Current size.

Public Member Functions

 ACE_SizeCDR (ACE_CDR::Octet major_version=ACE_CDR_GIOP_MAJOR_VERSION, ACE_CDR::Octet minor_version=ACE_CDR_GIOP_MINOR_VERSION)
 Default constructor.
bool good_bit (void) const
 Returns false if an error has ocurred.
void reset (void)
 Reset current size.
size_t total_length (void) const
 Return current size.
ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x)
ACE_CDR::Boolean write_char (ACE_CDR::Char x)
ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x)
ACE_CDR::Boolean write_octet (ACE_CDR::Octet x)
ACE_CDR::Boolean write_short (ACE_CDR::Short x)
ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x)
ACE_CDR::Boolean write_long (ACE_CDR::Long x)
ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x)
ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x)
ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x)
ACE_CDR::Boolean write_float (ACE_CDR::Float x)
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x)
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x)
ACE_CDR::Boolean write_string (const ACE_CDR::Char *x)
 For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (ACE_CDR::ULong len, const ACE_CDR::Char *x)
ACE_CDR::Boolean write_string (const ACE_CString &x)
ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x)
ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, const ACE_CDR::WChar *x)


Detailed Description

A CDR stream for calculating size of the representation.

Definition at line 47 of file CDR_Size.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_SizeCDR::ACE_SizeCDR ( ACE_CDR::Octet  major_version = ACE_CDR_GIOP_MAJOR_VERSION,
ACE_CDR::Octet  minor_version = ACE_CDR_GIOP_MINOR_VERSION 
)

Default constructor.

Definition at line 10 of file CDR_Size.inl.

00012     : good_bit_ (true),
00013       size_ (0),
00014       major_version_ (major_version),
00015       minor_version_ (minor_version)
00016 {
00017 }

ACE_SizeCDR::ACE_SizeCDR ( const ACE_SizeCDR rhs  )  [private]

disallow copying...


Member Function Documentation

void ACE_SizeCDR::adjust ( size_t  size,
size_t  align 
)

As above, but now the size and alignment requirements may be different.

Definition at line 227 of file CDR_Size.cpp.

References ACE_align_binary(), and size_.

00229 {
00230 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00231   const size_t offset = ACE_align_binary (size_, align) - size_;
00232   size_ += offset;
00233 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00234   size_ += size;
00235 }

void ACE_SizeCDR::adjust ( size_t  size  ) 

Adjust to size and count <size> octets.

Definition at line 221 of file CDR_Size.cpp.

Referenced by write_1(), write_16(), write_2(), write_4(), write_8(), write_array(), write_boolean_array(), and write_wchar_array_i().

00222 {
00223   adjust (size, size);
00224 }

ACE_INLINE bool ACE_SizeCDR::good_bit ( void   )  const

Returns false if an error has ocurred.

Definition at line 20 of file CDR_Size.inl.

References good_bit_.

Referenced by operator<<().

00021 {
00022   return this->good_bit_;
00023 }

ACE_SizeCDR& ACE_SizeCDR::operator= ( const ACE_SizeCDR rhs  )  [private]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

ACE_INLINE void ACE_SizeCDR::reset ( void   ) 

Reset current size.

Definition at line 26 of file CDR_Size.inl.

References size_.

00027 {
00028   this->size_ = 0;
00029 }

ACE_INLINE size_t ACE_SizeCDR::total_length ( void   )  const

Return current size.

Definition at line 32 of file CDR_Size.inl.

References size_.

00033 {
00034   return this->size_;
00035 }

ACE_CDR::Boolean ACE_SizeCDR::write_1 ( const ACE_CDR::Octet x  )  [private]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 148 of file CDR_Size.cpp.

References adjust().

Referenced by write_char(), and write_octet().

00149 {
00150   this->adjust (1);
00151   return true;
00152 }

ACE_CDR::Boolean ACE_SizeCDR::write_16 ( const ACE_CDR::LongDouble x  )  [private]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 176 of file CDR_Size.cpp.

References adjust(), ACE_CDR::LONGDOUBLE_ALIGN, and ACE_CDR::LONGDOUBLE_SIZE.

Referenced by write_longdouble().

00177 {
00178   this->adjust (ACE_CDR::LONGDOUBLE_SIZE,
00179                 ACE_CDR::LONGDOUBLE_ALIGN);
00180   return true;
00181 }

ACE_CDR::Boolean ACE_SizeCDR::write_2 ( const ACE_CDR::UShort x  )  [private]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 155 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::SHORT_SIZE.

Referenced by write_short(), and write_ushort().

00156 {
00157   this->adjust (ACE_CDR::SHORT_SIZE);
00158   return true;
00159 }

ACE_CDR::Boolean ACE_SizeCDR::write_4 ( const ACE_CDR::ULong x  )  [private]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 162 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::LONG_SIZE.

Referenced by write_float(), write_long(), and write_ulong().

00163 {
00164   this->adjust (ACE_CDR::LONG_SIZE);
00165   return true;
00166 }

ACE_CDR::Boolean ACE_SizeCDR::write_8 ( const ACE_CDR::ULongLong x  )  [private]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 169 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::LONGLONG_SIZE.

Referenced by write_double(), write_longlong(), and write_ulonglong().

00170 {
00171   this->adjust (ACE_CDR::LONGLONG_SIZE);
00172   return true;
00173 }

ACE_CDR::Boolean ACE_SizeCDR::write_array ( const void *  x,
size_t  size,
size_t  align,
ACE_CDR::ULong  length 
) [private]

write an array of length elements, each of size bytes and the start aligned at a multiple of <align>. The elements are assumed to be packed with the right alignment restrictions. It is mostly designed for buffers of the basic types.

This operation uses <memcpy>; as explained above it is expected that using assignment is faster that <memcpy> for one element, but for several elements <memcpy> should be more efficient, it could be interesting to find the break even point and optimize for that case, but that would be too platform dependent.

Definition at line 200 of file CDR_Size.cpp.

References adjust().

Referenced by write_char_array(), write_double_array(), write_float_array(), write_long_array(), write_longdouble_array(), write_longlong_array(), write_octet_array(), write_short_array(), write_ulong_array(), write_ulonglong_array(), write_ushort_array(), and write_wchar_array().

00204 {
00205   if (length == 0)
00206     return true;
00207 
00208   this->adjust (size * length, align);
00209   return true;
00210 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_boolean ( ACE_CDR::Boolean  x  ) 

Definition at line 47 of file CDR_Size.inl.

References write_octet().

Referenced by operator<<().

00048 {
00049   return (ACE_CDR::Boolean) this->write_octet (x ? (ACE_CDR::Octet) 1 : (ACE_CDR::Octet) 0);
00050 }

ACE_CDR::Boolean ACE_SizeCDR::write_boolean_array ( const ACE_CDR::Boolean x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 213 of file CDR_Size.cpp.

References adjust().

00215 {
00216   this->adjust (length, 1);
00217   return true;
00218 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_char ( ACE_CDR::Char  x  ) 

Definition at line 53 of file CDR_Size.inl.

References write_1().

Referenced by operator<<().

00054 {
00055   // Note: translator framework is not supported.
00056   //
00057   return this->write_1 (reinterpret_cast<const ACE_CDR::Octet*> (&x));
00058 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_char_array ( const ACE_CDR::Char x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 143 of file CDR_Size.inl.

References ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, and write_array().

00145 {
00146   // Note: translator framework is not supported.
00147   //
00148   return this->write_array (x,
00149                             ACE_CDR::OCTET_SIZE,
00150                             ACE_CDR::OCTET_ALIGN,
00151                             length);
00152 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_double ( const ACE_CDR::Double x  ) 

Definition at line 105 of file CDR_Size.inl.

References write_8().

Referenced by operator<<().

00106 {
00107   const void *temp = &x;
00108   return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (temp));
00109 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_double_array ( const ACE_CDR::Double x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 257 of file CDR_Size.inl.

References ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, and write_array().

00259 {
00260   return this->write_array (x,
00261                             ACE_CDR::LONGLONG_SIZE,
00262                             ACE_CDR::LONGLONG_ALIGN,
00263                             length);
00264 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_float ( ACE_CDR::Float  x  ) 

Definition at line 98 of file CDR_Size.inl.

References write_4().

Referenced by operator<<().

00099 {
00100   const void *temp = &x;
00101   return this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
00102 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_float_array ( const ACE_CDR::Float x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 246 of file CDR_Size.inl.

References ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, and write_array().

00248 {
00249   return this->write_array (x,
00250                             ACE_CDR::LONG_SIZE,
00251                             ACE_CDR::LONG_ALIGN,
00252                             length);
00253 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_long ( ACE_CDR::Long  x  ) 

Definition at line 73 of file CDR_Size.inl.

References write_4().

Referenced by operator<<().

00074 {
00075   return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
00076 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_long_array ( const ACE_CDR::Long x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 206 of file CDR_Size.inl.

References ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, and write_array().

00208 {
00209   return this->write_array (x,
00210                             ACE_CDR::LONG_SIZE,
00211                             ACE_CDR::LONG_ALIGN,
00212                             length);
00213 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_longdouble ( const ACE_CDR::LongDouble x  ) 

Definition at line 112 of file CDR_Size.inl.

References write_16().

Referenced by operator<<().

00113 {
00114   const void *temp = &x;
00115   return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (temp));
00116 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_longdouble_array ( const ACE_CDR::LongDouble x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 267 of file CDR_Size.inl.

References ACE_CDR::LONGDOUBLE_ALIGN, ACE_CDR::LONGDOUBLE_SIZE, and write_array().

00269 {
00270   return this->write_array (x,
00271                             ACE_CDR::LONGDOUBLE_SIZE,
00272                             ACE_CDR::LONGDOUBLE_ALIGN,
00273                             length);
00274 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_longlong ( const ACE_CDR::LongLong x  ) 

Definition at line 85 of file CDR_Size.inl.

References write_8().

Referenced by operator<<().

00086 {
00087   return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
00088 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_longlong_array ( const ACE_CDR::LongLong x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 226 of file CDR_Size.inl.

References ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, and write_array().

00228 {
00229   return this->write_array (x,
00230                             ACE_CDR::LONGLONG_SIZE,
00231                             ACE_CDR::LONGLONG_ALIGN,
00232                             length);
00233 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_octet ( ACE_CDR::Octet  x  ) 

Definition at line 41 of file CDR_Size.inl.

References write_1().

Referenced by operator<<(), and write_boolean().

00042 {
00043   return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&x));
00044 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_octet_array ( const ACE_CDR::Octet x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 176 of file CDR_Size.inl.

References ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE, and write_array().

00178 {
00179   return this->write_array (x,
00180                             ACE_CDR::OCTET_SIZE,
00181                             ACE_CDR::OCTET_ALIGN,
00182                             length);
00183 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_short ( ACE_CDR::Short  x  ) 

Definition at line 61 of file CDR_Size.inl.

References write_2().

Referenced by operator<<().

00062 {
00063   return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
00064 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_short_array ( const ACE_CDR::Short x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 186 of file CDR_Size.inl.

References ACE_CDR::SHORT_ALIGN, ACE_CDR::SHORT_SIZE, and write_array().

00188 {
00189   return this->write_array (x,
00190                             ACE_CDR::SHORT_SIZE,
00191                             ACE_CDR::SHORT_ALIGN,
00192                             length);
00193 }

ACE_CDR::Boolean ACE_SizeCDR::write_string ( const ACE_CString x  ) 

Definition at line 100 of file CDR_Size.cpp.

References ACE_String_Base< CHAR >::c_str(), ACE_String_Base< CHAR >::length(), and write_string().

00101 {
00102   // @@ Leave this method in here, not the `.i' file so that we don't
00103   //    have to unnecessarily pull in the `ace/SString.h' header.
00104   return this->write_string (static_cast<ACE_CDR::ULong> (x.length ()),
00105                              x.c_str());
00106 }

ACE_CDR::Boolean ACE_SizeCDR::write_string ( ACE_CDR::ULong  len,
const ACE_CDR::Char x 
)

Definition at line 76 of file CDR_Size.cpp.

00078 {
00079   // Note: translator framework is not supported.
00080   //
00081   if (len != 0)
00082     {
00083       if (this->write_ulong (len + 1))
00084         return this->write_char_array (x, len + 1);
00085     }
00086   else
00087     {
00088       // Be nice to programmers: treat nulls as empty strings not
00089       // errors. (OMG-IDL supports languages that don't use the C/C++
00090       // notion of null v. empty strings; nulls aren't part of the OMG-IDL
00091       // string model.)
00092       if (this->write_ulong (1))
00093         return this->write_char (0);
00094     }
00095 
00096   return (this->good_bit_ = false);
00097 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_string ( const ACE_CDR::Char x  ) 

For string we offer methods that accept a precomputed length.

Definition at line 119 of file CDR_Size.inl.

References ACE_OS::strlen().

Referenced by operator<<(), and write_string().

00120 {
00121   if (x != 0)
00122     {
00123       const ACE_CDR::ULong len =
00124         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00125       return this->write_string (len, x);
00126     }
00127   return this->write_string (0, 0);
00128 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ulong ( ACE_CDR::ULong  x  ) 

Definition at line 79 of file CDR_Size.inl.

References write_4().

Referenced by operator<<(), and write_wstring().

00080 {
00081   return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
00082 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ulong_array ( const ACE_CDR::ULong x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 216 of file CDR_Size.inl.

References ACE_CDR::LONG_ALIGN, ACE_CDR::LONG_SIZE, and write_array().

00218 {
00219   return this->write_array (x,
00220                             ACE_CDR::LONG_SIZE,
00221                             ACE_CDR::LONG_ALIGN,
00222                             length);
00223 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ulonglong ( const ACE_CDR::ULongLong x  ) 

Definition at line 91 of file CDR_Size.inl.

References write_8().

Referenced by operator<<().

00092 {
00093   const void *temp = &x;
00094   return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong *> (temp));
00095 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ulonglong_array ( const ACE_CDR::ULongLong x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 236 of file CDR_Size.inl.

References ACE_CDR::LONGLONG_ALIGN, ACE_CDR::LONGLONG_SIZE, and write_array().

00238 {
00239   return this->write_array (x,
00240                             ACE_CDR::LONGLONG_SIZE,
00241                             ACE_CDR::LONGLONG_ALIGN,
00242                             length);
00243 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ushort ( ACE_CDR::UShort  x  ) 

Definition at line 67 of file CDR_Size.inl.

References write_2().

Referenced by operator<<().

00068 {
00069   return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
00070 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_ushort_array ( const ACE_CDR::UShort x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 196 of file CDR_Size.inl.

References ACE_CDR::SHORT_ALIGN, ACE_CDR::SHORT_SIZE, and write_array().

00198 {
00199   return this->write_array (x,
00200                             ACE_CDR::SHORT_SIZE,
00201                             ACE_CDR::SHORT_ALIGN,
00202                             length);
00203 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_CDR::Boolean ACE_SizeCDR::write_wchar ( ACE_CDR::WChar  x  ) 

Definition at line 16 of file CDR_Size.cpp.

References ACE_OutputCDR::wchar_maxbytes().

Referenced by operator<<().

00017 {
00018   // Note: translator framework is not supported.
00019   //
00020   if (ACE_OutputCDR::wchar_maxbytes () == 0)
00021     {
00022       errno = EACCES;
00023       return (this->good_bit_ = false);
00024     }
00025   if (static_cast<ACE_CDR::Short> (major_version_) == 1
00026           && static_cast<ACE_CDR::Short> (minor_version_) == 2)
00027     {
00028       ACE_CDR::Octet len =
00029         static_cast<ACE_CDR::Octet> (ACE_OutputCDR::wchar_maxbytes ());
00030       if (this->write_1 (&len))
00031         {
00032           if (ACE_OutputCDR::wchar_maxbytes () == sizeof(ACE_CDR::WChar))
00033             return
00034               this->write_octet_array (
00035                 reinterpret_cast<const ACE_CDR::Octet*> (&x),
00036                 static_cast<ACE_CDR::ULong> (len));
00037           else
00038             if (ACE_OutputCDR::wchar_maxbytes () == 2)
00039               {
00040                 ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
00041                 return
00042                   this->write_octet_array (
00043                     reinterpret_cast<const ACE_CDR::Octet*> (&sx),
00044                     static_cast<ACE_CDR::ULong> (len));
00045               }
00046             else
00047               {
00048                 ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
00049                 return
00050                   this->write_octet_array (
00051                     reinterpret_cast<const ACE_CDR::Octet*> (&ox),
00052                     static_cast<ACE_CDR::ULong> (len));
00053               }
00054         }
00055     }
00056   else if (static_cast<ACE_CDR::Short> (minor_version_) == 0)
00057     { // wchar is not allowed with GIOP 1.0.
00058       errno = EINVAL;
00059       return (this->good_bit_ = false);
00060     }
00061   if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar))
00062     {
00063       const void *temp = &x;
00064       return this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
00065     }
00066   else if (ACE_OutputCDR::wchar_maxbytes () == 2)
00067     {
00068       ACE_CDR::Short sx = static_cast<ACE_CDR::Short> (x);
00069       return this->write_2 (reinterpret_cast<const ACE_CDR::UShort *> (&sx));
00070     }
00071   ACE_CDR::Octet ox = static_cast<ACE_CDR::Octet> (x);
00072   return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&ox));
00073 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_wchar_array ( const ACE_CDR::WChar x,
ACE_CDR::ULong  length 
)

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 155 of file CDR_Size.inl.

References good_bit_, ACE_CDR::LONG_ALIGN, ACE_CDR::SHORT_ALIGN, ACE_OutputCDR::wchar_maxbytes(), write_array(), and write_wchar_array_i().

00157 {
00158   // Note: translator framework is not supported.
00159   //
00160   if (ACE_OutputCDR::wchar_maxbytes () == 0)
00161     {
00162       errno = EACCES;
00163       return (ACE_CDR::Boolean) (this->good_bit_ = false);
00164     }
00165   if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar))
00166     return this->write_array (x,
00167                               sizeof (ACE_CDR::WChar),
00168                               sizeof (ACE_CDR::WChar) == 2
00169                               ? ACE_CDR::SHORT_ALIGN
00170                               : ACE_CDR::LONG_ALIGN,
00171                               length);
00172   return this->write_wchar_array_i (x,length);
00173 }

ACE_CDR::Boolean ACE_SizeCDR::write_wchar_array_i ( const ACE_CDR::WChar x,
ACE_CDR::ULong  length 
) [private]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 184 of file CDR_Size.cpp.

References adjust(), ACE_CDR::OCTET_ALIGN, ACE_CDR::SHORT_ALIGN, and ACE_OutputCDR::wchar_maxbytes().

Referenced by write_wchar_array().

00186 {
00187   if (length == 0)
00188     return true;
00189 
00190   size_t const align = (ACE_OutputCDR::wchar_maxbytes () == 2) ?
00191     ACE_CDR::SHORT_ALIGN :
00192     ACE_CDR::OCTET_ALIGN;
00193 
00194   this->adjust (ACE_OutputCDR::wchar_maxbytes () * length, align);
00195   return true;
00196 }

ACE_CDR::Boolean ACE_SizeCDR::write_wstring ( ACE_CDR::ULong  length,
const ACE_CDR::WChar x 
)

Definition at line 109 of file CDR_Size.cpp.

References ACE_OutputCDR::wchar_maxbytes(), and write_ulong().

00111 {
00112   // Note: translator framework is not supported.
00113   //
00114   if (ACE_OutputCDR::wchar_maxbytes () == 0)
00115     {
00116       errno = EACCES;
00117       return (this->good_bit_ = false);
00118     }
00119 
00120   if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
00121       && static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
00122     {
00123       if (x != 0)
00124         {
00125           //In GIOP 1.2 the length field contains the number of bytes
00126           //the wstring occupies rather than number of wchars
00127           //Taking sizeof might not be a good way! This is a temporary fix.
00128           if (this->write_ulong (ACE_OutputCDR::wchar_maxbytes () * len))
00129             return this->write_wchar_array (x, len);
00130         }
00131       else
00132         //In GIOP 1.2 zero length wstrings are legal
00133         return this->write_ulong (0);
00134     }
00135 
00136   else
00137     if (x != 0)
00138       {
00139         if (this->write_ulong (len + 1))
00140           return this->write_wchar_array (x, len + 1);
00141       }
00142     else if (this->write_ulong (1))
00143       return this->write_wchar (0);
00144    return (this->good_bit_ = false);
00145 }

ACE_INLINE ACE_CDR::Boolean ACE_SizeCDR::write_wstring ( const ACE_CDR::WChar x  ) 

Definition at line 131 of file CDR_Size.inl.

References ACE_OS::strlen().

Referenced by operator<<().

00132 {
00133   if (x != 0)
00134     {
00135       ACE_CDR::ULong len =
00136         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00137       return this->write_wstring (len, x);
00138     }
00139   return this->write_wstring (0, 0);
00140 }


Member Data Documentation

bool ACE_SizeCDR::good_bit_ [private]

Set to false when an error ocurrs.

Definition at line 166 of file CDR_Size.h.

Referenced by good_bit(), and write_wchar_array().

ACE_CDR::Octet ACE_SizeCDR::major_version_ [protected]

GIOP version information.

Definition at line 173 of file CDR_Size.h.

ACE_CDR::Octet ACE_SizeCDR::minor_version_ [protected]

Note:
the portion written starts at <x> and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 174 of file CDR_Size.h.

size_t ACE_SizeCDR::size_ [private]

Current size.

Definition at line 169 of file CDR_Size.h.

Referenced by adjust(), reset(), and total_length().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:37 2010 for ACE by  doxygen 1.4.7