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