1 // -*- Mode: C++; -*- 2 // Package : omniORB 3 // seqTemplatedefns.h Created on: 14/5/96 4 // Author : Sai Lai Lo (sll) 5 // 6 // Copyright (C) 2003-2009 Apasphere Ltd 7 // Copyright (C) 1996-1999 AT&T Laboratories Cambridge 8 // 9 // This file is part of the omniORB library. 10 // 11 // The omniORB library is free software; you can redistribute it and/or 12 // modify it under the terms of the GNU Lesser General Public 13 // License as published by the Free Software Foundation; either 14 // version 2.1 of the License, or (at your option) any later version. 15 // 16 // This library is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 // Lesser General Public License for more details. 20 // 21 // You should have received a copy of the GNU Lesser General Public 22 // License along with this library. If not, see http://www.gnu.org/licenses/ 23 // 24 // 25 // Description: 26 // *** PROPRIETARY INTERFACE *** 27 28 #ifndef __SEQTEMPLATEDEFNS_H__ 29 #define __SEQTEMPLATEDEFNS_H__ 30 31 ////////////////////////////////////////////////////////////////////// 32 template <class T> 33 inline void 34 _CORBA_Unbounded_Sequence<T>::operator>>= (cdrStream& s) const 35 { 36 s.marshalULong(this->pd_len); 37 for (_CORBA_ULong i = 0; i < this->pd_len; i++) 38 this->pd_buf[i] >>= s; 39 } 40 41 42 ////////////////////////////////////////////////////////////////////// 43 template <class T> 44 inline void 45 _CORBA_Unbounded_Sequence<T>::operator<<= (cdrStream& s) 46 { 47 _CORBA_ULong l; 48 l <<= s; 49 if (!s.checkInputOverrun(1,l)) { 50 _CORBA_marshal_sequence_range_check_error(s); 51 // never reach here 52 } 53 this->length(l); 54 for (_CORBA_ULong i = 0; i < l; i++) 55 this->pd_buf[i] <<= s; 56 } 57 58 ////////////////////////////////////////////////////////////////////// 59 template <class T,int max> 60 inline void 61 _CORBA_Bounded_Sequence<T,max>::operator>>= (cdrStream& s) const 62 { 63 s.marshalULong(this->pd_len); 64 for (_CORBA_ULong i = 0; i < this->pd_len; i++) 65 this->pd_buf[i] >>= s; 66 } 67 68 69 ////////////////////////////////////////////////////////////////////// 70 template <class T,int max> 71 inline void 72 _CORBA_Bounded_Sequence<T,max>::operator<<= (cdrStream& s) 73 { 74 _CORBA_ULong l; 75 l <<= s; 76 if (!s.checkInputOverrun(1,l) || (l > max)) { 77 _CORBA_marshal_sequence_range_check_error(s); 78 // never reach here 79 } 80 this->length(l); 81 for (_CORBA_ULong i = 0; i < l; i++) 82 this->pd_buf[i] <<= s; 83 } 84 85 ////////////////////////////////////////////////////////////////////// 86 template <class T,int elmSize,int elmAlignment> 87 inline 88 void 89 _CORBA_Unbounded_Sequence_w_FixSizeElement<T,elmSize,elmAlignment>::operator>>= (cdrStream& s) const 90 { 91 if (s.marshal_byte_swap()) { 92 Base_T_seq::operator>>=(s); 93 return; 94 } 95 _CORBA_ULong l = Base_T_seq::length(); 96 l >>= s; 97 if (l==0) return; 98 s.put_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 99 (int)l*elmSize, 100 (omni::alignment_t)elmAlignment); 101 } 102 103 104 ////////////////////////////////////////////////////////////////////// 105 template <class T,int elmSize,int elmAlignment> 106 inline 107 void 108 _CORBA_Unbounded_Sequence_w_FixSizeElement<T,elmSize,elmAlignment>::operator<<= (cdrStream& s) 109 { 110 _CORBA_ULong l; 111 l <<= s; 112 if (!s.checkInputOverrun(elmSize,l)) { 113 _CORBA_marshal_sequence_range_check_error(s); 114 // never reach here 115 } 116 Base_T_seq::length(l); 117 if (l==0) return; 118 s.get_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 119 (int)l*elmSize, 120 (omni::alignment_t)elmAlignment); 121 122 if (s.unmarshal_byte_swap() && elmAlignment != 1) { 123 if (elmSize == 2) { 124 _CORBA_UShort* data = (_CORBA_UShort*)Base_T_seq::NP_data(); 125 126 for (_CORBA_ULong i=0; i<l; i++) { 127 data[i] = cdrStream::byteSwap(data[i]); 128 } 129 } 130 else if (elmSize == 4) { 131 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 132 133 for (_CORBA_ULong i=0; i<l; i++) { 134 data[i] = cdrStream::byteSwap(data[i]); 135 } 136 } 137 else if (elmSize == 8) { 138 139 #ifdef HAS_LongLong 140 _CORBA_ULongLong* data = (_CORBA_ULongLong*)Base_T_seq::NP_data(); 141 142 for (_CORBA_ULong i=0; i<l; i++) { 143 data[i] = cdrStream::byteSwap(data[i]); 144 } 145 #else 146 l *= 2; 147 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 148 _CORBA_ULong temp; 149 150 for (_CORBA_ULong i=0; i<l; i+=2) { 151 temp = cdrStream::byteSwap(data[i+i]); 152 data[i+1] = cdrStream::byteSwap(data[i]); 153 data[i] = temp; 154 } 155 #endif 156 } 157 } 158 } 159 160 ////////////////////////////////////////////////////////////////////// 161 template <class T,int max,int elmSize,int elmAlignment> 162 inline 163 void 164 _CORBA_Bounded_Sequence_w_FixSizeElement<T,max,elmSize,elmAlignment>::operator>>= (cdrStream& s) const 165 { 166 if (s.marshal_byte_swap()) { 167 Base_T_seq::operator>>=(s); 168 return; 169 } 170 _CORBA_ULong l = Base_T_seq::length(); 171 l >>= s; 172 if (l==0) return; 173 s.put_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 174 (int)l*elmSize, 175 (omni::alignment_t)elmAlignment); 176 } 177 178 179 ////////////////////////////////////////////////////////////////////// 180 template <class T,int max,int elmSize,int elmAlignment> 181 inline 182 void 183 _CORBA_Bounded_Sequence_w_FixSizeElement<T,max,elmSize,elmAlignment>::operator<<= (cdrStream& s) 184 { 185 _CORBA_ULong l; 186 l <<= s; 187 if (!s.checkInputOverrun(elmSize,l) || (l > max)) { 188 _CORBA_marshal_sequence_range_check_error(s); 189 // never reach here 190 } 191 Base_T_seq::length(l); 192 if (l==0) return; 193 s.get_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 194 (int)l*elmSize, 195 (omni::alignment_t)elmAlignment); 196 197 if (s.unmarshal_byte_swap() && elmAlignment != 1) { 198 if (elmSize == 2) { 199 _CORBA_UShort* data = (_CORBA_UShort*)Base_T_seq::NP_data(); 200 201 for (_CORBA_ULong i=0; i<l; i++) { 202 data[i] = cdrStream::byteSwap(data[i]); 203 } 204 } 205 else if (elmSize == 4) { 206 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 207 208 for (_CORBA_ULong i=0; i<l; i++) { 209 data[i] = cdrStream::byteSwap(data[i]); 210 } 211 } 212 else if (elmSize == 8) { 213 214 #ifdef HAS_LongLong 215 _CORBA_ULongLong* data = (_CORBA_ULongLong*)Base_T_seq::NP_data(); 216 217 for (_CORBA_ULong i=0; i<l; i++) { 218 data[i] = cdrStream::byteSwap(data[i]); 219 } 220 #else 221 l *= 2; 222 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 223 _CORBA_ULong temp; 224 225 for (_CORBA_ULong i=0; i<l; i+=2) { 226 temp = cdrStream::byteSwap(data[i+i]); 227 data[i+1] = cdrStream::byteSwap(data[i]); 228 data[i] = temp; 229 } 230 #endif 231 } 232 } 233 } 234 235 ////////////////////////////////////////////////////////////////////// 236 #ifdef OMNI_MIXED_ENDIAN_DOUBLE 237 238 // Template member function specializations to use the base 239 // marshalling functions for double, so the doubles are properly 240 // word-swapped. 241 242 template<> 243 inline 244 void 245 _CORBA_Unbounded_Sequence_w_FixSizeElement<_CORBA_Double,8,8>::operator>>= (cdrStream& s) const 246 { 247 Base_T_seq::operator>>=(s); 248 } 249 250 template<> 251 inline 252 void 253 _CORBA_Unbounded_Sequence_w_FixSizeElement<_CORBA_Double,8,8>::operator<<= (cdrStream& s) 254 { 255 Base_T_seq::operator<<=(s); 256 } 257 258 template<int max> 259 inline 260 void 261 _CORBA_Bounded_Sequence_w_FixSizeElement<_CORBA_Double,max,8,8>::operator>>= (cdrStream& s) const 262 { 263 Base_T_seq::operator>>=(s); 264 } 265 266 template<int max> 267 inline 268 void 269 _CORBA_Bounded_Sequence_w_FixSizeElement<_CORBA_Double,max,8,8>::operator<<= (cdrStream& s) 270 { 271 Base_T_seq::operator<<=(s); 272 } 273 274 #endif 275 276 277 ////////////////////////////////////////////////////////////////////// 278 inline 279 void 280 _CORBA_Sequence_Char::operator>>= (cdrStream& s) const 281 { 282 _CORBA_ULong l = Base_T_seq::length(); 283 l >>= s; 284 for( _CORBA_ULong i = 0; i < l; i++ ) 285 s.marshalChar(this->pd_buf[i]); 286 287 } 288 289 ////////////////////////////////////////////////////////////////////// 290 inline 291 void 292 _CORBA_Sequence_Char::operator<<= (cdrStream& s) 293 { 294 _CORBA_ULong l; 295 l <<= s; 296 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 297 _CORBA_marshal_sequence_range_check_error(s); 298 // never reach here 299 } 300 this->length(l); 301 for( _CORBA_ULong i = 0; i < l; i++ ) 302 this->pd_buf[i] = s.unmarshalChar(); 303 } 304 305 ////////////////////////////////////////////////////////////////////// 306 inline 307 void 308 _CORBA_Sequence_Boolean::operator>>= (cdrStream& s) const 309 { 310 _CORBA_ULong l = Base_T_seq::length(); 311 l >>= s; 312 if (l==0) return; 313 # if !defined(HAS_Cplusplus_Bool) || (SIZEOF_BOOL == 1) 314 s.put_octet_array((_CORBA_Octet*)this->pd_buf,l); 315 # else 316 for ( _CORBA_ULong i = 0; i < l; i++ ) 317 s.marshalBoolean(this->pd_buf[i]); 318 # endif 319 } 320 321 ////////////////////////////////////////////////////////////////////// 322 inline 323 void 324 _CORBA_Sequence_Boolean::operator<<= (cdrStream& s) 325 { 326 _CORBA_ULong l; 327 l <<= s; 328 if (!s.checkInputOverrun(1,l) || (pd_bounded && l > this->pd_max)) { 329 _CORBA_marshal_sequence_range_check_error(s); 330 // never reach here 331 } 332 this->length(l); 333 if (l==0) return; 334 # if !defined(HAS_Cplusplus_Bool) || (SIZEOF_BOOL == 1) 335 s.get_octet_array((_CORBA_Octet*)this->pd_buf,l); 336 # else 337 for ( _CORBA_ULong i = 0; i < l; i++ ) 338 this->pd_buf[i] = s.unmarshalBoolean(); 339 # endif 340 } 341 342 ////////////////////////////////////////////////////////////////////// 343 inline 344 void 345 _CORBA_Sequence_Octet::operator>>= (cdrStream& s) const 346 { 347 _CORBA_ULong l = Base_T_seq::length(); 348 l >>= s; 349 if (l==0) return; 350 s.put_octet_array(this->pd_buf,l); 351 } 352 353 ////////////////////////////////////////////////////////////////////// 354 inline 355 void 356 _CORBA_Sequence_Octet::operator<<= (cdrStream& s) 357 { 358 _CORBA_ULong l; 359 l <<= s; 360 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 361 _CORBA_marshal_sequence_range_check_error(s); 362 // never reach here 363 } 364 this->length(l); 365 if (l==0) return; 366 s.get_octet_array(this->pd_buf,l); 367 } 368 369 ////////////////////////////////////////////////////////////////////// 370 inline 371 void 372 _CORBA_Sequence_WChar::operator>>= (cdrStream& s) const 373 { 374 _CORBA_ULong l = Base_T_seq::length(); 375 l >>= s; 376 for( _CORBA_ULong i = 0; i < l; i++ ) 377 s.marshalWChar(this->pd_buf[i]); 378 } 379 380 ////////////////////////////////////////////////////////////////////// 381 inline 382 void 383 _CORBA_Sequence_WChar::operator<<= (cdrStream& s) 384 { 385 _CORBA_ULong l; 386 l <<= s; 387 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 388 _CORBA_marshal_sequence_range_check_error(s); 389 // never reach here 390 } 391 this->length(l); 392 for( _CORBA_ULong i = 0; i < l; i++ ) 393 this->pd_buf[i] = s.unmarshalWChar(); 394 } 395 396 ////////////////////////////////////////////////////////////////////// 397 template <class T,class T_slice,class Telm,int dimension> 398 inline void 399 _CORBA_Unbounded_Sequence_Array<T,T_slice,Telm,dimension>::operator>>= (cdrStream& s) const 400 { 401 this->pd_len >>= s; 402 for (_CORBA_ULong i=0; i<this->pd_len; i++) { 403 for (_CORBA_ULong j=0; j<dimension; j++) { 404 *((Telm*)(this->pd_buf[i]) + j) >>= s; 405 } 406 } 407 return; 408 } 409 410 411 ////////////////////////////////////////////////////////////////////// 412 template <class T,class T_slice,class Telm,int dimension> 413 inline void 414 _CORBA_Unbounded_Sequence_Array<T,T_slice,Telm,dimension>::operator<<= (cdrStream& s) 415 { 416 _CORBA_ULong l; 417 l <<= s; 418 if (!s.checkInputOverrun(1,l)) { 419 _CORBA_marshal_sequence_range_check_error(s); 420 // never reach here 421 } 422 this->length(l); 423 for (_CORBA_ULong i=0; i<l; i++) { 424 for (_CORBA_ULong j=0; j<dimension; j++) { 425 *((Telm*)(this->pd_buf[i]) + j) <<= s; 426 } 427 } 428 return; 429 } 430 431 ////////////////////////////////////////////////////////////////////// 432 template <class T,class T_slice,class Telm,int dimension,int max> 433 inline void 434 _CORBA_Bounded_Sequence_Array<T,T_slice,Telm,dimension,max>::operator>>= (cdrStream& s) const 435 { 436 this->pd_len >>= s; 437 for (_CORBA_ULong i=0; i<this->pd_len; i++) { 438 for (_CORBA_ULong j=0; j<dimension; j++) { 439 *((Telm*)(this->pd_buf[i]) + j) >>= s; 440 } 441 } 442 return; 443 } 444 445 446 ////////////////////////////////////////////////////////////////////// 447 template <class T,class T_slice,class Telm,int dimension,int max> 448 inline void 449 _CORBA_Bounded_Sequence_Array<T,T_slice,Telm,dimension,max>::operator<<= (cdrStream& s) 450 { 451 _CORBA_ULong l; 452 l <<= s; 453 if (!s.checkInputOverrun(1,l) || (l > max)) { 454 _CORBA_marshal_sequence_range_check_error(s); 455 // never reach here 456 } 457 this->length(l); 458 for (_CORBA_ULong i=0; i<l; i++) { 459 for (_CORBA_ULong j=0; j<dimension; j++) { 460 *((Telm*)(this->pd_buf[i]) + j) <<= s; 461 } 462 } 463 return; 464 } 465 466 ////////////////////////////////////////////////////////////////////// 467 template<class T, class T_slice, int dimension> 468 inline void 469 _CORBA_Sequence_Array_Char<T,T_slice,dimension>::operator>>=(cdrStream& s) const 470 { 471 this->pd_len >>= s; 472 for (_CORBA_ULong i=0; i<this->pd_len; i++) { 473 for (_CORBA_ULong j=0; j<dimension; j++) { 474 s.marshalChar(*((_CORBA_Char*)(this->pd_buf[i]) + j)); 475 } 476 } 477 } 478 479 ////////////////////////////////////////////////////////////////////// 480 template<class T, class T_slice, int dimension> 481 inline void 482 _CORBA_Sequence_Array_Char<T,T_slice,dimension>::operator<<=(cdrStream& s) 483 { 484 _CORBA_ULong l; 485 l <<= s; 486 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 487 _CORBA_marshal_sequence_range_check_error(s); 488 // never reach here 489 } 490 this->length(l); 491 for (_CORBA_ULong i=0; i<l; i++) { 492 for (_CORBA_ULong j=0; j<dimension; j++) { 493 *((_CORBA_Char*)(this->pd_buf[i]) + j) = s.unmarshalChar(); 494 } 495 } 496 } 497 498 ////////////////////////////////////////////////////////////////////// 499 template<class T, class T_slice, int dimension> 500 inline void 501 _CORBA_Sequence_Array_Boolean<T,T_slice,dimension>::operator>>=(cdrStream& s) const 502 { 503 this->pd_len >>= s; 504 if (this->pd_len==0) return; 505 # if !defined(HAS_Cplusplus_Bool) || (SIZEOF_BOOL == 1) 506 s.put_octet_array((_CORBA_Octet*)this->pd_buf,(int)this->pd_len*dimension); 507 # else 508 for (_CORBA_ULong i=0; i<this->pd_len; i++) { 509 for (_CORBA_ULong j=0; j<dimension; j++) { 510 s.marshalBoolean(*((_CORBA_Boolean*)(this->pd_buf[i]) + j)); 511 } 512 } 513 # endif 514 } 515 516 ////////////////////////////////////////////////////////////////////// 517 template<class T, class T_slice, int dimension> 518 inline void 519 _CORBA_Sequence_Array_Boolean<T,T_slice,dimension>::operator<<=(cdrStream& s) 520 { 521 _CORBA_ULong l; 522 l <<= s; 523 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 524 _CORBA_marshal_sequence_range_check_error(s); 525 // never reach here 526 } 527 this->length(l); 528 if (l==0) return; 529 # if !defined(HAS_Cplusplus_Bool) || (SIZEOF_BOOL == 1) 530 s.get_octet_array((_CORBA_Octet*)this->pd_buf,(int)l*dimension); 531 # else 532 for (_CORBA_ULong i=0; i<l; i++) { 533 for (_CORBA_ULong j=0; j<dimension; j++) { 534 *((_CORBA_Boolean*)(this->pd_buf[i]) + j) = s.unmarshalBoolean(); 535 } 536 } 537 # endif 538 } 539 ////////////////////////////////////////////////////////////////////// 540 template<class T, class T_slice, int dimension> 541 inline void 542 _CORBA_Sequence_Array_Octet<T,T_slice,dimension>::operator>>=(cdrStream& s) const 543 { 544 this->pd_len >>= s; 545 if (this->pd_len==0) return; 546 s.put_octet_array((_CORBA_Octet*)this->pd_buf,(int)this->pd_len*dimension); 547 } 548 549 ////////////////////////////////////////////////////////////////////// 550 template<class T, class T_slice, int dimension> 551 inline void 552 _CORBA_Sequence_Array_Octet<T,T_slice,dimension>::operator<<=(cdrStream& s) 553 { 554 _CORBA_ULong l; 555 l <<= s; 556 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 557 _CORBA_marshal_sequence_range_check_error(s); 558 // never reach here 559 } 560 this->length(l); 561 if (l==0) return; 562 s.get_octet_array((_CORBA_Octet*)this->pd_buf,(int)l*dimension); 563 } 564 565 ////////////////////////////////////////////////////////////////////// 566 template<class T, class T_slice, int dimension> 567 inline void 568 _CORBA_Sequence_Array_WChar<T,T_slice,dimension>::operator>>=(cdrStream& s) const 569 { 570 this->pd_len >>= s; 571 for (_CORBA_ULong i=0; i<this->pd_len; i++) { 572 for (_CORBA_ULong j=0; j<dimension; j++) { 573 s.marshalWChar(*((_CORBA_WChar*)(this->pd_buf[i]) + j)); 574 } 575 } 576 } 577 578 ////////////////////////////////////////////////////////////////////// 579 template<class T, class T_slice, int dimension> 580 inline void 581 _CORBA_Sequence_Array_WChar<T,T_slice,dimension>::operator<<=(cdrStream& s) 582 { 583 _CORBA_ULong l; 584 l <<= s; 585 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 586 _CORBA_marshal_sequence_range_check_error(s); 587 // never reach here 588 } 589 this->length(l); 590 for (_CORBA_ULong i=0; i<l; i++) { 591 for (_CORBA_ULong j=0; j<dimension; j++) { 592 *((_CORBA_WChar*)(this->pd_buf[i]) + j) = s.unmarshalWChar(); 593 } 594 } 595 } 596 597 ////////////////////////////////////////////////////////////////////// 598 template <class T,class T_slice,class Telm,int dimension,int elmSize,int elmAlignment> 599 inline 600 void 601 _CORBA_Unbounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,elmSize,elmAlignment>::operator>>= (cdrStream& s) const 602 { 603 if (s.marshal_byte_swap()) { 604 Base_T_seq::operator>>=(s); 605 return; 606 } 607 608 _CORBA_ULong l = Base_T_seq::length(); 609 l >>= s; 610 if (l==0) return; 611 s.put_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 612 (int)l*dimension*elmSize, 613 (omni::alignment_t)elmAlignment); 614 } 615 616 617 ////////////////////////////////////////////////////////////////////// 618 template <class T,class T_slice,class Telm,int dimension,int elmSize,int elmAlignment> 619 inline 620 void 621 _CORBA_Unbounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,elmSize,elmAlignment>::operator<<= (cdrStream& s) 622 { 623 _CORBA_ULong l; 624 l <<= s; 625 if (!s.checkInputOverrun(elmSize,l*dimension)) { 626 _CORBA_marshal_sequence_range_check_error(s); 627 // never reach here 628 } 629 Base_T_seq::length(l); 630 if (l==0) return; 631 s.get_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 632 (int)l*dimension*elmSize, 633 (omni::alignment_t)elmAlignment); 634 635 if (s.unmarshal_byte_swap() && elmAlignment != 1) { 636 l *= dimension; 637 638 if (elmSize == 2) { 639 _CORBA_UShort* data = (_CORBA_UShort*)Base_T_seq::NP_data(); 640 641 for (_CORBA_ULong i=0; i<l; i++) { 642 data[i] = cdrStream::byteSwap(data[i]); 643 } 644 } 645 else if (elmSize == 4) { 646 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 647 648 for (_CORBA_ULong i=0; i<l; i++) { 649 data[i] = cdrStream::byteSwap(data[i]); 650 } 651 } 652 else if (elmSize == 8) { 653 654 #ifdef HAS_LongLong 655 _CORBA_ULongLong* data = (_CORBA_ULongLong*)Base_T_seq::NP_data(); 656 657 for (_CORBA_ULong i=0; i<l; i++) { 658 data[i] = cdrStream::byteSwap(data[i]); 659 } 660 #else 661 l *= 2; 662 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 663 _CORBA_ULong temp; 664 665 for (_CORBA_ULong i=0; i<l; i+=2) { 666 temp = cdrStream::byteSwap(data[i+i]); 667 data[i+1] = cdrStream::byteSwap(data[i]); 668 data[i] = temp; 669 } 670 #endif 671 } 672 } 673 } 674 675 ////////////////////////////////////////////////////////////////////// 676 template <class T,class T_slice,class Telm,int dimension,int max,int elmSize,int elmAlignment> 677 inline 678 void 679 _CORBA_Bounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,max,elmSize,elmAlignment>::operator>>= (cdrStream& s) const 680 { 681 if (s.marshal_byte_swap()) { 682 Base_T_seq::operator>>=(s); 683 return; 684 } 685 686 _CORBA_ULong l = Base_T_seq::length(); 687 l >>= s; 688 if (l==0) return; 689 s.put_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 690 (int)l*dimension*elmSize, 691 (omni::alignment_t)elmAlignment); 692 } 693 694 695 ////////////////////////////////////////////////////////////////////// 696 template <class T,class T_slice,class Telm,int dimension,int max,int elmSize,int elmAlignment> 697 inline 698 void 699 _CORBA_Bounded_Sequence_Array_w_FixSizeElement<T,T_slice,Telm,dimension,max,elmSize,elmAlignment>::operator<<= (cdrStream& s) 700 { 701 _CORBA_ULong l; 702 l <<= s; 703 if (!s.checkInputOverrun(elmSize,l*dimension) || (l > max)) { 704 _CORBA_marshal_sequence_range_check_error(s); 705 // never reach here 706 } 707 Base_T_seq::length(l); 708 if (l==0) return; 709 s.get_octet_array((_CORBA_Octet*)Base_T_seq::NP_data(), 710 (int)l*dimension*elmSize, 711 (omni::alignment_t)elmAlignment); 712 713 if (s.unmarshal_byte_swap() && elmAlignment != 1) { 714 l *= dimension; 715 716 if (elmSize == 2) { 717 _CORBA_UShort* data = (_CORBA_UShort*)Base_T_seq::NP_data(); 718 719 for (_CORBA_ULong i=0; i<l; i++) { 720 data[i] = cdrStream::byteSwap(data[i]); 721 } 722 } 723 else if (elmSize == 4) { 724 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 725 726 for (_CORBA_ULong i=0; i<l; i++) { 727 data[i] = cdrStream::byteSwap(data[i]); 728 } 729 } 730 else if (elmSize == 8) { 731 732 #ifdef HAS_LongLong 733 _CORBA_ULongLong* data = (_CORBA_ULongLong*)Base_T_seq::NP_data(); 734 735 for (_CORBA_ULong i=0; i<l; i++) { 736 data[i] = cdrStream::byteSwap(data[i]); 737 } 738 #else 739 l *= 2; 740 _CORBA_ULong* data = (_CORBA_ULong*)Base_T_seq::NP_data(); 741 _CORBA_ULong temp; 742 743 for (_CORBA_ULong i=0; i<l; i+=2) { 744 temp = cdrStream::byteSwap(data[i+i]); 745 data[i+1] = cdrStream::byteSwap(data[i]); 746 data[i] = temp; 747 } 748 #endif 749 } 750 } 751 } 752 753 ////////////////////////////////////////////////////////////////////// 754 template <class T, class T_Elem,class T_Helper> 755 inline void 756 _CORBA_Sequence_ObjRef<T,T_Elem,T_Helper>::operator>>= (cdrStream& s) const 757 { 758 s.marshalULong(this->pd_len); 759 for( int i = 0; i < (int)this->pd_len; i++ ) 760 T_Helper::marshalObjRef(pd_buf[i],s); 761 } 762 763 764 ////////////////////////////////////////////////////////////////////// 765 template <class T, class T_Elem,class T_Helper> 766 inline void 767 _CORBA_Sequence_ObjRef<T,T_Elem,T_Helper>::operator<<= (cdrStream& s) 768 { 769 _CORBA_ULong l; 770 l <<= s; 771 if (!s.checkInputOverrun(1,l) || (this->pd_bounded && l > this->pd_max)) { 772 _CORBA_marshal_sequence_range_check_error(s); 773 // never reach here 774 } 775 776 _CORBA_ULong i; 777 778 if (this->pd_rel) { 779 T* nil_ = T_Helper::_nil(); 780 for (i=0; i < this->pd_len; i++) { 781 T_Helper::release(pd_buf[i]); 782 pd_buf[i] = nil_; 783 } 784 } 785 this->pd_len = 0; 786 787 this->length(l); 788 for (i = 0; i < l; i++) 789 this->pd_buf[i] = T_Helper::unmarshalObjRef(s); 790 } 791 792 793 #endif // __SEQTEMPLATEDEFNS_H__ 794