1 #ifndef TAO_BOUNDED_SEQUENCE_CDR_T_H
2 #define TAO_BOUNDED_SEQUENCE_CDR_T_H
6 * @brief Extract the sequence
8 * @author Carlos O'Ryan
9 * @author Johnny Willemsen
12 #include "tao/orbconf.h"
13 #include "tao/SystemException.h"
14 #include "tao/Basic_Types_IDLv4.h"
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
19 template <typename stream
, CORBA::ULong MAX
>
20 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::Short
, MAX
> & target
) {
21 typedef TAO::bounded_value_sequence
<CORBA::Short
, MAX
> sequence
;
22 ::CORBA::ULong new_length
= 0;
23 if (!(strm
>> new_length
)) {
26 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
30 tmp
.length(new_length
);
31 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
32 if (!strm
.read_short_array (buffer
, new_length
)) {
39 template <typename stream
, CORBA::ULong MAX
>
40 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::Long
, MAX
> & target
) {
41 typedef TAO::bounded_value_sequence
<CORBA::Long
, MAX
> sequence
;
42 ::CORBA::ULong new_length
= 0;
43 if (!(strm
>> new_length
)) {
46 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
50 tmp
.length(new_length
);
51 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
52 if (!strm
.read_long_array (buffer
, new_length
)) {
59 template <typename stream
, CORBA::ULong MAX
>
60 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::ULong
, MAX
> & target
) {
61 typedef TAO::bounded_value_sequence
<CORBA::ULong
, MAX
> sequence
;
62 ::CORBA::ULong new_length
= 0;
63 if (!(strm
>> new_length
)) {
66 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
70 tmp
.length(new_length
);
71 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
72 if (!strm
.read_ulong_array (buffer
, new_length
)) {
79 template <typename stream
, CORBA::ULong MAX
>
80 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::UShort
, MAX
> & target
) {
81 typedef TAO::bounded_value_sequence
<CORBA::UShort
, MAX
> sequence
;
82 ::CORBA::ULong new_length
= 0;
83 if (!(strm
>> new_length
)) {
86 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
90 tmp
.length(new_length
);
91 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
92 if (!strm
.read_ushort_array (buffer
, new_length
)) {
99 template <typename stream
, CORBA::ULong MAX
>
100 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::Octet
, MAX
> & target
) {
101 typedef TAO::bounded_value_sequence
<CORBA::Octet
, MAX
> sequence
;
102 ::CORBA::ULong new_length
= 0;
103 if (!(strm
>> new_length
)) {
106 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
110 tmp
.length(new_length
);
111 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
112 if (!strm
.read_octet_array (buffer
, new_length
)) {
119 template <typename stream
, CORBA::ULong MAX
>
120 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::Char
, MAX
> & target
) {
121 typedef TAO::bounded_value_sequence
<CORBA::Char
, MAX
> sequence
;
122 ::CORBA::ULong new_length
= 0;
123 if (!(strm
>> new_length
)) {
126 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
130 tmp
.length(new_length
);
131 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
132 if (!strm
.read_char_array (buffer
, new_length
)) {
139 # if (defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)) && !defined (ACE_LACKS_NATIVE_WCHAR_T)
140 template <typename stream
, CORBA::ULong MAX
>
141 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::WChar
, MAX
> & target
) {
142 typedef TAO::bounded_value_sequence
<CORBA::WChar
, MAX
> sequence
;
143 ::CORBA::ULong new_length
= 0;
144 if (!(strm
>> new_length
)) {
147 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
151 tmp
.length(new_length
);
152 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
153 if (!strm
.read_wchar_array (buffer
, new_length
)) {
161 template <typename stream
, CORBA::ULong MAX
>
162 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::Float
, MAX
> & target
) {
163 typedef TAO::bounded_value_sequence
<CORBA::Float
, MAX
> sequence
;
164 ::CORBA::ULong new_length
= 0;
165 if (!(strm
>> new_length
)) {
168 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
172 tmp
.length(new_length
);
173 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
174 if (!strm
.read_float_array (buffer
, new_length
)) {
181 template <typename stream
, CORBA::ULong MAX
>
182 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::Double
, MAX
> & target
) {
183 typedef TAO::bounded_value_sequence
<CORBA::Double
, MAX
> sequence
;
184 ::CORBA::ULong new_length
= 0;
185 if (!(strm
>> new_length
)) {
188 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
192 tmp
.length(new_length
);
193 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
194 if (!strm
.read_double_array (buffer
, new_length
)) {
201 template <typename stream
, CORBA::ULong MAX
>
202 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::LongLong
, MAX
> & target
) {
203 typedef TAO::bounded_value_sequence
<CORBA::LongLong
, MAX
> sequence
;
204 ::CORBA::ULong new_length
= 0;
205 if (!(strm
>> new_length
)) {
208 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
212 tmp
.length(new_length
);
213 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
214 if (!strm
.read_longlong_array (buffer
, new_length
)) {
221 template <typename stream
, CORBA::ULong MAX
>
222 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::ULongLong
, MAX
> & target
) {
223 typedef TAO::bounded_value_sequence
<CORBA::ULongLong
, MAX
> sequence
;
224 ::CORBA::ULong new_length
= 0;
225 if (!(strm
>> new_length
)) {
228 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
232 tmp
.length(new_length
);
233 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
234 if (!strm
.read_ulonglong_array (buffer
, new_length
)) {
241 template <typename stream
, CORBA::ULong MAX
>
242 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::LongDouble
, MAX
> & target
) {
243 typedef TAO::bounded_value_sequence
<CORBA::LongDouble
, MAX
> sequence
;
244 ::CORBA::ULong new_length
= 0;
245 if (!(strm
>> new_length
)) {
248 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
252 tmp
.length(new_length
);
253 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
254 if (!strm
.read_longdouble_array (buffer
, new_length
)) {
261 template <typename stream
, CORBA::ULong MAX
>
262 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<CORBA::Boolean
, MAX
> & target
) {
263 typedef TAO::bounded_value_sequence
<CORBA::Boolean
, MAX
> sequence
;
264 ::CORBA::ULong new_length
= 0;
265 if (!(strm
>> new_length
)) {
268 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
272 tmp
.length(new_length
);
273 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
274 if (!strm
.read_boolean_array (buffer
, new_length
)) {
281 template <typename stream
, CORBA::ULong MAX
>
282 bool demarshal_sequence(stream
& strm
,
283 TAO::bounded_value_sequence
<CORBA::IDLv4::UInt8
, MAX
, CORBA::IDLv4::UInt8_tag
> & target
) {
284 typedef TAO::bounded_value_sequence
<CORBA::IDLv4::UInt8
, MAX
, CORBA::IDLv4::UInt8_tag
> sequence
;
285 ::CORBA::ULong new_length
= 0;
286 if (!(strm
>> new_length
)) {
289 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
293 tmp
.length(new_length
);
294 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
295 if (!strm
.read_uint8_array (buffer
, new_length
)) {
302 template <typename stream
, CORBA::ULong MAX
>
303 bool demarshal_sequence(stream
& strm
,
304 TAO::bounded_value_sequence
<CORBA::IDLv4::Int8
, MAX
, CORBA::IDLv4::Int8_tag
> & target
) {
305 typedef TAO::bounded_value_sequence
<CORBA::IDLv4::Int8
, MAX
, CORBA::IDLv4::Int8_tag
> sequence
;
306 ::CORBA::ULong new_length
= 0;
307 if (!(strm
>> new_length
)) {
310 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
314 tmp
.length(new_length
);
315 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
316 if (!strm
.read_int8_array (buffer
, new_length
)) {
323 template <typename stream
, typename value_t
, CORBA::ULong MAX
>
324 bool demarshal_sequence(stream
& strm
, TAO::bounded_value_sequence
<value_t
, MAX
> & target
) {
325 typedef TAO::bounded_value_sequence
<value_t
, MAX
> sequence
;
326 ::CORBA::ULong new_length
= 0;
327 if (!(strm
>> new_length
)) {
330 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
334 tmp
.length(new_length
);
335 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
336 for(CORBA::ULong i
= 0; i
< new_length
; ++i
) {
337 if (!(strm
>> buffer
[i
])) {
345 template <typename stream
, typename charT
, CORBA::ULong MAX
>
346 bool demarshal_sequence(stream
& strm
, TAO::bounded_basic_string_sequence
<charT
, MAX
> & target
) {
347 typedef typename
TAO::bounded_basic_string_sequence
<charT
, MAX
> sequence
;
348 typedef typename
sequence::element_traits::string_var string_var
;
349 typedef typename
sequence::allocation_traits sequence_allocation_traits
;
350 ::CORBA::ULong new_length
= 0;
351 if (!(strm
>> new_length
)) {
354 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
357 sequence
tmp(new_length
,
358 sequence_allocation_traits::allocbuf_noinit(new_length
),
360 for(CORBA::ULong i
= 0; i
< new_length
; ++i
) {
362 if (!(strm
>> string
.inout ())) {
366 tmp
[i
] = string
._retn ();
373 template <typename stream
, typename charT
, CORBA::ULong MAX
, CORBA::ULong BD_STR_MAX
>
374 bool demarshal_sequence(stream
& strm
, TAO::bounded_bd_string_sequence
<charT
, MAX
, BD_STR_MAX
> & target
) {
375 typedef typename
TAO::bounded_bd_string_sequence
<charT
, MAX
, BD_STR_MAX
> sequence
;
376 typedef typename
sequence::element_traits::string_var string_var
;
377 typedef typename
sequence::allocation_traits sequence_allocation_traits
;
378 ::CORBA::ULong new_length
= 0;
379 if (!(strm
>> new_length
)) {
382 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
385 sequence
tmp(new_length
,
386 sequence_allocation_traits::allocbuf_noinit(new_length
),
388 for(CORBA::ULong i
= 0; i
< new_length
; ++i
) {
390 if (!(strm
>> string
.inout ())) {
394 if (string
.in () != 0 &&
395 ACE_OS::strlen (string
.in ()) > tmp
.bd_string_maximum ()) {
396 throw ::CORBA::BAD_PARAM ();
398 tmp
[i
] = string
._retn ();
405 template <typename stream
, typename object_t
, typename object_t_var
, CORBA::ULong MAX
>
406 bool demarshal_sequence(stream
& strm
, TAO::bounded_object_reference_sequence
<object_t
, object_t_var
, MAX
> & target
) {
407 typedef typename
TAO::bounded_object_reference_sequence
<object_t
, object_t_var
, MAX
> sequence
;
408 typedef typename
sequence::allocation_traits sequence_allocation_traits
;
409 ::CORBA::ULong new_length
= 0;
410 if (!(strm
>> new_length
)) {
413 if ((new_length
> strm
.length()) || (new_length
> target
.maximum ())) {
416 sequence
tmp(new_length
,
417 sequence_allocation_traits::allocbuf_noinit(new_length
),
419 typename
sequence::value_type
* buffer
= tmp
.get_buffer();
420 for(CORBA::ULong i
= 0; i
< new_length
; ++i
) {
421 if (!(strm
>> buffer
[i
])) {
429 template <typename stream
, CORBA::ULong MAX
>
430 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::Short
, MAX
> & source
) {
431 ::CORBA::ULong
const length
= source
.length ();
432 if (length
> source
.maximum () || !(strm
<< length
)) {
435 return strm
.write_short_array (source
.get_buffer (), length
);
438 template <typename stream
, CORBA::ULong MAX
>
439 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::Long
, MAX
> & source
) {
440 ::CORBA::ULong
const length
= source
.length ();
441 if (length
> source
.maximum () || !(strm
<< length
)) {
444 return strm
.write_long_array (source
.get_buffer (), length
);
447 template <typename stream
, CORBA::ULong MAX
>
448 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::ULong
, MAX
> & source
) {
449 ::CORBA::ULong
const length
= source
.length ();
450 if (length
> source
.maximum () || !(strm
<< length
)) {
453 return strm
.write_ulong_array (source
.get_buffer (), length
);
456 template <typename stream
, CORBA::ULong MAX
>
457 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::UShort
, MAX
> & source
) {
458 ::CORBA::ULong
const length
= source
.length ();
459 if (length
> source
.maximum () || !(strm
<< length
)) {
462 return strm
.write_ushort_array (source
.get_buffer (), length
);
465 template <typename stream
, CORBA::ULong MAX
>
466 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::Octet
, MAX
> & source
) {
467 ::CORBA::ULong
const length
= source
.length ();
468 if (length
> source
.maximum () || !(strm
<< length
)) {
471 return strm
.write_octet_array (source
.get_buffer (), length
);
474 template <typename stream
, CORBA::ULong MAX
>
475 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::Char
, MAX
> & source
) {
476 ::CORBA::ULong
const length
= source
.length ();
477 if (length
> source
.maximum () || !(strm
<< length
)) {
480 return strm
.write_char_array (source
.get_buffer (), length
);
483 # if (defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)) && !defined (ACE_LACKS_NATIVE_WCHAR_T)
484 template <typename stream
, CORBA::ULong MAX
>
485 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::WChar
, MAX
> & source
) {
486 ::CORBA::ULong
const length
= source
.length ();
487 if (length
> source
.maximum () || !(strm
<< length
)) {
490 return strm
.write_wchar_array (source
.get_buffer (), length
);
494 template <typename stream
, CORBA::ULong MAX
>
495 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::Float
, MAX
> & source
) {
496 ::CORBA::ULong
const length
= source
.length ();
497 if (length
> source
.maximum () || !(strm
<< length
)) {
500 return strm
.write_float_array (source
.get_buffer (), length
);
503 template <typename stream
, CORBA::ULong MAX
>
504 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::Double
, MAX
> & source
) {
505 ::CORBA::ULong
const length
= source
.length ();
506 if (length
> source
.maximum () || !(strm
<< length
)) {
509 return strm
.write_double_array (source
.get_buffer (), length
);
512 template <typename stream
, CORBA::ULong MAX
>
513 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::LongLong
, MAX
> & source
) {
514 ::CORBA::ULong
const length
= source
.length ();
515 if (length
> source
.maximum () || !(strm
<< length
)) {
518 return strm
.write_longlong_array (source
.get_buffer (), length
);
521 template <typename stream
, CORBA::ULong MAX
>
522 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::ULongLong
, MAX
> & source
) {
523 ::CORBA::ULong
const length
= source
.length ();
524 if (length
> source
.maximum () || !(strm
<< length
)) {
527 return strm
.write_ulonglong_array (source
.get_buffer (), length
);
530 template <typename stream
, CORBA::ULong MAX
>
531 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::LongDouble
, MAX
> & source
) {
532 ::CORBA::ULong
const length
= source
.length ();
533 if (length
> source
.maximum () || !(strm
<< length
)) {
536 return strm
.write_longdouble_array (source
.get_buffer (), length
);
539 template <typename stream
, CORBA::ULong MAX
>
540 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<CORBA::Boolean
, MAX
> & source
) {
541 ::CORBA::ULong
const length
= source
.length ();
542 if (length
> source
.maximum () || !(strm
<< length
)) {
545 return strm
.write_boolean_array (source
.get_buffer (), length
);
548 template <typename stream
, CORBA::ULong MAX
>
549 bool marshal_sequence(stream
& strm
,
550 const TAO::bounded_value_sequence
<CORBA::IDLv4::UInt8
, MAX
, CORBA::IDLv4::UInt8_tag
> & source
) {
551 ::CORBA::ULong
const length
= source
.length ();
552 if (length
> source
.maximum () || !(strm
<< length
)) {
555 return strm
.write_uint8_array (source
.get_buffer (), length
);
558 template <typename stream
, CORBA::ULong MAX
>
559 bool marshal_sequence(stream
& strm
,
560 const TAO::bounded_value_sequence
<CORBA::IDLv4::Int8
, MAX
, CORBA::IDLv4::Int8_tag
> & source
) {
561 ::CORBA::ULong
const length
= source
.length ();
562 if (length
> source
.maximum () || !(strm
<< length
)) {
565 return strm
.write_int8_array (source
.get_buffer (), length
);
568 template <typename stream
, typename value_t
, CORBA::ULong MAX
>
569 bool marshal_sequence(stream
& strm
, const TAO::bounded_value_sequence
<value_t
, MAX
> & source
) {
570 ::CORBA::ULong
const length
= source
.length ();
571 if (length
> source
.maximum () || !(strm
<< length
)) {
574 for(CORBA::ULong i
= 0; i
< length
; ++i
) {
575 if (!(strm
<< source
[i
])) {
582 template <typename stream
, typename charT
, CORBA::ULong MAX
>
583 bool marshal_sequence(stream
& strm
, const TAO::bounded_basic_string_sequence
<charT
, MAX
> & source
) {
584 ::CORBA::ULong
const length
= source
.length ();
585 if (length
> source
.maximum () || !(strm
<< length
)) {
588 for(CORBA::ULong i
= 0; i
< length
; ++i
) {
589 if (!(strm
<< source
[i
])) {
596 template <typename stream
, typename charT
, CORBA::ULong MAX
, CORBA::ULong BD_STR_MAX
>
597 bool marshal_sequence(stream
& strm
, const TAO::bounded_bd_string_sequence
<charT
, MAX
, BD_STR_MAX
> & source
) {
598 ::CORBA::ULong
const length
= source
.length ();
599 if (length
> source
.maximum () || !(strm
<< length
)) {
602 for(CORBA::ULong i
= 0; i
< length
; ++i
) {
603 if (source
[i
].in () != 0 &&
604 ACE_OS::strlen (source
[i
]) > source
.bd_string_maximum ()) {
605 throw ::CORBA::BAD_PARAM ();
607 if (!(strm
<< source
[i
])) {
614 template <typename stream
, typename object_t
, typename object_t_var
, CORBA::ULong MAX
>
615 bool marshal_sequence(stream
& strm
, const TAO::bounded_object_reference_sequence
<object_t
, object_t_var
, MAX
> & source
) {
616 typedef typename
TAO::bounded_object_reference_sequence
<object_t
, object_t_var
, MAX
>::object_type object_type
;
617 ::CORBA::ULong
const length
= source
.length ();
618 if (length
> source
.maximum () || !(strm
<< length
)) {
621 for(CORBA::ULong i
= 0; i
< length
; ++i
) {
622 if (!TAO::Objref_Traits
<object_type
>::marshal (source
[i
], strm
)) {
630 TAO_END_VERSIONED_NAMESPACE_DECL
632 #endif /* TAO_BOUNDED_SEQUENCE_CDR_T_H */