00001 #ifndef guard_bounded_sequence_cdr
00002 #define guard_bounded_sequence_cdr
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "tao/orbconf.h"
00015 #include "tao/SystemException.h"
00016
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018
00019 namespace TAO {
00020 template <typename stream, CORBA::ULong MAX>
00021 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::Short, MAX> & target) {
00022 typedef TAO::bounded_value_sequence <CORBA::Short, MAX> sequence;
00023 ::CORBA::ULong new_length = 0;
00024 if (!(strm >> new_length)) {
00025 return false;
00026 }
00027 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00028 return false;
00029 }
00030 sequence tmp;
00031 tmp.length(new_length);
00032 typename sequence::value_type * buffer = tmp.get_buffer();
00033 if (!strm.read_short_array (buffer, new_length)) {
00034 return false;
00035 }
00036 tmp.swap(target);
00037 return true;
00038 }
00039
00040 template <typename stream, CORBA::ULong MAX>
00041 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::Long, MAX> & target) {
00042 typedef TAO::bounded_value_sequence <CORBA::Long, MAX> sequence;
00043 ::CORBA::ULong new_length = 0;
00044 if (!(strm >> new_length)) {
00045 return false;
00046 }
00047 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00048 return false;
00049 }
00050 sequence tmp;
00051 tmp.length(new_length);
00052 typename sequence::value_type * buffer = tmp.get_buffer();
00053 if (!strm.read_long_array (buffer, new_length)) {
00054 return false;
00055 }
00056 tmp.swap(target);
00057 return true;
00058 }
00059
00060 template <typename stream, CORBA::ULong MAX>
00061 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::ULong, MAX> & target) {
00062 typedef TAO::bounded_value_sequence <CORBA::ULong, MAX> sequence;
00063 ::CORBA::ULong new_length = 0;
00064 if (!(strm >> new_length)) {
00065 return false;
00066 }
00067 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00068 return false;
00069 }
00070 sequence tmp;
00071 tmp.length(new_length);
00072 typename sequence::value_type * buffer = tmp.get_buffer();
00073 if (!strm.read_ulong_array (buffer, new_length)) {
00074 return false;
00075 }
00076 tmp.swap(target);
00077 return true;
00078 }
00079
00080 template <typename stream, CORBA::ULong MAX>
00081 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::UShort, MAX> & target) {
00082 typedef TAO::bounded_value_sequence <CORBA::UShort, MAX> sequence;
00083 ::CORBA::ULong new_length = 0;
00084 if (!(strm >> new_length)) {
00085 return false;
00086 }
00087 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00088 return false;
00089 }
00090 sequence tmp;
00091 tmp.length(new_length);
00092 typename sequence::value_type * buffer = tmp.get_buffer();
00093 if (!strm.read_ushort_array (buffer, new_length)) {
00094 return false;
00095 }
00096 tmp.swap(target);
00097 return true;
00098 }
00099
00100 template <typename stream, CORBA::ULong MAX>
00101 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::Octet, MAX> & target) {
00102 typedef TAO::bounded_value_sequence <CORBA::Octet, MAX> sequence;
00103 ::CORBA::ULong new_length = 0;
00104 if (!(strm >> new_length)) {
00105 return false;
00106 }
00107 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00108 return false;
00109 }
00110 sequence tmp;
00111 tmp.length(new_length);
00112 typename sequence::value_type * buffer = tmp.get_buffer();
00113 if (!strm.read_octet_array (buffer, new_length)) {
00114 return false;
00115 }
00116 tmp.swap(target);
00117 return true;
00118 }
00119
00120 template <typename stream, CORBA::ULong MAX>
00121 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::Char, MAX> & target) {
00122 typedef TAO::bounded_value_sequence <CORBA::Char, MAX> sequence;
00123 ::CORBA::ULong new_length = 0;
00124 if (!(strm >> new_length)) {
00125 return false;
00126 }
00127 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00128 return false;
00129 }
00130 sequence tmp;
00131 tmp.length(new_length);
00132 typename sequence::value_type * buffer = tmp.get_buffer();
00133 if (!strm.read_char_array (buffer, new_length)) {
00134 return false;
00135 }
00136 tmp.swap(target);
00137 return true;
00138 }
00139
00140 # if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
00141 template <typename stream, CORBA::ULong MAX>
00142 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::WChar, MAX> & target) {
00143 typedef TAO::bounded_value_sequence <CORBA::WChar, MAX> sequence;
00144 ::CORBA::ULong new_length = 0;
00145 if (!(strm >> new_length)) {
00146 return false;
00147 }
00148 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00149 return false;
00150 }
00151 sequence tmp;
00152 tmp.length(new_length);
00153 typename sequence::value_type * buffer = tmp.get_buffer();
00154 if (!strm.read_wchar_array (buffer, new_length)) {
00155 return false;
00156 }
00157 tmp.swap(target);
00158 return true;
00159 }
00160 #endif
00161
00162 template <typename stream, CORBA::ULong MAX>
00163 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::Float, MAX> & target) {
00164 typedef TAO::bounded_value_sequence <CORBA::Float, MAX> sequence;
00165 ::CORBA::ULong new_length = 0;
00166 if (!(strm >> new_length)) {
00167 return false;
00168 }
00169 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00170 return false;
00171 }
00172 sequence tmp;
00173 tmp.length(new_length);
00174 typename sequence::value_type * buffer = tmp.get_buffer();
00175 if (!strm.read_float_array (buffer, new_length)) {
00176 return false;
00177 }
00178 tmp.swap(target);
00179 return true;
00180 }
00181
00182 template <typename stream, CORBA::ULong MAX>
00183 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::Double, MAX> & target) {
00184 typedef TAO::bounded_value_sequence <CORBA::Double, MAX> sequence;
00185 ::CORBA::ULong new_length = 0;
00186 if (!(strm >> new_length)) {
00187 return false;
00188 }
00189 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00190 return false;
00191 }
00192 sequence tmp;
00193 tmp.length(new_length);
00194 typename sequence::value_type * buffer = tmp.get_buffer();
00195 if (!strm.read_double_array (buffer, new_length)) {
00196 return false;
00197 }
00198 tmp.swap(target);
00199 return true;
00200 }
00201
00202 template <typename stream, CORBA::ULong MAX>
00203 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::ULongLong, MAX> & target) {
00204 typedef TAO::bounded_value_sequence <CORBA::ULongLong, MAX> sequence;
00205 ::CORBA::ULong new_length = 0;
00206 if (!(strm >> new_length)) {
00207 return false;
00208 }
00209 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00210 return false;
00211 }
00212 sequence tmp;
00213 tmp.length(new_length);
00214 typename sequence::value_type * buffer = tmp.get_buffer();
00215 if (!strm.read_ulonglong_array (buffer, new_length)) {
00216 return false;
00217 }
00218 tmp.swap(target);
00219 return true;
00220 }
00221
00222 template <typename stream, CORBA::ULong MAX>
00223 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::LongDouble, MAX> & target) {
00224 typedef TAO::bounded_value_sequence <CORBA::LongDouble, MAX> sequence;
00225 ::CORBA::ULong new_length = 0;
00226 if (!(strm >> new_length)) {
00227 return false;
00228 }
00229 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00230 return false;
00231 }
00232 sequence tmp;
00233 tmp.length(new_length);
00234 typename sequence::value_type * buffer = tmp.get_buffer();
00235 if (!strm.read_longdouble_array (buffer, new_length)) {
00236 return false;
00237 }
00238 tmp.swap(target);
00239 return true;
00240 }
00241
00242 template <typename stream, CORBA::ULong MAX>
00243 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <CORBA::Boolean, MAX> & target) {
00244 typedef TAO::bounded_value_sequence <CORBA::Boolean, MAX> sequence;
00245 ::CORBA::ULong new_length = 0;
00246 if (!(strm >> new_length)) {
00247 return false;
00248 }
00249 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00250 return false;
00251 }
00252 sequence tmp;
00253 tmp.length(new_length);
00254 typename sequence::value_type * buffer = tmp.get_buffer();
00255 if (!strm.read_boolean_array (buffer, new_length)) {
00256 return false;
00257 }
00258 tmp.swap(target);
00259 return true;
00260 }
00261
00262 template <typename stream, typename value_t, CORBA::ULong MAX>
00263 bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <value_t, MAX> & target) {
00264 typedef TAO::bounded_value_sequence <value_t, MAX> sequence;
00265 ::CORBA::ULong new_length = 0;
00266 if (!(strm >> new_length)) {
00267 return false;
00268 }
00269 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00270 return false;
00271 }
00272 sequence tmp;
00273 tmp.length(new_length);
00274 typename sequence::value_type * buffer = tmp.get_buffer();
00275 for(CORBA::ULong i = 0; i < new_length; ++i) {
00276 if (!(strm >> buffer[i])) {
00277 return false;
00278 }
00279 }
00280 tmp.swap(target);
00281 return true;
00282 }
00283
00284 template <typename stream, typename charT, CORBA::ULong MAX>
00285 bool demarshal_sequence(stream & strm, TAO::details::bounded_basic_string_sequence <charT, MAX> & target) {
00286 typedef typename TAO::details::bounded_basic_string_sequence <charT, MAX> sequence;
00287 typedef typename sequence::element_traits::string_var string_var;
00288 ::CORBA::ULong new_length = 0;
00289 if (!(strm >> new_length)) {
00290 return false;
00291 }
00292 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00293 return false;
00294 }
00295 sequence tmp;
00296 tmp.length(new_length);
00297 for(CORBA::ULong i = 0; i < new_length; ++i) {
00298 string_var string;
00299 if (!(strm >> string.inout ())) {
00300 return false;
00301 }
00302 else {
00303 tmp[i] = string._retn ();
00304 }
00305 }
00306 tmp.swap(target);
00307 return true;
00308 }
00309
00310 template <typename stream, typename object_t, typename object_t_var, CORBA::ULong MAX>
00311 bool demarshal_sequence(stream & strm, TAO::bounded_object_reference_sequence<object_t, object_t_var, MAX> & target) {
00312 typedef typename TAO::bounded_object_reference_sequence<object_t, object_t_var, MAX> sequence;
00313 ::CORBA::ULong new_length = 0;
00314 if (!(strm >> new_length)) {
00315 return false;
00316 }
00317 if ((new_length > strm.length()) || (new_length > target.maximum ())) {
00318 return false;
00319 }
00320 sequence tmp;
00321 tmp.length(new_length);
00322 typename sequence::value_type * buffer = tmp.get_buffer();
00323 for(CORBA::ULong i = 0; i < new_length; ++i) {
00324 if (!(strm >> buffer[i])) {
00325 return false;
00326 }
00327 }
00328 tmp.swap(target);
00329 return true;
00330 }
00331 }
00332
00333 namespace TAO {
00334 template <typename stream, CORBA::ULong MAX>
00335 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Short, MAX> & source) {
00336 if (0 == &source)
00337 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00338 ::CORBA::ULong const length = source.length ();
00339 if (!(strm << length)) {
00340 return false;
00341 }
00342 return strm.write_short_array (source.get_buffer (), length);
00343 }
00344
00345 template <typename stream, CORBA::ULong MAX>
00346 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Long, MAX> & source) {
00347 if (0 == &source)
00348 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00349 ::CORBA::ULong const length = source.length ();
00350 if (!(strm << length)) {
00351 return false;
00352 }
00353 return strm.write_long_array (source.get_buffer (), length);
00354 }
00355
00356 template <typename stream, CORBA::ULong MAX>
00357 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::ULong, MAX> & source) {
00358 if (0 == &source)
00359 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00360 ::CORBA::ULong const length = source.length ();
00361 if (!(strm << length)) {
00362 return false;
00363 }
00364 return strm.write_ulong_array (source.get_buffer (), length);
00365 }
00366
00367 template <typename stream, CORBA::ULong MAX>
00368 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::UShort, MAX> & source) {
00369 if (0 == &source)
00370 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00371 ::CORBA::ULong const length = source.length ();
00372 if (!(strm << length)) {
00373 return false;
00374 }
00375 return strm.write_ushort_array (source.get_buffer (), length);
00376 }
00377
00378 template <typename stream, CORBA::ULong MAX>
00379 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Octet, MAX> & source) {
00380 if (0 == &source)
00381 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00382 ::CORBA::ULong const length = source.length ();
00383 if (!(strm << length)) {
00384 return false;
00385 }
00386 return strm.write_octet_array (source.get_buffer (), length);
00387 }
00388
00389 template <typename stream, CORBA::ULong MAX>
00390 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Char, MAX> & source) {
00391 if (0 == &source)
00392 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00393 ::CORBA::ULong const length = source.length ();
00394 if (!(strm << length)) {
00395 return false;
00396 }
00397 return strm.write_char_array (source.get_buffer (), length);
00398 }
00399
00400 # if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)
00401 template <typename stream, CORBA::ULong MAX>
00402 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::WChar, MAX> & source) {
00403 if (0 == &source)
00404 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00405 ::CORBA::ULong const length = source.length ();
00406 if (!(strm << length)) {
00407 return false;
00408 }
00409 return strm.write_wchar_array (source.get_buffer (), length);
00410 }
00411 #endif
00412
00413 template <typename stream, CORBA::ULong MAX>
00414 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Float, MAX> & source) {
00415 if (0 == &source)
00416 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00417 ::CORBA::ULong const length = source.length ();
00418 if (!(strm << length)) {
00419 return false;
00420 }
00421 return strm.write_float_array (source.get_buffer (), length);
00422 }
00423
00424 template <typename stream, CORBA::ULong MAX>
00425 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Double, MAX> & source) {
00426 if (0 == &source)
00427 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00428 ::CORBA::ULong const length = source.length ();
00429 if (!(strm << length)) {
00430 return false;
00431 }
00432 return strm.write_double_array (source.get_buffer (), length);
00433 }
00434
00435 template <typename stream, CORBA::ULong MAX>
00436 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::ULongLong, MAX> & source) {
00437 if (0 == &source)
00438 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00439 ::CORBA::ULong const length = source.length ();
00440 if (!(strm << length)) {
00441 return false;
00442 }
00443 return strm.write_ulonglong_array (source.get_buffer (), length);
00444 }
00445
00446 template <typename stream, CORBA::ULong MAX>
00447 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::LongDouble, MAX> & source) {
00448 if (0 == &source)
00449 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00450 ::CORBA::ULong const length = source.length ();
00451 if (!(strm << length)) {
00452 return false;
00453 }
00454 return strm.write_longdouble_array (source.get_buffer (), length);
00455 }
00456
00457 template <typename stream, CORBA::ULong MAX>
00458 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Boolean, MAX> & source) {
00459 if (0 == &source)
00460 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00461 ::CORBA::ULong const length = source.length ();
00462 if (!(strm << length)) {
00463 return false;
00464 }
00465 return strm.write_boolean_array (source.get_buffer (), length);
00466 }
00467
00468 template <typename stream, typename value_t, CORBA::ULong MAX>
00469 bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <value_t, MAX> & source) {
00470 if (0 == &source)
00471 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00472 ::CORBA::ULong const length = source.length ();
00473 if (!(strm << length)) {
00474 return false;
00475 }
00476 for(CORBA::ULong i = 0; i < length; ++i) {
00477 if (!(strm << source[i])) {
00478 return false;
00479 }
00480 }
00481 return true;
00482 }
00483
00484 template <typename stream, typename charT, CORBA::ULong MAX>
00485 bool marshal_sequence(stream & strm, const TAO::details::bounded_basic_string_sequence <charT, MAX> & source) {
00486 if (0 == &source)
00487 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00488 ::CORBA::ULong const length = source.length ();
00489 if (!(strm << length)) {
00490 return false;
00491 }
00492 for(CORBA::ULong i = 0; i < length; ++i) {
00493 if (!(strm << source[i])) {
00494 return false;
00495 }
00496 }
00497 return true;
00498 }
00499
00500 template <typename stream, typename object_t, typename object_t_var, CORBA::ULong MAX>
00501 bool marshal_sequence(stream & strm, const TAO::bounded_object_reference_sequence<object_t, object_t_var, MAX> & source) {
00502 typedef typename TAO::bounded_object_reference_sequence<object_t, object_t_var, MAX>::object_type object_type;
00503 if (0 == &source)
00504 ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false);
00505 ::CORBA::ULong const length = source.length ();
00506 if (!(strm << length)) {
00507 return false;
00508 }
00509 for(CORBA::ULong i = 0; i < length; ++i) {
00510 if (!TAO::Objref_Traits<object_type>::marshal (source[i], strm)) {
00511 return false;
00512 }
00513 }
00514 return true;
00515 }
00516 }
00517
00518 TAO_END_VERSIONED_NAMESPACE_DECL
00519
00520 #endif