ACE_SizeCDR Class Reference

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

#include <CDR_Size.h>

List of all members.

Array write operations

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.

Size-calculating pseudo-write operations
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.

References ACE_CDR::Octet.

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 233 of file CDR_Size.cpp.

References ACE_align_binary.

00235 {
00236 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00237   const size_t offset = ACE_align_binary (size_, align) - size_;
00238   size_ += offset;
00239 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00240   size_ += size;
00241 }

void ACE_SizeCDR::adjust size_t  size  ) 
 

Adjust to and count octets.

Definition at line 227 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().

00228 {
00229   adjust (size, size);
00230 }

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 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.

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.

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 144 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::Octet.

Referenced by write_char(), write_octet(), and write_wchar().

00145 {
00146   ACE_UNUSED_ARG (x);
00147   this->adjust (1);
00148   return true;
00149 }

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

Note:
the portion written starts at 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().

Referenced by write_longdouble().

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

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

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

Definition at line 152 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::UShort.

Referenced by write_short(), write_ushort(), and write_wchar().

00153 {
00154   ACE_UNUSED_ARG (x);
00155   this->adjust (ACE_CDR::SHORT_SIZE);
00156   return true;
00157 }

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

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

Definition at line 160 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::ULong.

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

00161 {
00162   ACE_UNUSED_ARG (x);
00163   this->adjust (ACE_CDR::LONG_SIZE);
00164   return true;
00165 }

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

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

Definition at line 168 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::ULongLong.

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

