/usr/include/omniORB4/cdrStream.h is in libomniorb4-dev 4.1.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 | // -*- Mode: C++; -*-
// Package : omniORB
// cdrStream.h Created on: 11/1/99
// Author : Sai Lai Lo (sll)
//
// Copyright (C) 2003-2007 Apasphere Ltd
// Copyright (C) 1999 AT&T Laboratories, Cambridge
//
// This file is part of the omniORB library
//
// The omniORB library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA
//
//
// Description:
// *** PROPRIETARY INTERFACE ***
//
/*
$Log$
Revision 1.1.4.17 2007/04/12 19:50:33 dgrisby
A few cases of sizeof(bool) > 1 were not handled correctly.
Revision 1.1.4.16 2007/02/11 23:44:59 dgrisby
Value chunk stream looked at wrong byteswap flag in getLength.
Revision 1.1.4.15 2006/06/06 16:39:37 dgrisby
marshalRawString and chunking stream did not byte-swap length fields
when required to.
Revision 1.1.4.14 2006/05/21 17:43:24 dgrisby
Remove obsolete pd_chunked flag.
Revision 1.1.4.13 2006/05/20 16:23:37 dgrisby
Minor cdrMemoryStream and TypeCode performance tweaks.
Revision 1.1.4.12 2006/05/15 10:13:00 dgrisby
Data was overwritten when a chunk ended with an array; make
declareArrayLength() virtual.
Revision 1.1.4.11 2006/04/28 18:40:46 dgrisby
Merge from omni4_0_develop.
Revision 1.1.4.10 2005/12/08 14:22:31 dgrisby
Better string marshalling performance; other minor optimisations.
Revision 1.1.4.9 2005/07/22 17:18:40 dgrisby
Another merge from omni4_0_develop.
Revision 1.1.4.8 2005/01/06 23:08:09 dgrisby
Big merge from omni4_0_develop.
Revision 1.1.4.7 2005/01/06 17:31:07 dgrisby
Changes (mainly from omni4_0_develop) to compile on gcc 3.4.
Revision 1.1.4.6 2004/07/23 10:29:56 dgrisby
Completely new, much simpler Any implementation.
Revision 1.1.4.5 2004/07/04 23:53:35 dgrisby
More ValueType TypeCode and Any support.
Revision 1.1.4.4 2003/11/06 11:56:55 dgrisby
Yet more valuetype. Plain valuetype and abstract valuetype are now working.
Revision 1.1.4.3 2003/07/10 21:52:31 dgrisby
Value chunks should start after URL / repoids.
Revision 1.1.4.2 2003/05/20 16:53:12 dgrisby
Valuetype marshalling support.
Revision 1.1.4.1 2003/03/23 21:04:17 dgrisby
Start of omniORB 4.1.x development branch.
Revision 1.1.2.20 2003/03/02 17:10:41 dgrisby
AIX patches integrated in main tree.
Revision 1.1.2.19 2002/03/14 14:39:44 dpg1
Obscure bug in objref creation with unaligned buffers.
Revision 1.1.2.18 2002/03/11 12:23:03 dpg1
Tweaks to avoid compiler warnings.
Revision 1.1.2.17 2001/11/14 17:13:41 dpg1
Long double support.
Revision 1.1.2.16 2001/10/17 16:33:27 dpg1
New downcast mechanism for cdrStreams.
Revision 1.1.2.15 2001/09/19 17:29:04 dpg1
Cosmetic changes.
Revision 1.1.2.14 2001/08/22 13:29:45 dpg1
Re-entrant Any marshalling.
Revision 1.1.2.13 2001/08/17 17:02:22 sll
Removed static variables ncs_c, ncs_w, default_tcs_c, default_tcs_w.
Revision 1.1.2.12 2001/07/31 16:32:02 sll
Added virtual function is_giopStream to check if a cdrStream is a giopStream.
That is, a poor man's substitute for dynamic_cast.
Revision 1.1.2.11 2001/06/13 19:58:37 sll
Added omni namespace scoping for omniCodeSet.
Revision 1.1.2.10 2001/05/10 15:03:50 dpg1
Update cdrStreamAdapter to modified cdrStream interface.
Revision 1.1.2.9 2001/04/18 17:50:44 sll
Big checkin with the brand new internal APIs.
Scoped where appropriate with the omni namespace.
Revision 1.1.2.8 2001/01/09 17:16:59 dpg1
New cdrStreamAdapter class to allow omniORBpy to intercept buffer
management.
Revision 1.1.2.7 2000/12/05 17:39:31 dpg1
New cdrStream functions to marshal and unmarshal raw strings.
Revision 1.1.2.6 2000/11/22 14:37:58 dpg1
Code set marshalling functions now take a string length argument.
Revision 1.1.2.5 2000/11/15 17:16:23 sll
Added char, wchar codeset convertor support to cdrStream.
Revision 1.1.2.4 2000/11/09 12:27:49 dpg1
Huge merge from omni3_develop, plus full long long from omni3_1_develop.
Revision 1.1.2.3 2000/11/03 18:49:16 sll
Separate out the marshalling of byte, octet and char into 3 set of distinct
marshalling functions.
Renamed put_char_array and get_char_array to put_octet_array and
get_octet_array.
New string marshal member functions.
Revision 1.1.2.2 2000/10/10 10:14:27 sll
Extra ctor for cdrEncapsulationStream which initialise the buffer by
fetching data from the argument cdrStream.
Revision 1.1.2.1 2000/09/27 16:54:08 sll
*** empty log message ***
*/
#ifndef __CDRSTREAM_H__
#define __CDRSTREAM_H__
#include <limits.h>
#ifndef Swap16
#define Swap16(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
#else
#error "Swap16 has already been defined"
#endif
#ifndef Swap32
#define Swap32(l) ((((l) & 0xff000000) >> 24) | \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24))
#else
#error "Swap32 has already been defined"
#endif
#ifdef HAS_LongLong
#ifndef Swap64
#define Swap64(l) \
((((l) & _CORBA_LONGLONG_CONST(0xff00000000000000)) >> 56) | \
(((l) & _CORBA_LONGLONG_CONST(0x00ff000000000000)) >> 40) | \
(((l) & _CORBA_LONGLONG_CONST(0x0000ff0000000000)) >> 24) | \
(((l) & _CORBA_LONGLONG_CONST(0x000000ff00000000)) >> 8) | \
(((l) & _CORBA_LONGLONG_CONST(0x00000000ff000000)) << 8) | \
(((l) & _CORBA_LONGLONG_CONST(0x0000000000ff0000)) << 24) | \
(((l) & _CORBA_LONGLONG_CONST(0x000000000000ff00)) << 40) | \
(((l) & _CORBA_LONGLONG_CONST(0x00000000000000ff)) << 56))
#else
#error "Swap64 has already been defined"
#endif
#endif
// Technically, we have to declare friend functions outside of the
// class to put them into the global scope (this is pretty esoteric:
// friend functions are not in class scope but if they are first
// declared inside the class they aren't in global scope either...or
// something like that...) It is too bad we have to have operators in
// global scope but some compilers don't handle Koenig lookup
// correctly.
class cdrStream;
inline void operator>>= (_CORBA_Short a, cdrStream& s);
inline void operator<<= (_CORBA_Short& a, cdrStream& s);
inline void operator>>= (_CORBA_UShort a, cdrStream& s);
inline void operator<<= (_CORBA_UShort& a, cdrStream& s);
inline void operator>>= (_CORBA_Long a, cdrStream& s);
inline void operator<<= (_CORBA_Long& a, cdrStream& s);
inline void operator>>= (_CORBA_ULong a, cdrStream& s);
inline void operator<<= (_CORBA_ULong& a, cdrStream& s);
#ifdef HAS_LongLong
inline void operator>>= (_CORBA_LongLong a, cdrStream& s);
inline void operator<<= (_CORBA_LongLong& a, cdrStream& s);
inline void operator>>= (_CORBA_ULongLong a, cdrStream& s);
inline void operator<<= (_CORBA_ULongLong& a, cdrStream& s);
#endif
class cdrStreamAdapter;
class cdrValueChunkStream;
OMNI_NAMESPACE_BEGIN(omni)
class ValueIndirectionTracker {
public:
virtual ~ValueIndirectionTracker();
};
OMNI_NAMESPACE_END(omni)
class cdrStream {
public:
cdrStream();
virtual ~cdrStream();
#ifndef CdrMarshal
#define CdrMarshal(s,type,align,arg) do {\
again: \
omni::ptr_arith_t p1 = omni::align_to((omni::ptr_arith_t)s.pd_outb_mkr,align);\
omni::ptr_arith_t p2 = p1 + sizeof(type);\
if( (void*)p2 > s.pd_outb_end ) {\
if (s.reserveOutputSpaceForPrimitiveType(align,sizeof(type)))\
goto again;\
else {\
s.pd_outb_mkr = (void*) p2;\
break;\
}\
}\
s.pd_outb_mkr = (void*) p2;\
*((type*)p1) = arg;\
} while(0)
#else
#error "CdrMarshal has already been defined"
#endif
#ifndef CdrUnMarshal
#define CdrUnMarshal(s,type,align,arg) do {\
again: \
omni::ptr_arith_t p1 = omni::align_to((omni::ptr_arith_t)s.pd_inb_mkr,align);\
omni::ptr_arith_t p2 = p1 + sizeof(type);\
if ((void *)p2 > s.pd_inb_end) {\
s.fetchInputData(align,sizeof(type));\
goto again;\
}\
s.pd_inb_mkr = (void*) p2;\
arg = *((type*)p1);\
} while(0)
#else
#error "CdrUnMarshal has already been defined"
#endif
// Macros to convert floats to integers or arrays of integers so they
// may be byte-swapped. The default version uses a union to do the
// conversion, but that fails for VMS which uses classes to represent
// float types. The version with reinterpret_cast<> fails on some
// platforms with strict aliasing.
#ifndef USING_PROXY_FLOAT
#define convertFromFloat(float_t, int_t) \
union { float_t a; int_t l; } u; \
u.a = a; \
int_t l = u.l
#define convertToFloat(float_t, int_t) \
union { float_t a; int_t l; } u; \
u.l = l; \
a = u.a
#else
#define convertFromFloat(float_t, int_t) \
int_t l = OMNI_REINTERPRET_CAST(int_t, a)
#define convertToFloat(float_t, int_t) \
a = OMNI_REINTERPRET_CAST(float_t, l)
#endif
inline void marshalChar(_CORBA_Char a) {
pd_ncs_c->marshalChar(*this,pd_tcs_c,a);
}
inline _CORBA_Char unmarshalChar() {
return pd_ncs_c->unmarshalChar(*this,pd_tcs_c);
}
inline void marshalWChar(_CORBA_WChar a) {
pd_ncs_w->marshalWChar(*this,pd_tcs_w,a);
}
inline _CORBA_WChar unmarshalWChar() {
return pd_ncs_w->unmarshalWChar(*this,pd_tcs_w);
}
inline void marshalOctet(_CORBA_Octet a) {
// No need to align here
do {
again:
omni::ptr_arith_t p1 = (omni::ptr_arith_t)pd_outb_mkr;
omni::ptr_arith_t p2 = p1 + 1;
if( (void*)p2 > pd_outb_end ) {
if (reserveOutputSpaceForPrimitiveType(omni::ALIGN_1, 1))
goto again;
else {
pd_outb_mkr = (void*) p2;
break;
}
}
pd_outb_mkr = (void*) p2;
*((_CORBA_Octet*)p1) = a;
} while (0);
}
inline _CORBA_Octet unmarshalOctet() {
_CORBA_Octet a;
do {
again:
omni::ptr_arith_t p1 = (omni::ptr_arith_t)pd_inb_mkr;
omni::ptr_arith_t p2 = p1 + sizeof(_CORBA_Octet);
if ((void *)p2 > pd_inb_end) {
fetchInputData(omni::ALIGN_1,sizeof(_CORBA_Octet));
goto again;
}
pd_inb_mkr = (void*) p2;
a = *((_CORBA_Octet*)p1);
} while(0);
return a;
}
inline void marshalBoolean(_CORBA_Boolean b) {
_CORBA_Char c = b ? 1 : 0;
CdrMarshal((*this),_CORBA_Char,omni::ALIGN_1,c);
}
inline _CORBA_Boolean unmarshalBoolean() {
_CORBA_Char c;
CdrUnMarshal((*this),_CORBA_Char,omni::ALIGN_1,c);
#ifdef HAS_Cplusplus_Bool
return c ? true : false;
#else
return c;
#endif
}
#ifndef OMNI_NO_INLINE_FRIENDS
friend inline void operator>>= (_CORBA_Short a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_Short t = Swap16(a);
a = t;
}
CdrMarshal(s,_CORBA_Short,omni::ALIGN_2,a);
}
friend inline void operator<<= (_CORBA_Short& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_Short,omni::ALIGN_2,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_Short t = Swap16(a);
a = t;
}
}
friend inline void operator>>= (_CORBA_UShort a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_UShort t = Swap16(a);
a = t;
}
CdrMarshal(s,_CORBA_UShort,omni::ALIGN_2,a);
}
friend inline void operator<<= (_CORBA_UShort& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_UShort,omni::ALIGN_2,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_UShort t = Swap16(a);
a = t;
}
}
friend inline void operator>>= (_CORBA_Long a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_Long t = Swap32(a);
a = t;
}
CdrMarshal(s,_CORBA_Long,omni::ALIGN_4,a);
}
friend inline void operator<<= (_CORBA_Long& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_Long,omni::ALIGN_4,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_Long t = Swap32(a);
a = t;
}
}
friend inline void operator>>= (_CORBA_ULong a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_ULong t = Swap32(a);
a = t;
}
CdrMarshal(s,_CORBA_ULong,omni::ALIGN_4,a);
}
friend inline void operator<<= (_CORBA_ULong& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_ULong,omni::ALIGN_4,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_ULong t = Swap32(a);
a = t;
}
}
# ifdef HAS_LongLong
friend inline void operator>>= (_CORBA_LongLong a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_LongLong t = Swap64(a);
a = t;
}
CdrMarshal(s,_CORBA_LongLong,omni::ALIGN_8,a);
}
friend inline void operator<<= (_CORBA_LongLong& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_LongLong,omni::ALIGN_8,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_LongLong t = Swap64(a);
a = t;
}
}
friend inline void operator>>= (_CORBA_ULongLong a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_ULongLong t = Swap64(a);
a = t;
}
CdrMarshal(s,_CORBA_ULongLong,omni::ALIGN_8,a);
}
friend inline void operator<<= (_CORBA_ULongLong& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_ULongLong,omni::ALIGN_8,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_ULongLong t = Swap64(a);
a = t;
}
}
# endif
#else
friend inline void operator>>= (_CORBA_Short a, cdrStream& s);
friend inline void operator<<= (_CORBA_Short& a, cdrStream& s);
friend inline void operator>>= (_CORBA_UShort a, cdrStream& s);
friend inline void operator<<= (_CORBA_UShort& a, cdrStream& s);
friend inline void operator>>= (_CORBA_Long a, cdrStream& s);
friend inline void operator<<= (_CORBA_Long& a, cdrStream& s);
friend inline void operator>>= (_CORBA_ULong a, cdrStream& s);
friend inline void operator<<= (_CORBA_ULong& a, cdrStream& s);
# ifdef HAS_LongLong
friend inline void operator>>= (_CORBA_LongLong a, cdrStream& s);
friend inline void operator<<= (_CORBA_LongLong& a, cdrStream& s);
friend inline void operator>>= (_CORBA_ULongLong a, cdrStream& s);
friend inline void operator<<= (_CORBA_ULongLong& a, cdrStream& s);
# endif
#endif
#if !defined(NO_FLOAT)
#ifndef OMNI_NO_INLINE_FRIENDS
friend inline void operator>>= (_CORBA_Float a, cdrStream& s) {
convertFromFloat(_CORBA_Float, _CORBA_ULong);
if (s.pd_marshal_byte_swap) {
l = Swap32(l);
}
CdrMarshal(s,_CORBA_ULong,omni::ALIGN_4,l);
}
friend inline void operator<<= (_CORBA_Float& a, cdrStream& s) {
_CORBA_ULong l;
CdrUnMarshal(s,_CORBA_ULong,omni::ALIGN_4,l);
if (s.pd_unmarshal_byte_swap) {
l = Swap32(l);
}
convertToFloat(_CORBA_Float, _CORBA_ULong);
}
friend inline void operator>>= (_CORBA_Double a, cdrStream& s) {
struct LongArray2 { _CORBA_ULong l[2]; };
convertFromFloat(_CORBA_Double, LongArray2);
if (s.pd_marshal_byte_swap) {
LongArray2 m;
m.l[0] = Swap32(l.l[1]);
m.l[1] = Swap32(l.l[0]);
l = m;
}
#ifdef OMNI_MIXED_ENDIAN_DOUBLE
{
_CORBA_ULong v = l.l[0];
l.l[0] = l.l[1];
l.l[1] = v;
}
#endif
CdrMarshal(s,LongArray2,omni::ALIGN_8,l);
}
friend inline void operator<<= (_CORBA_Double& a, cdrStream& s) {
struct LongArray2 { _CORBA_ULong l[2]; } l;
CdrUnMarshal(s,LongArray2,omni::ALIGN_8,l);
if (s.pd_unmarshal_byte_swap) {
LongArray2 m;
m.l[0] = Swap32(l.l[1]);
m.l[1] = Swap32(l.l[0]);
l = m;
}
#ifdef OMNI_MIXED_ENDIAN_DOUBLE
{
_CORBA_ULong v = l.l[0];
l.l[0] = l.l[1];
l.l[1] = v;
}
#endif
convertToFloat(_CORBA_Double, LongArray2);
}
#else
friend inline void operator>>= (_CORBA_Float a, cdrStream& s);
friend inline void operator<<= (_CORBA_Float& a, cdrStream& s);
friend inline void operator>>= (_CORBA_Double a, cdrStream& s);
friend inline void operator<<= (_CORBA_Double& a, cdrStream& s);
#endif
#endif
#ifdef HAS_LongDouble
#if SIZEOF_LONG_DOUBLE == 16
#ifndef OMNI_NO_INLINE_FRIENDS
friend inline void operator>>= (_CORBA_LongDouble a, cdrStream& s) {
struct LongArray4 { _CORBA_ULong l[4]; };
convertFromFloat(_CORBA_LongDouble, LongArray4);
if (s.pd_marshal_byte_swap) {
LongArray4 m;
m.l[0] = Swap32(l.l[3]);
m.l[1] = Swap32(l.l[2]);
m.l[2] = Swap32(l.l[1]);
m.l[3] = Swap32(l.l[0]);
l = m;
}
CdrMarshal(s,LongArray4,omni::ALIGN_8,l);
}
friend inline void operator<<= (_CORBA_LongDouble& a, cdrStream& s) {
struct LongArray4 { _CORBA_ULong l[4]; } l;
CdrUnMarshal(s,LongArray4,omni::ALIGN_8,l);
if (s.pd_unmarshal_byte_swap) {
LongArray4 m;
m.l[0] = Swap32(l.l[3]);
m.l[1] = Swap32(l.l[2]);
m.l[2] = Swap32(l.l[1]);
m.l[3] = Swap32(l.l[0]);
l = m;
}
convertToFloat(_CORBA_LongDouble, LongArray4);
}
#else
friend inline void operator>>= (_CORBA_LongDouble a, cdrStream& s);
friend inline void operator<<= (_CORBA_LongDouble& a, cdrStream& s);
#endif
#else
// Code for long double < 16 bytes is too painful to put inline
friend void operator>>= (_CORBA_LongDouble a, cdrStream& s);
friend void operator<<= (_CORBA_LongDouble& a, cdrStream& s);
#endif
#endif
inline void marshalString(const char* s,int bounded=0) {
OMNIORB_USER_CHECK(s);
pd_ncs_c->marshalString(*this,pd_tcs_c,bounded,0,s);
}
inline char* unmarshalString(int bounded=0) {
char* s;
pd_ncs_c->unmarshalString(*this,pd_tcs_c,bounded,s);
return s;
}
_CORBA_ULong marshalRawString(const char* s);
// Marshal a raw string, with no code set conversion.
char* unmarshalRawString();
// Unmarshal a raw string.
inline void marshalWString(const _CORBA_WChar* s,int bounded=0) {
OMNIORB_USER_CHECK(s);
pd_ncs_w->marshalWString(*this,pd_tcs_w,bounded,
_CORBA_WString_helper::len(s),s);
}
inline _CORBA_WChar* unmarshalWString(int bounded=0) {
_CORBA_WChar* s;
pd_ncs_w->unmarshalWString(*this,pd_tcs_w,bounded,s);
return s;
}
virtual void put_octet_array(const _CORBA_Octet* b, int size,
omni::alignment_t align=omni::ALIGN_1) = 0;
// <size> must be a multiple of <align>.
// For instance, if <align> == omni::ALIGN_8 then <size> % 8 == 0.
void put_small_octet_array(const _CORBA_Octet* b, int size);
// Put a small octet array which must have ALIGN_1. Since it is
// small, we expect it to fit in the stream's current buffer without
// having to allocate more space.
virtual void get_octet_array(_CORBA_Octet* b, int size,
omni::alignment_t align=omni::ALIGN_1) = 0;
// Get array of octets.
virtual void skipInput(_CORBA_ULong size) = 0;
// Skip <size> bytes from the input stream.
virtual _CORBA_Boolean checkInputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1) = 0;
// Return true if the input stream contains data for at least
// <nitems> of size <itemSize>. The initial alignment of the data
// starts at <align>. Return false otherwise.
virtual _CORBA_ULong currentInputPtr() const = 0;
// Return a value that represents the position of the next byte in
// the input stream. Later bytes in the stream has a higher return
// value. The absolute value of the return value has no meaning.
// The only use of this function is to compute the distance between
// two bytes in the stream.
virtual _CORBA_ULong currentOutputPtr() const = 0;
// Return a value that represents the position of the next byte in
// the output stream. Later bytes in the stream have a higher return
// value. The absolute value of the return value has no meaning.
// The only use of this function is to compute the distance between
// two bytes in the stream.
virtual _CORBA_Boolean checkOutputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1) = 0;
// Return true if data of at least <nitems> of size <itemSize> can
// be inserted to the output stream. The initial alignment of the
// data starts at <align>. Return false otherwise.
virtual void copy_to(cdrStream&,int size,
omni::alignment_t align=omni::ALIGN_1);
// From this stream, copy <size> bytes to the argument stream.
// The initial alignment starts at <align>.
// Derived classes may provided more efficent implementation than the
// default.
inline
void alignInput(omni::alignment_t align)
// Align the buffer of the input stream to <align>.
{
again:
omni::ptr_arith_t p1 = omni::align_to((omni::ptr_arith_t)pd_inb_mkr,
align);
if ((void*)p1 > pd_inb_end) {
fetchInputData(align,0);
goto again;
}
pd_inb_mkr = (void*)p1;
}
inline
void alignOutput(omni::alignment_t align)
// Align the buffer of the output stream to <align>.
{
again:
omni::ptr_arith_t p1 = omni::align_to((omni::ptr_arith_t)pd_outb_mkr,
align);
if ((void*)p1 > pd_outb_end) {
if (reserveOutputSpaceForPrimitiveType(align,0))
goto again;
}
pd_outb_mkr = (void*)p1;
}
inline
_CORBA_Boolean unmarshal_byte_swap() const { return pd_unmarshal_byte_swap; }
// Return TRUE(1) if unmarshalled data have to be byte-swapped.
inline
_CORBA_Boolean marshal_byte_swap() const { return pd_marshal_byte_swap; }
inline
void* PR_get_outb_mkr() { return pd_outb_mkr; }
// internal function used by cdrStream implementations
protected:
_CORBA_Boolean pd_unmarshal_byte_swap;
// TRUE(1) if unmarshalled data have to be byte-swapped.
_CORBA_Boolean pd_marshal_byte_swap;
// TRUE(1) if marshalled data have to be byte-swapped. I.e. data are not
// going into the stream with the host endian.
// Input buffer pointers, the region (*p) containing valid data
// is pd_inb_mkr <= p < pd_inb_end.
// pd_inb_end and pd_inb_mkr are initialised by fetchInputData().
// pd_inb_mkr is also updated by the unmarshalling operators between
// calls to fetchInputData().
void* pd_inb_end;
void* pd_inb_mkr;
virtual void fetchInputData(omni::alignment_t align,
size_t required) = 0;
// Fetch at least <required> bytes into the input buffer.
// <required> must be no more than 8 bytes && align == required!!
// The data block should start at alignment <align>.
// If the space available is less than specified, raise a
// MARSHAL system exception.
// Output buffer pointers, the region (*p) that can be written
// into is pd_outb_mkr <= p < pd_outb_end.
// pd_outb_end and pd_outb_mkr are initialised by reserveOutputSpace().
// pd_outb_mkr is also updated by the marshalling operators between
// calls to reserveOutputSpace().
void* pd_outb_end;
void* pd_outb_mkr;
virtual
_CORBA_Boolean reserveOutputSpaceForPrimitiveType(omni::alignment_t align,
size_t required) = 0;
// Allocate at least <required> bytes in the output buffer.
// The data block should start at alignment <align>.
// <required> must be no more than 8 bytes && align == required!!
// Returns TRUE(1) if at least <required> bytes with the starting
// alignment as specified has been allocated.
// Returns FALSE(0) if the required space cannot be allocated.
// When the return value is FALSE, the cdrStream would skip writing
// the current argument quietly.
// If the derived class do not want the cdrStream to skip writing
// quietly, it should raise a MARSHAL system exception instead of
// returning FALSE.
virtual _CORBA_Boolean maybeReserveOutputSpace(omni::alignment_t align,
size_t required) = 0;
// Same as reserveOutputSpaceForPrimitiveType, except the following:
// 1. The required size can be any size.
// 2. The implementation of this function can throw CORBA::BAD_PARAM
// if the nature of the stream makes it impossible to fullfil this
// request. The caller should fall back to use put_octet_array or
// other means instead.
_OMNI_NS(omniCodeSet::TCS_C)* pd_tcs_c;
// Transmission code set convertor for char and string
_OMNI_NS(omniCodeSet::TCS_W)* pd_tcs_w;
// Transmission code set convertor for wchar and wstring
_OMNI_NS(omniCodeSet::NCS_C)* pd_ncs_c;
_OMNI_NS(omniCodeSet::NCS_W)* pd_ncs_w;
_OMNI_NS(ValueIndirectionTracker)* pd_valueTracker;
// Object used to track offsets of indirections in valuetypes.
public:
// Access functions to the char and wchar code set convertors
inline _OMNI_NS(omniCodeSet::TCS_C)* TCS_C() const { return pd_tcs_c; }
inline void TCS_C(_OMNI_NS(omniCodeSet::TCS_C)* c) { pd_tcs_c = c; }
inline _OMNI_NS(omniCodeSet::TCS_W)* TCS_W() const { return pd_tcs_w; }
inline void TCS_W(_OMNI_NS(omniCodeSet::TCS_W)* c) { pd_tcs_w = c; }
// Access functions to the value indirection tracker
inline _OMNI_NS(ValueIndirectionTracker)* valueTracker() const {
return pd_valueTracker;
}
inline void valueTracker(_OMNI_NS(ValueIndirectionTracker)* v) {
pd_valueTracker = v;
}
inline void clearValueTracker() {
if (pd_valueTracker) {
delete pd_valueTracker;
pd_valueTracker = 0;
}
}
virtual void declareArrayLength(omni::alignment_t align, size_t size);
inline void
unmarshalArrayChar(_CORBA_Short* a, int length)
{
for( int i = 0; i < length; i++ )
a[i] = unmarshalChar();
}
inline void
unmarshalArrayBoolean(_CORBA_Boolean* a, int length)
{
#if !defined(HAS_Cplusplus_Bool) || (SIZEOF_BOOL == 1)
get_octet_array((_CORBA_Char*)a, length, omni::ALIGN_1);
#else
for( int i = 0; i < length; i++ )
a[i] = unmarshalBoolean();
#endif
}
inline void
unmarshalArrayShort(_CORBA_Short* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 2, omni::ALIGN_2);
if( unmarshal_byte_swap() )
for( int i = 0; i < length; i++ )
a[i] = Swap16(a[i]);
}
inline void
unmarshalArrayUShort(_CORBA_UShort* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 2, omni::ALIGN_2);
if( unmarshal_byte_swap() )
for( int i = 0; i < length; i++ )
a[i] = Swap16(a[i]);
}
inline void
unmarshalArrayLong(_CORBA_Long* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 4, omni::ALIGN_4);
if( unmarshal_byte_swap() )
for( int i = 0; i < length; i++ )
a[i] = Swap32(a[i]);
}
inline void
unmarshalArrayULong(_CORBA_ULong* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 4, omni::ALIGN_4);
if( unmarshal_byte_swap() )
for( int i = 0; i < length; i++ )
a[i] = Swap32(a[i]);
}
#ifdef HAS_LongLong
inline void
unmarshalArrayLongLong(_CORBA_LongLong* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 8, omni::ALIGN_8);
if( unmarshal_byte_swap() )
for( int i = 0; i < length; i++ )
a[i] = Swap64(a[i]);
}
inline void
unmarshalArrayULongLong(_CORBA_ULongLong* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 8, omni::ALIGN_8);
if( unmarshal_byte_swap() )
for( int i = 0; i < length; i++ )
a[i] = Swap64(a[i]);
}
#endif
#if !defined(NO_FLOAT)
inline void
unmarshalArrayFloat(_CORBA_Float* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 4, omni::ALIGN_4);
if( unmarshal_byte_swap() ) {
_CORBA_ULong* p=(_CORBA_ULong*)a;
for( int i = 0; i < length; i++ ) {
p[i] = Swap32(p[i]);
}
}
}
inline void
unmarshalArrayDouble(_CORBA_Double* a, int length)
{
get_octet_array((_CORBA_Char*) a, length * 8, omni::ALIGN_8);
if( unmarshal_byte_swap() ) {
struct LongArray2 {
_CORBA_ULong l[2];
};
LongArray2* p=(LongArray2*)a;
for( int i = 0; i < length; i++ ) {
LongArray2 l;
l.l[0] = Swap32(p[i].l[1]);
l.l[1] = Swap32(p[i].l[0]);
p[i] = l;
}
}
#ifdef OMNI_MIXED_ENDIAN_DOUBLE
{
struct LongArray2 {
_CORBA_ULong l[2];
};
LongArray2* p=(LongArray2*)a;
for( int i = 0; i < length; i++ ) {
_CORBA_ULong v = p[i].l[0];
p[i].l[0] = p[i].l[1];
p[i].l[1] = v;
}
}
#endif
}
#endif
public:
/////////////////////////////////////////////////////////////////////
virtual _CORBA_ULong completion();
// If an error occurs when a value is marshalled or unmarshalled, a
// system exception will be raised. The "completed" member of the
// exception must be taken from the return value of this function.
// Note: the return value is really of type CORBA::CompletionStatus.
// Since this declaration must appear before the CORBA declaration,
// we have to live with returning a _CORBA_ULong.
/////////////////////////////////////////////////////////////////////
virtual void* ptrToClass(int* cptr);
// Yet another dynamic casting mechanism to cope with compilers
// without dynamic_cast<>. Each class derived from cdrStream has a
// static int declared in it. The address of this int is used to
// compare the required class with the target object. Apart from the
// use of the integer pointer, it works just like _ptrToInterface
// and _ptrToObjRef in omniObjRef etc.
static inline cdrStream* downcast(cdrStream* s) {
return (cdrStream*)s->ptrToClass(&_classid);
}
// Not really necessary in the base class, but here for consistency.
static _core_attr int _classid;
private:
cdrStream(const cdrStream&);
cdrStream& operator=(const cdrStream&);
friend class cdrStreamAdapter;
friend class cdrValueChunkStream;
// cdrStreamAdapter and cdrValueChunkStream need to access protected
// pointers and virtual functions.
};
#ifdef OMNI_NO_INLINE_FRIENDS
inline void operator>>= (_CORBA_Short a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_Short t = Swap16(a);
a = t;
}
CdrMarshal(s,_CORBA_Short,omni::ALIGN_2,a);
}
inline void operator<<= (_CORBA_Short& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_Short,omni::ALIGN_2,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_Short t = Swap16(a);
a = t;
}
}
inline void operator>>= (_CORBA_UShort a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_UShort t = Swap16(a);
a = t;
}
CdrMarshal(s,_CORBA_UShort,omni::ALIGN_2,a);
}
inline void operator<<= (_CORBA_UShort& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_UShort,omni::ALIGN_2,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_UShort t = Swap16(a);
a = t;
}
}
inline void operator>>= (_CORBA_Long a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_Long t = Swap32(a);
a = t;
}
CdrMarshal(s,_CORBA_Long,omni::ALIGN_4,a);
}
inline void operator<<= (_CORBA_Long& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_Long,omni::ALIGN_4,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_Long t = Swap32(a);
a = t;
}
}
inline void operator>>= (_CORBA_ULong a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_ULong t = Swap32(a);
a = t;
}
CdrMarshal(s,_CORBA_ULong,omni::ALIGN_4,a);
}
inline void operator<<= (_CORBA_ULong& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_ULong,omni::ALIGN_4,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_ULong t = Swap32(a);
a = t;
}
}
#ifdef HAS_LongLong
inline void operator>>= (_CORBA_LongLong a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_LongLong t = Swap64(a);
a = t;
}
CdrMarshal(s,_CORBA_LongLong,omni::ALIGN_8,a);
}
inline void operator<<= (_CORBA_LongLong& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_LongLong,omni::ALIGN_8,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_LongLong t = Swap64(a);
a = t;
}
}
inline void operator>>= (_CORBA_ULongLong a, cdrStream& s) {
if (s.pd_marshal_byte_swap) {
_CORBA_ULongLong t = Swap64(a);
a = t;
}
CdrMarshal(s,_CORBA_ULongLong,omni::ALIGN_8,a);
}
inline void operator<<= (_CORBA_ULongLong& a, cdrStream& s) {
CdrUnMarshal(s,_CORBA_ULongLong,omni::ALIGN_8,a);
if (s.pd_unmarshal_byte_swap) {
_CORBA_ULongLong t = Swap64(a);
a = t;
}
}
#endif
#if !defined(NO_FLOAT)
inline void operator>>= (_CORBA_Float a, cdrStream& s) {
convertFromFloat(_CORBA_Float, _CORBA_ULong);
if (s.pd_marshal_byte_swap) {
l = Swap32(l);
}
CdrMarshal(s,_CORBA_ULong,omni::ALIGN_4,l);
}
inline void operator<<= (_CORBA_Float& a, cdrStream& s) {
_CORBA_ULong l;
CdrUnMarshal(s,_CORBA_ULong,omni::ALIGN_4,l);
if (s.pd_unmarshal_byte_swap) {
l = Swap32(l);
}
convertToFloat(_CORBA_Float, _CORBA_ULong);
}
inline void operator>>= (_CORBA_Double a, cdrStream& s) {
struct LongArray2 { _CORBA_ULong l[2]; };
convertFromFloat(_CORBA_Double, LongArray2);
if (s.pd_marshal_byte_swap) {
LongArray2 m;
m.l[0] = Swap32(l.l[1]);
m.l[1] = Swap32(l.l[0]);
l = m;
}
#ifdef OMNI_MIXED_ENDIAN_DOUBLE
{
_CORBA_ULong v = l.l[0];
l.l[0] = l.l[1];
l.l[1] = v;
}
#endif
CdrMarshal(s,LongArray2,omni::ALIGN_8,l);
}
inline void operator<<= (_CORBA_Double& a, cdrStream& s) {
struct LongArray2 { _CORBA_ULong l[2]; } l;
CdrUnMarshal(s,LongArray2,omni::ALIGN_8,l);
if (s.pd_unmarshal_byte_swap) {
LongArray2 m;
m.l[0] = Swap32(l.l[1]);
m.l[1] = Swap32(l.l[0]);
l = m;
}
#ifdef OMNI_MIXED_ENDIAN_DOUBLE
{
_CORBA_ULong v = l.l[0];
l.l[0] = l.l[1];
l.l[1] = v;
}
#endif
convertToFloat(_CORBA_Double, LongArray2);
}
#endif
#ifdef HAS_LongDouble
#if SIZEOF_LONG_DOUBLE == 16
inline void operator>>= (_CORBA_LongDouble a, cdrStream& s) {
struct LongArray4 { _CORBA_ULong l[4]; };
convertFromFloat(_CORBA_LongDouble, LongArray4);
if (s.pd_marshal_byte_swap) {
LongArray4 m;
m.l[0] = Swap32(l.l[3]);
m.l[1] = Swap32(l.l[2]);
m.l[2] = Swap32(l.l[1]);
m.l[3] = Swap32(l.l[0]);
l = m;
}
CdrMarshal(s,LongArray4,omni::ALIGN_8,l);
}
inline void operator<<= (_CORBA_LongDouble& a, cdrStream& s) {
struct LongArray4 { _CORBA_ULong l[4]; } l;
CdrUnMarshal(s,LongArray4,omni::ALIGN_8,l);
if (s.pd_unmarshal_byte_swap) {
LongArray4 m;
m.l[0] = Swap32(l.l[3]);
m.l[1] = Swap32(l.l[2]);
m.l[2] = Swap32(l.l[1]);
m.l[3] = Swap32(l.l[0]);
l = m;
}
convertToFloat(_CORBA_LongDouble, LongArray4);
}
#endif
#endif
#endif
class cdrMemoryStream : public cdrStream {
public:
cdrMemoryStream(_CORBA_ULong initialBufsize = 0,
_CORBA_Boolean clearMemory = 0);
virtual ~cdrMemoryStream();
void rewindInputPtr();
// Rewind the input pointer to the beginning of the buffer
void rewindPtrs();
// Rewind the both input and output pointers to the beginning of the buffer
// bufSize() returns 0 after this call.
_CORBA_ULong bufSize() const;
// Returns the size of the buffer containing valid data.
void* bufPtr() const;
// Returns a pointer to the beginning of the buffer.
void setByteSwapFlag(_CORBA_Boolean littleendian);
// Data in the buffer is little-endian (<littleendian> = TRUE(1)) or
// big-endian (<littleendian> = FALSE(0)). Setup the cdrStream
// accordingly.
inline _CORBA_Boolean readOnly() { return pd_readonly_and_external_buffer; }
// Return true if the stream is read-only -- i.e. it is using an
// external buffer.
cdrMemoryStream(const cdrMemoryStream&, _CORBA_Boolean read_only = 0);
// Copy a stream. If the source stream is read-only, or <read_only>
// is true, the new stream uses the same underlying memory buffer as
// the source, and assumes the buffer stays valid for the lifetime
// of the new stream.
cdrMemoryStream& operator=(const cdrMemoryStream&);
cdrMemoryStream(void* databuffer);
cdrMemoryStream(void* databuffer, size_t maxLen);
// Constructors for a read-only buffered stream.
virtual void* ptrToClass(int* cptr);
static inline cdrMemoryStream* downcast(cdrStream* s) {
return (cdrMemoryStream*)s->ptrToClass(&_classid);
}
static _core_attr int _classid;
protected:
_CORBA_Boolean pd_readonly_and_external_buffer;
_CORBA_Boolean pd_clear_memory;
void* pd_bufp;
void* pd_bufp_8;
char pd_inline_buffer[32];
public:
// The following implement the abstract functions defined in cdrStream
void put_octet_array(const _CORBA_Octet* b, int size,
omni::alignment_t align=omni::ALIGN_1);
void get_octet_array(_CORBA_Octet* b,int size,
omni::alignment_t align=omni::ALIGN_1);
void skipInput(_CORBA_ULong size);
_CORBA_Boolean checkInputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1);
_CORBA_Boolean checkOutputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1);
void copy_to(cdrStream&,int size,
omni::alignment_t align=omni::ALIGN_1);
void fetchInputData(omni::alignment_t,size_t);
_CORBA_Boolean reserveOutputSpaceForPrimitiveType(omni::alignment_t,size_t);
_CORBA_Boolean maybeReserveOutputSpace(omni::alignment_t,size_t);
_CORBA_ULong currentInputPtr() const;
_CORBA_ULong currentOutputPtr() const;
private:
_CORBA_Boolean reserveOutputSpace(omni::alignment_t,size_t);
};
class cdrEncapsulationStream : public cdrMemoryStream {
public:
cdrEncapsulationStream(_CORBA_ULong initialBufsize = 0,
_CORBA_Boolean clearMemory = 0);
cdrEncapsulationStream(const _CORBA_Octet* databuffer,
_CORBA_ULong bufsize,
_CORBA_Boolean allowAlign4 = 0);
cdrEncapsulationStream(cdrStream& s,_CORBA_ULong fetchsize);
// copy from <s> <fetchsize> bytes of data.
void getOctetStream(_CORBA_Octet*& databuffer, _CORBA_ULong& max,
_CORBA_ULong& len);
virtual void* ptrToClass(int* cptr);
static inline cdrEncapsulationStream* downcast(cdrStream* s) {
return (cdrEncapsulationStream*)s->ptrToClass(&_classid);
}
static _core_attr int _classid;
};
class cdrCountingStream : public cdrStream {
public:
cdrCountingStream(_OMNI_NS(omniCodeSet::TCS_C)* tcs_c,
_OMNI_NS(omniCodeSet::TCS_W)* tcs_w,
size_t initialoffset = 0) :
pd_total(initialoffset) {
pd_tcs_c = tcs_c;
pd_tcs_w = tcs_w;
}
virtual ~cdrCountingStream() {}
size_t total() { return pd_total; }
// The following implements the abstract functions defined in cdrStream
void put_octet_array(const _CORBA_Octet* b, int size,
omni::alignment_t align=omni::ALIGN_1);
_CORBA_Boolean reserveOutputSpaceForPrimitiveType(omni::alignment_t align,
size_t required);
_CORBA_Boolean maybeReserveOutputSpace(omni::alignment_t align,
size_t required);
_CORBA_Boolean checkOutputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1);
void copy_to(cdrStream&,int size,
omni::alignment_t align=omni::ALIGN_1);
void get_octet_array(_CORBA_Octet* b,int size,
omni::alignment_t align=omni::ALIGN_1);
void skipInput(_CORBA_ULong);
_CORBA_Boolean checkInputOverrun(_CORBA_ULong,_CORBA_ULong,
omni::alignment_t align=omni::ALIGN_1);
void fetchInputData(omni::alignment_t,size_t);
_CORBA_ULong currentInputPtr() const;
_CORBA_ULong currentOutputPtr() const;
virtual void* ptrToClass(int* cptr);
static inline cdrCountingStream* downcast(cdrStream* s) {
return (cdrCountingStream*)s->ptrToClass(&_classid);
}
static _core_attr int _classid;
private:
size_t pd_total;
cdrCountingStream(const cdrCountingStream&);
cdrCountingStream& operator=(const cdrCountingStream&);
};
// In some circumstances, for example in omniORBpy, it is necessary to
// perform some extra work around operations which manage a
// cdrStream's buffers. cdrStreamAdapter provides a wrapper around a
// cdrStream object. A class derived from cdrStreamAdapter may do
// anything it likes in its implementations of the cdrStream virtual
// functions, as long as it also calls the cdrStreamAdapter versions.
class cdrStreamAdapter : public cdrStream {
protected:
cdrStreamAdapter(cdrStream& stream) :
pd_actual(stream)
{
pd_unmarshal_byte_swap = pd_actual.pd_unmarshal_byte_swap;
pd_marshal_byte_swap = pd_actual.pd_marshal_byte_swap;
pd_tcs_c = pd_actual.pd_tcs_c;
pd_tcs_w = pd_actual.pd_tcs_w;
copyStateFromActual();
}
virtual ~cdrStreamAdapter()
{
copyStateToActual();
pd_valueTracker = 0;
}
// Implementations of abstract functions...
void put_octet_array(const _CORBA_Octet* b, int size,
omni::alignment_t align=omni::ALIGN_1);
void get_octet_array(_CORBA_Octet* b,int size,
omni::alignment_t align=omni::ALIGN_1);
void skipInput(_CORBA_ULong size);
_CORBA_Boolean checkInputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1);
_CORBA_Boolean checkOutputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1);
void copy_to(cdrStream&, int size, omni::alignment_t align=omni::ALIGN_1);
void fetchInputData(omni::alignment_t align,size_t required);
_CORBA_Boolean reserveOutputSpaceForPrimitiveType(omni::alignment_t align,
size_t required);
_CORBA_Boolean maybeReserveOutputSpace(omni::alignment_t align,
size_t required);
_CORBA_ULong currentInputPtr() const;
_CORBA_ULong currentOutputPtr() const;
_CORBA_ULong completion();
public:
inline void copyStateFromActual()
{
pd_inb_end = pd_actual.pd_inb_end;
pd_inb_mkr = pd_actual.pd_inb_mkr;
pd_outb_end = pd_actual.pd_outb_end;
pd_outb_mkr = pd_actual.pd_outb_mkr;
pd_valueTracker = pd_actual.pd_valueTracker;
}
inline void copyStateToActual() const
{
pd_actual.pd_inb_end = pd_inb_end;
pd_actual.pd_inb_mkr = pd_inb_mkr;
pd_actual.pd_outb_end = pd_outb_end;
pd_actual.pd_outb_mkr = pd_outb_mkr;
pd_actual.pd_valueTracker = pd_valueTracker;
}
virtual void* ptrToClass(int* cptr);
static inline cdrStreamAdapter* downcast(cdrStream* s) {
return (cdrStreamAdapter*)s->ptrToClass(&_classid);
}
static _core_attr int _classid;
private:
cdrStream& pd_actual;
};
// cdrValueChunkStream is similar to cdrStreamAdapter. It implements
// chunked encoding of valuetypes by wrapping an existing stream.
//
// Use for reading and writing is slightly asymmetric: for writing,
// the stream wrapper must be created before marshalling the value tag
// indicating chunked encoding; for reading, the wrapper is created
// after unmarshalling the outer-most value tag (since it is not until
// then that the reader knows chunking is is use).
class cdrValueChunkStream : public cdrStream {
public:
cdrValueChunkStream(cdrStream& stream) :
pd_actual(stream), pd_nestLevel(0), pd_lengthPtr(0),
pd_remaining(0), pd_inHeader(0), pd_inChunk(0), pd_justEnded(0),
pd_reader(0), pd_exception(0)
{
pd_unmarshal_byte_swap = pd_actual.pd_unmarshal_byte_swap;
pd_marshal_byte_swap = pd_actual.pd_marshal_byte_swap;
pd_tcs_c = pd_actual.pd_tcs_c;
pd_tcs_w = pd_actual.pd_tcs_w;
copyStateFromActual();
}
virtual ~cdrValueChunkStream();
void startOutputValueHeader(_CORBA_Long valueTag);
// Start a new value with the given value tag. The value tag must
// specify chunking. Must be called at least once before using the
// stream for writing.
void startOutputValueBody();
// End the value header and start a chunk for the value body.
void endOutputValue();
// End the current value, decrementing the nesting level.
void initialiseInput();
// Initialise stream as an input stream.
void startInputValueBody();
// Start reading the value body.
inline _CORBA_Long nestLevel() {
return pd_nestLevel;
}
inline void exceptionOccurred()
{
pd_exception = 1;
}
_CORBA_Boolean skipToNestedValue(_CORBA_Long level);
// Function used by truncation. Skip the remaining octets in the
// value at the specified nesting level. If a nested value is
// encountered, return true; if the end of the value is reached,
// return false.
//
// We need this because we might truncate a value containing a
// member that is a value we know about. Later on, an indirection
// might point to that member.
// Implementations of abstract functions...
void put_octet_array(const _CORBA_Octet* b, int size,
omni::alignment_t align=omni::ALIGN_1);
void get_octet_array(_CORBA_Octet* b,int size,
omni::alignment_t align=omni::ALIGN_1);
void skipInput(_CORBA_ULong size);
_CORBA_Boolean checkInputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1);
_CORBA_Boolean checkOutputOverrun(_CORBA_ULong itemSize,
_CORBA_ULong nItems,
omni::alignment_t align=omni::ALIGN_1);
void fetchInputData(omni::alignment_t align,size_t required);
_CORBA_Boolean reserveOutputSpaceForPrimitiveType(omni::alignment_t align,
size_t required);
_CORBA_Boolean maybeReserveOutputSpace(omni::alignment_t align,
size_t required);
_CORBA_ULong currentInputPtr() const;
_CORBA_ULong currentOutputPtr() const;
_CORBA_ULong completion();
virtual void declareArrayLength(omni::alignment_t align, size_t size);
inline void copyStateFromActual()
{
pd_inb_end = pd_actual.pd_inb_end;
pd_inb_mkr = pd_actual.pd_inb_mkr;
pd_outb_end = pd_actual.pd_outb_end;
pd_outb_mkr = pd_actual.pd_outb_mkr;
pd_valueTracker = pd_actual.pd_valueTracker;
}
inline void copyStateToActual() const
{
pd_actual.pd_inb_mkr = pd_inb_mkr;
pd_actual.pd_outb_mkr = pd_outb_mkr;
pd_actual.pd_valueTracker = pd_valueTracker;
}
static _core_attr int _classid;
virtual void* ptrToClass(int* cptr);
static inline cdrValueChunkStream* downcast(cdrStream* s) {
return (cdrValueChunkStream*)s->ptrToClass(&_classid);
}
private:
void startOutputChunk();
void endOutputChunk();
void maybeStartNewChunk(omni::alignment_t align, size_t size);
// Start a new chunk by doing the equivalent of endOutputChunk,
// startOutputChunk, unless ending the chunk now would cause us to
// output a zero length chunk. In that case, we use
// declareArrayLength to reserve space in the chunk for an element
// of the specified size.
void startInputChunk();
void endInputValue();
_CORBA_Long peekChunkTag();
// Retrieve a chunk tag from the stream without moving the pointers along.
inline void setLength(_CORBA_ULong len)
{
*pd_lengthPtr = pd_marshal_byte_swap ? Swap32(len) : len;
}
inline _CORBA_ULong getLength()
{
return pd_unmarshal_byte_swap ? Swap32(*pd_lengthPtr) : *pd_lengthPtr;
}
cdrStream& pd_actual; // Stream being wrapped
_CORBA_Long pd_nestLevel; // The nesting level of chunks
_CORBA_Long* pd_lengthPtr; // Pointer to the chunk length field
_CORBA_ULong pd_remaining; // !=0 => octets remaining in chunk
_CORBA_Boolean pd_inHeader; // True if we're inside a value header
_CORBA_Boolean pd_inChunk; // True if we're inside a chunk
_CORBA_Boolean pd_justEnded; // True if we've just ended a value
_CORBA_Boolean pd_reader; // True if we're a reader not a writer
_CORBA_Boolean pd_exception; // Set true if an exception occurs, to
// prevent further exceptions during
// clean-up.
};
#undef CdrMarshal
#undef CdrUnMarshal
#undef convertFromFloat
#undef convertToFloat
#undef Swap16
#undef Swap32
#undef Swap64
#endif /* __CDRSTREAM_H__ */
|