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 return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
00094 }
00095
00096 ACE_INLINE ACE_CDR::Boolean
00097 ACE_SizeCDR::write_float (ACE_CDR::Float x)
00098 {
00099 return this->write_4 (reinterpret_cast<const ACE_CDR::ULong*> (&x));
00100 }
00101
00102 ACE_INLINE ACE_CDR::Boolean
00103 ACE_SizeCDR::write_double (const ACE_CDR::Double &x)
00104 {
00105 return this->write_8 (reinterpret_cast<const ACE_CDR::ULongLong*> (&x));
00106 }
00107
00108 ACE_INLINE ACE_CDR::Boolean
00109 ACE_SizeCDR::write_longdouble (const ACE_CDR::LongDouble &x)
00110 {
00111 return this->write_16 (reinterpret_cast<const ACE_CDR::LongDouble*> (&x));
00112 }
00113
00114 ACE_INLINE ACE_CDR::Boolean
00115 ACE_SizeCDR::write_string (const ACE_CDR::Char *x)
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 }
00125
00126 ACE_INLINE ACE_CDR::Boolean
00127 ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x)
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 }
00137
00138 ACE_INLINE ACE_CDR::Boolean
00139 ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x,
00140 ACE_CDR::ULong length)
00141 {
00142
00143
00144 return this->write_array (x,
00145 ACE_CDR::OCTET_SIZE,
00146 ACE_CDR::OCTET_ALIGN,
00147 length);
00148 }
00149
00150 ACE_INLINE ACE_CDR::Boolean
00151 ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x,
00152 ACE_CDR::ULong length)
00153 {
00154
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 }
00170
00171 ACE_INLINE ACE_CDR::Boolean
00172 ACE_SizeCDR::write_octet_array (const ACE_CDR::Octet* x,
00173 ACE_CDR::ULong length)
00174 {
00175 return this->write_array (x,
00176 ACE_CDR::OCTET_SIZE,
00177 ACE_CDR::OCTET_ALIGN,
00178 length);
00179 }
00180
00181 ACE_INLINE ACE_CDR::Boolean
00182 ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x,
00183 ACE_CDR::ULong length)
00184 {
00185 return this->write_array (x,
00186 ACE_CDR::SHORT_SIZE,
00187 ACE_CDR::SHORT_ALIGN,
00188 length);
00189 }
00190
00191 ACE_INLINE ACE_CDR::Boolean
00192 ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x,
00193 ACE_CDR::ULong length)
00194 {
00195 return this->write_array (x,
00196 ACE_CDR::SHORT_SIZE,
00197 ACE_CDR::SHORT_ALIGN,
00198 length);
00199 }
00200
00201 ACE_INLINE ACE_CDR::Boolean
00202 ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x,
00203 ACE_CDR::ULong length)
00204 {
00205 return this->write_array (x,
00206 ACE_CDR::LONG_SIZE,
00207 ACE_CDR::LONG_ALIGN,
00208 length);
00209 }
00210
00211 ACE_INLINE ACE_CDR::Boolean
00212 ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x,
00213 ACE_CDR::ULong length)
00214 {
00215 return this->write_array (x,
00216 ACE_CDR::LONG_SIZE,
00217 ACE_CDR::LONG_ALIGN,
00218 length);
00219 }
00220
00221 ACE_INLINE ACE_CDR::Boolean
00222 ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x,
00223 ACE_CDR::ULong length)
00224 {
00225 return this->write_array (x,
00226 ACE_CDR::LONGLONG_SIZE,
00227 ACE_CDR::LONGLONG_ALIGN,
00228 length);
00229 }
00230
00231 ACE_INLINE ACE_CDR::Boolean
00232 ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x,
00233 ACE_CDR::ULong length)
00234 {
00235 return this->write_array (x,
00236 ACE_CDR::LONGLONG_SIZE,
00237 ACE_CDR::LONGLONG_ALIGN,
00238 length);
00239 }
00240
00241 ACE_INLINE ACE_CDR::Boolean
00242 ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x,
00243 ACE_CDR::ULong length)
00244 {
00245 return this->write_array (x,
00246 ACE_CDR::LONG_SIZE,
00247 ACE_CDR::LONG_ALIGN,
00248 length);
00249 }
00250
00251
00252 ACE_INLINE ACE_CDR::Boolean
00253 ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x,
00254 ACE_CDR::ULong length)
00255 {
00256 return this->write_array (x,
00257 ACE_CDR::LONGLONG_SIZE,
00258 ACE_CDR::LONGLONG_ALIGN,
00259 length);
00260 }
00261
00262 ACE_INLINE ACE_CDR::Boolean
00263 ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x,
00264 ACE_CDR::ULong length)
00265 {
00266 return this->write_array (x,
00267 ACE_CDR::LONGDOUBLE_SIZE,
00268 ACE_CDR::LONGDOUBLE_ALIGN,
00269 length);
00270 }
00271
00272
00273
00274
00275
00276 ACE_INLINE ACE_CDR::Boolean
00277 operator<< (ACE_SizeCDR &ss, ACE_CDR::Char x)
00278 {
00279 ss.write_char (x);
00280 return (ACE_CDR::Boolean) ss.good_bit ();
00281 }
00282
00283 ACE_INLINE ACE_CDR::Boolean
00284 operator<< (ACE_SizeCDR &ss, ACE_CDR::Short x)
00285 {
00286 ss.write_short (x);
00287 return (ACE_CDR::Boolean) ss.good_bit ();
00288 }
00289
00290 ACE_INLINE ACE_CDR::Boolean
00291 operator<< (ACE_SizeCDR &ss, ACE_CDR::UShort x)
00292 {
00293 ss.write_ushort (x);
00294 return (ACE_CDR::Boolean) ss.good_bit ();
00295 }
00296
00297 ACE_INLINE ACE_CDR::Boolean
00298 operator<< (ACE_SizeCDR &ss, ACE_CDR::Long x)
00299 {
00300 ss.write_long (x);
00301 return (ACE_CDR::Boolean) ss.good_bit ();
00302 }
00303
00304 ACE_INLINE ACE_CDR::Boolean
00305 operator<< (ACE_SizeCDR &ss, ACE_CDR::ULong x)
00306 {
00307 ss.write_ulong (x);
00308 return (ACE_CDR::Boolean) ss.good_bit ();
00309 }
00310
00311 ACE_INLINE ACE_CDR::Boolean
00312 operator<< (ACE_SizeCDR &ss, ACE_CDR::LongLong x)
00313 {
00314 ss.write_longlong (x);
00315 return (ACE_CDR::Boolean) ss.good_bit ();
00316 }
00317
00318 ACE_INLINE ACE_CDR::Boolean
00319 operator<< (ACE_SizeCDR &ss, ACE_CDR::ULongLong x)
00320 {
00321 ss.write_ulonglong (x);
00322 return (ACE_CDR::Boolean) ss.good_bit ();
00323 }
00324
00325 ACE_INLINE ACE_CDR::Boolean
00326 operator<< (ACE_SizeCDR &ss, ACE_CDR::LongDouble x)
00327 {
00328 ss.write_longdouble (x);
00329 return (ACE_CDR::Boolean) ss.good_bit ();
00330 }
00331
00332 ACE_INLINE ACE_CDR::Boolean
00333 operator<< (ACE_SizeCDR &ss, ACE_CDR::Float x)
00334 {
00335 ss.write_float (x);
00336 return (ACE_CDR::Boolean) ss.good_bit ();
00337 }
00338
00339 ACE_INLINE ACE_CDR::Boolean
00340 operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x)
00341 {
00342 ss.write_double (x);
00343 return (ACE_CDR::Boolean) ss.good_bit ();
00344 }
00345
00346 ACE_INLINE ACE_CDR::Boolean
00347 operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char *x)
00348 {
00349 ss.write_string (x);
00350 return (ACE_CDR::Boolean) ss.good_bit ();
00351 }
00352
00353 ACE_INLINE ACE_CDR::Boolean
00354 operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar *x)
00355 {
00356 ss.write_wstring (x);
00357 return (ACE_CDR::Boolean) ss.good_bit ();
00358 }
00359
00360
00361 ACE_INLINE ACE_CDR::Boolean
00362 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x)
00363 {
00364 ss.write_boolean (x.val_);
00365 return (ACE_CDR::Boolean) ss.good_bit ();
00366 }
00367
00368 ACE_INLINE ACE_CDR::Boolean
00369 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_char x)
00370 {
00371 ss.write_char (x.val_);
00372 return (ACE_CDR::Boolean) ss.good_bit ();
00373 }
00374
00375 ACE_INLINE ACE_CDR::Boolean
00376 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wchar x)
00377 {
00378 ss.write_wchar (x.val_);
00379 return (ACE_CDR::Boolean) ss.good_bit ();
00380 }
00381
00382 ACE_INLINE ACE_CDR::Boolean
00383 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_octet x)
00384 {
00385 ss.write_octet (x.val_);
00386 return (ACE_CDR::Boolean) ss.good_bit ();
00387 }
00388
00389 ACE_INLINE ACE_CDR::Boolean
00390 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_string x)
00391 {
00392 ACE_CDR::ULong len = 0;
00393
00394 if (x.val_ != 0)
00395 {
00396 len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x.val_));
00397 }
00398
00399 ss.write_string (len, x.val_);
00400 return
00401 (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_));
00402 }
00403
00404 ACE_INLINE ACE_CDR::Boolean
00405 operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wstring x)
00406 {
00407 ACE_CDR::ULong len = 0;
00408
00409 if (x.val_ != 0)
00410 {
00411 len = static_cast<ACE_CDR::ULong> (ACE_OS::strlen (x.val_));
00412 }
00413
00414 ss.write_wstring (len, x.val_);
00415 return
00416 (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_));
00417 }
00418
00419
00420 ACE_END_VERSIONED_NAMESPACE_DECL