00169 {
00170   ACE_UNUSED_ARG (x);
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 elements, each of bytes and the start aligned at a multiple of . 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 ; as explained above it is expected that using assignment is faster that for one element, but for several elements 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 203 of file CDR_Size.cpp.

References adjust(), and ACE_CDR::ULong.

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().

00207 {
00208   ACE_UNUSED_ARG (x);
00209 
00210   if (length == 0)
00211     return true;
00212 
00213   this->adjust (size * length, align);
00214   return true;
00215 }

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

Definition at line 47 of file CDR_Size.inl.

References ACE_CDR::Boolean, ACE_CDR::Octet, and 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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 218 of file CDR_Size.cpp.

References adjust(), ACE_CDR::Boolean, and ACE_CDR::ULong.

00220 {
00221   ACE_UNUSED_ARG (x);
00222   this->adjust (length, 1);
00223   return true;
00224 }

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

Definition at line 53 of file CDR_Size.inl.

References ACE_CDR::Char, and write_1().

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

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 139 of file CDR_Size.inl.

References ACE_CDR::Char, ACE_CDR::ULong, and write_array().

Referenced by write_string().

00141 {
00142   // Note: translator framework is not supported.
00143   //
00144   return this->write_array (x,
00145                             ACE_CDR::OCTET_SIZE,
00146                             ACE_CDR::OCTET_ALIGN,
00147                             length);
00148 }

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

Definition at line 103 of file CDR_Size.inl.

References write_8().

Referenced by operator<<().

00104 {
00105   return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
00106 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 253 of file CDR_Size.inl.

References ACE_CDR::ULong, and write_array().

00255 {
00256   return this->write_array (x,
00257                             ACE_CDR::LONGLONG_SIZE,
00258                             ACE_CDR::LONGLONG_ALIGN,
00259                             length);
00260 }

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

Definition at line 97 of file CDR_Size.inl.

References write_4().

Referenced by operator<<().

00098 {
00099   return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
00100 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 242 of file CDR_Size.inl.

References ACE_CDR::ULong, and write_array().

00244 {
00245   return this->write_array (x,
00246                             ACE_CDR::LONG_SIZE,
00247                             ACE_CDR::LONG_ALIGN,
00248                             length);
00249 }

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

Definition at line 73 of file CDR_Size.inl.

References ACE_CDR::Long, and 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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 202 of file CDR_Size.inl.

References ACE_CDR::Long, ACE_CDR::ULong, and write_array().

00204 {
00205   return this->write_array (x,
00206                             ACE_CDR::LONG_SIZE,
00207                             ACE_CDR::LONG_ALIGN,
00208                             length);
00209 }

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

Definition at line 109 of file CDR_Size.inl.

References write_16().

Referenced by operator<<().

00110 {
00111   return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (&x));
00112 }

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 263 of file CDR_Size.inl.

References ACE_CDR::ULong, and write_array().

00265 {
00266   return this->write_array (x,
00267                             ACE_CDR::LONGDOUBLE_SIZE,
00268                             ACE_CDR::LONGDOUBLE_ALIGN,
00269                             length);
00270 }

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

Definition at line 85 of file CDR_Size.inl.

References ACE_CDR::LongLong, and 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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 222 of file CDR_Size.inl.

References ACE_CDR::LongLong, ACE_CDR::ULong, and write_array().

00224 {
00225   return this->write_array (x,
00226                             ACE_CDR::LONGLONG_SIZE,
00227                             ACE_CDR::LONGLONG_ALIGN,
00228                             length);
00229 }

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

Definition at line 41 of file CDR_Size.inl.

References ACE_CDR::Octet, and 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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 172 of file CDR_Size.inl.

References ACE_CDR::Octet, ACE_CDR::ULong, and write_array().

Referenced by write_wchar().

00174 {
00175   return this->write_array (x,
00176                             ACE_CDR::OCTET_SIZE,
00177                             ACE_CDR::OCTET_ALIGN,
00178                             length);
00179 }

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

Definition at line 61 of file CDR_Size.inl.

References ACE_CDR::Short, and 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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 182 of file CDR_Size.inl.

References ACE_CDR::Short, ACE_CDR::ULong, and write_array().

00184 {
00185   return this->write_array (x,
00186                             ACE_CDR::SHORT_SIZE,
00187                             ACE_CDR::SHORT_ALIGN,
00188                             length);
00189 }

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

Definition at line 96 of file CDR_Size.cpp.

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

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

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

Definition at line 72 of file CDR_Size.cpp.

References ACE_CDR::Char, good_bit_, ACE_CDR::ULong, write_char(), write_char_array(), and write_ulong().

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

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 115 of file CDR_Size.inl.

References ACE_CDR::Char, ACE_OS::strlen(), and ACE_CDR::ULong.

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

00116 {
00117   if (x != 0)
00118     {
00119       const ACE_CDR::ULong len =
00120         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00121       return this->write_string (len, x);
00122     }
00123   return this->write_string (0, 0);
00124 }

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

Definition at line 79 of file CDR_Size.inl.

References ACE_CDR::ULong, and write_4().

Referenced by operator<<(), write_string(), 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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 212 of file CDR_Size.inl.

References ACE_CDR::ULong, and write_array().

00214 {
00215   return this->write_array (x,
00216                             ACE_CDR::LONG_SIZE,
00217                             ACE_CDR::LONG_ALIGN,
00218                             length);
00219 }

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

Definition at line 91 of file CDR_Size.inl.

References ACE_CDR::ULongLong, and write_8().

Referenced by operator<<().

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

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 232 of file CDR_Size.inl.

References ACE_CDR::ULong, ACE_CDR::ULongLong, and write_array().

00234 {
00235   return this->write_array (x,
00236                             ACE_CDR::LONGLONG_SIZE,
00237                             ACE_CDR::LONGLONG_ALIGN,
00238                             length);
00239 }

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

Definition at line 67 of file CDR_Size.inl.

References ACE_CDR::UShort, and 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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 192 of file CDR_Size.inl.

References ACE_CDR::ULong, ACE_CDR::UShort, and write_array().

00194 {
00195   return this->write_array (x,
00196                             ACE_CDR::SHORT_SIZE,
00197                             ACE_CDR::SHORT_ALIGN,
00198                             length);
00199 }

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

Definition at line 15 of file CDR_Size.cpp.

References good_bit_, major_version_, minor_version_, ACE_CDR::Octet, ACE_CDR::Short, ACE_CDR::WChar, ACE_OutputCDR::wchar_maxbytes(), write_1(), write_2(), write_4(), and write_octet_array().

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

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

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 151 of file CDR_Size.inl.

References ACE_CDR::Boolean, good_bit_, ACE_CDR::ULong, ACE_CDR::WChar, ACE_OutputCDR::wchar_maxbytes(), write_array(), and write_wchar_array_i().

Referenced by write_wstring().

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

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 and ends at <x + length>. The length is *NOT* stored into the CDR stream.

Definition at line 185 of file CDR_Size.cpp.

References adjust(), ACE_CDR::ULong, ACE_CDR::WChar, and ACE_OutputCDR::wchar_maxbytes().

Referenced by write_wchar_array().

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

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

Definition at line 105 of file CDR_Size.cpp.

References good_bit_, major_version_, minor_version_, ACE_CDR::ULong, ACE_CDR::WChar, ACE_OutputCDR::wchar_maxbytes(), write_ulong(), write_wchar(), and write_wchar_array().

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

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

Definition at line 127 of file CDR_Size.inl.

References ACE_OS::strlen(), ACE_CDR::ULong, and ACE_CDR::WChar.

Referenced by operator<<().

00128 {
00129   if (x != 0)
00130     {
00131       ACE_CDR::ULong len =
00132         static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x));
00133       return this->write_wstring (len, x);
00134     }
00135   return this->write_wstring (0, 0);
00136 }


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(), write_string(), write_wchar(), write_wchar_array(), and write_wstring().

ACE_CDR::Octet ACE_SizeCDR::major_version_ [protected]
 

GIOP version information.

Definition at line 173 of file CDR_Size.h.

Referenced by write_wchar(), and write_wstring().

ACE_CDR::Octet ACE_SizeCDR::minor_version_ [protected]
 

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

Definition at line 174 of file CDR_Size.h.

Referenced by write_wchar(), and write_wstring().

size_t ACE_SizeCDR::size_ [private]
 

Current size.

Definition at line 169 of file CDR_Size.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:29:44 2006 for ACE by doxygen 1.3.6