00001
00002
00003
00004
00005 #include "ace/OS_NS_string.h"
00006
00007 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00008
00009 ACE_INLINE
00010 ACE_SizeCDR::ACE_SizeCDR (ACE_CDR::Octet major_version,
00011 ACE_CDR::Octet minor_version)
00012 : good_bit_ (true),
00013 size_ (0),
00014 major_version_ (major_version),
00015 minor_version_ (minor_version)
00016 {
00017 }
00018
00019 ACE_INLINE bool
00020 ACE_SizeCDR::good_bit (void) const
00021 {
00022 return this->good_bit_;
00023 }
00024
00025 ACE_INLINE void
00026 ACE_SizeCDR::reset (void)
00027 {
00028 this->size_ = 0;
00029 }
00030
00031 ACE_INLINE size_t
00032 ACE_SizeCDR::total_length (void) const
00033 {
00034 return this->size_;
00035 }
00036
00037
00038
00039
00040 ACE_INLINE ACE_CDR::Boolean
00041 ACE_SizeCDR::write_octet (ACE_CDR::Octet x)
00042 {
00043 return this->write_1 (reinterpret_cast<const ACE_CDR::Octet *> (&x));
00044 }
00045
00046 ACE_INLINE ACE_CDR::Boolean
00047 ACE_SizeCDR::write_boolean (ACE_CDR::Boolean x)
00048 {
00049 return (ACE_CDR::Boolean) this->write_octet (x ? (ACE_CDR::Octet) 1 : (ACE_CDR::Octet) 0);
00050 }
00051
00052 ACE_INLINE ACE_CDR::Boolean
00053 ACE_SizeCDR::write_char (ACE_CDR::Char x)
00054 {
00055
00056
00057 return this->write_1 (reinterpret_cast<const ACE_CDR::Octet*> (&x));
00058 }
00059
00060 ACE_INLINE ACE_CDR::Boolean
00061 ACE_SizeCDR::write_short (ACE_CDR::Short x)
00062 {
00063 return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
00064 }
00065
00066 ACE_INLINE ACE_CDR::Boolean
00067 ACE_SizeCDR::write_ushort (ACE_CDR::UShort x)
00068 {
00069 return this->write_2 (reinterpret_cast<const ACE_CDR::UShort*> (&x));
00070 }
00071
00072 ACE_INLINE ACE_CDR::Boolean
00073 ACE_SizeCDR::write_long (ACE_CDR::Long x)
00074 {
00075 return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
00076 }
00077
00078 ACE_INLINE ACE_CDR::Boolean
00079 ACE_SizeCDR::write_ulong (ACE_CDR::ULong x)
00080 {
00081 return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
00082 }
00083
00084 ACE_INLINE ACE_CDR::Boolean
00085 ACE_SizeCDR::write_longlong (const ACE_CDR::LongLong &x)
00086 {
00087 return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
00088 }
00089
00090 ACE_INLINE ACE_CDR::Boolean
00091 ACE_SizeCDR::write_ulonglong (const ACE_CDR::ULongLong &x)
00092 {
00093 const void *temp = &x;
00094 return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong *> (temp));
00095 }
00096
00097 ACE_INLINE ACE_CDR::Boolean
00098 ACE_SizeCDR::write_float (ACE_CDR::Float x)
00099 {
00100 const void *temp = &x;
00101 return this->write_4 (reinterpret_cast<const ACE_CDR::ULong *> (temp));
00102 }
00103
00104 ACE_INLINE ACE_CDR::Boolean
00105 ACE_SizeCDR::write_double (const ACE_CDR::Double &x)
00106 {
00107 const void *temp = &x;
00108 return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (temp));
00109 }
00110
00111 ACE_INLINE ACE_CDR::Boolean
00112 ACE_SizeCDR::write_longdouble (const ACE_CDR::LongDouble &x)
00113 {
00114 const void *temp = &x;
00115 return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (temp));
00116 }
00117
00118 ACE_INLINE ACE_CDR::Boolean
00119 ACE_SizeCDR::write_string (const ACE_CDR::Char *x)
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 }
00129
00130 ACE_INLINE ACE_CDR::Boolean
00131 ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x)
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 }
00141
00142 ACE_INLINE ACE_CDR::Boolean
00143 ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x,
00144 ACE_CDR::ULong length)
00145 {
00146
00147
00148 return this->write_array (x,
00149 ACE_CDR::OCTET_SIZE,
00150 ACE_CDR::OCTET_ALIGN,
00151 length);
00152 }
00153
00154 ACE_INLINE ACE_CDR::Boolean
00155 ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x,
00156 ACE_CDR::ULong length)
00157 {
00158
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 }
00174
00175 ACE_INLINE ACE_CDR::Boolean
00176 ACE_SizeCDR::write_octet_array (const ACE_CDR::Octet* x,
00177 ACE_CDR::ULong length)
00178 {
00179 return this->write_array (x,
00180 ACE_CDR::OCTET_SIZE,
00181 ACE_CDR::OCTET_ALIGN,
00182 length);
00183 }
00184
00185 ACE_INLINE ACE_CDR::Boolean
00186 ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x,
00187 ACE_CDR::ULong length)
00188 {
00189 return this->write_array (x,
00190 ACE_CDR::SHORT_SIZE,
00191 ACE_CDR::SHORT_ALIGN,
00192 length);
00193 }
00194
00195 ACE_INLINE ACE_CDR::Boolean
00196 ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x,
00197 ACE_CDR::ULong length)
00198 {
00199 return this->write_array (x,
00200 ACE_CDR::SHORT_SIZE,
00201 ACE_CDR::SHORT_ALIGN,
00202 length);
00203 }
00204
00205 ACE_INLINE ACE_CDR::Boolean
00206 ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x,
00207 ACE_CDR::ULong length)
00208 {
00209 return this->write_array (x,
00210 ACE_CDR::LONG_SIZE,
00211 ACE_CDR::LONG_ALIGN,
00212 length);
00213 }
00214
00215 ACE_INLINE ACE_CDR::Boolean
00216 ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x,
00217 ACE_CDR::ULong length)
00218 {
00219 return this->write_array (x,
00220 ACE_CDR::LONG_SIZE,
00221 ACE_CDR::LONG_ALIGN,
00222 length);
00223 }
00224
00225 ACE_INLINE ACE_CDR::Boolean
00226 ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x,
00227 ACE_CDR::ULong length)
00228 {
00229 return this->write_array (x,
00230 ACE_CDR::LONGLONG_SIZE,
00231 ACE_CDR::LONGLONG_ALIGN,
00232 length);
00233 }
00234
00235 ACE_INLINE ACE_CDR::Boolean
00236 ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x,
00237 ACE_CDR::ULong length)
00238 {
00239 return this->write_array (x,
00240 ACE_CDR::LONGLONG_SIZE,
00241 ACE_CDR::LONGLONG_ALIGN,
00242 length);
00243 }
00244
00245 ACE_INLINE ACE_CDR::Boolean
00246 ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x,
00247 ACE_CDR::ULong length)
00248 {
00249 return this->write_array (x,
00250 ACE_CDR::LONG_SIZE,
00251 ACE_CDR::LONG_ALIGN,
00252 length);
00253 }
00254
00255
00256 ACE_INLINE ACE_CDR::Boolean
00257 ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x,
00258 ACE_CDR::ULong length)
00259 {
00260 return this->write_array (x,
00261 ACE_CDR::LONGLONG_SIZE,
00262 ACE_CDR::LONGLONG_ALIGN,
00263 length);
00264 }
00265
00266 ACE_INLINE ACE_CDR::Boolean
00267 ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x,
00268 ACE_CDR::ULong length)
00269 {
00270 return this->write_array (x,
00271 ACE_CDR::LONGDOUBLE_SIZE,
00272 ACE_CDR::LONGDOUBLE_ALIGN,
00273 length);
00274 }
00275
00276
00277
00278
00279
00280 ACE_INLINE ACE_CDR::Boolean
00281 operator<< (ACE_SizeCDR &ss, ACE_CDR::Char x)
00282 {
00283 ss.write_char (x);
00284 return (ACE_CDR::Boolean) ss.good_bit ();
00285 }
00286
00287 ACE_INLINE ACE_CDR::Boolean
00288 operator<< (ACE_SizeCDR &ss, ACE_CDR::Short x)
00289 {
00290 ss.write_short (x);
00291 return (ACE_CDR::Boolean) ss.good_bit ();
00292 }
00293
00294 ACE_INLINE ACE_CDR::Boolean
00295 operator<< (ACE_SizeCDR &ss, ACE_CDR::UShort x)
00296 {
00297 ss.write_ushort (x);
00298 return (ACE_CDR::Boolean) ss.good_bit ();
00299 }
00300
00301 ACE_INLINE ACE_CDR::Boolean
00302 operator<< (ACE_SizeCDR &ss, ACE_CDR::Long x)
00303 {
00304 ss.write_long (x);
00305 return (ACE_CDR::Boolean) ss.good_bit ();
00306 }
00307
00308 ACE_INLINE ACE_CDR::Boolean
00309 operator<< (ACE_SizeCDR &ss, ACE_CDR::ULong x)
00310 {
00311 ss.write_ulong (x);
00312 return (ACE_CDR::Boolean) ss.good_bit ();
00313 }
00314
00315 ACE_INLINE ACE_CDR::Boolean
00316 operator<< (ACE_SizeCDR &ss, ACE_CDR::LongLong x)
00317 {
00318 ss.write_longlong (x);
00319 return (ACE_CDR::Boolean) ss.good_bit ();
00320 }
00321
00322 ACE_INLINE ACE_CDR::Boolean
00323 operator<< (ACE_SizeCDR &ss, ACE_CDR::ULongLong x)
00324 {
00325 ss.write_ulonglong (x);
00326 return (ACE_CDR::Boolean) ss.good_bit ();
00327 }
00328
00329 ACE_INLINE ACE_CDR::Boolean
00330 operator<< (ACE_SizeCDR &ss, ACE_CDR::LongDouble x)
00331 {
00332 ss.write_longdouble (x);
00333 return (ACE_CDR::Boolean) ss.good_bit ();
00334 }
00335
00336 ACE_INLINE ACE_CDR::Boolean
00337 operator<< (ACE_SizeCDR &ss, ACE_CDR::Float x)
00338 {
00339 ss.write_float (x);
00340 return (ACE_CDR::Boolean) ss.good_bit ();
00341 }
00342
00343 ACE_INLINE ACE_CDR::Boolean
00344 operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x)
00345 {
00346 ss.write_double (x);
00347 return (ACE_CDR::Boolean) ss.good_bit ();
00348 }
00349
00350 ACE_INLINE ACE_CDR::Boolean
00351 operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char *x)
00352 {
00353 ss.write_string (x);
00354 return (ACE_CDR::Boolean) ss.good_bit ();
00355 }
00356
00357 ACE_INLINE ACE_CDR::Boolean
00358 operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar *x)
00359 {
00360 ss.write_wstring (x);
00361 return (ACE_CDR::Boolean) ss.good_bit ();
00362 }
00363
00364
00365 ACE_INLINE ACE_CDR::Boolean
00366 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x)
00367 {
00368 ss.write_boolean (x.val_);
00369 return (ACE_CDR::Boolean) ss.good_bit ();
00370 }
00371
00372 ACE_INLINE ACE_CDR::Boolean
00373 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_char x)
00374 {
00375 ss.write_char (x.val_);
00376 return (ACE_CDR::Boolean) ss.good_bit ();
00377 }
00378
00379 ACE_INLINE ACE_CDR::Boolean
00380 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wchar x)
00381 {
00382 ss.write_wchar (x.val_);
00383 return (ACE_CDR::Boolean) ss.good_bit ();
00384 }
00385
00386 ACE_INLINE ACE_CDR::Boolean
00387 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_octet x)
00388 {
00389 ss.write_octet (x.val_);
00390 return (ACE_CDR::Boolean) ss.good_bit ();
00391 }
00392
00393 ACE_INLINE ACE_CDR::Boolean
00394 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_string x)
00395 {
00396 ACE_CDR::ULong len = 0;
00397
00398 if (x.val_ != 0)
00399 {
00400 len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x.val_));
00401 }
00402
00403 ss.write_string (len, x.val_);
00404 return
00405 (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_));
00406 }
00407
00408 ACE_INLINE ACE_CDR::Boolean
00409 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wstring x)
00410 {
00411 ACE_CDR::ULong len = 0;
00412
00413 if (x.val_ != 0)
00414 {
00415 len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x.val_));
00416 }
00417
00418 ss.write_wstring (len, x.val_);
00419 return
00420 (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_));
00421 }
00422
00423
00424 ACE_END_VERSIONED_NAMESPACE_DECL