#ifndef guard_bounded_sequence_cdr #define guard_bounded_sequence_cdr /** * @file * * @brief Extract the sequence * * $Id$ * * @author Carlos O'Ryan * @author Johnny Willemsen */ #include "tao/orbconf.h" #include "tao/SystemException.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_short_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_long_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_ulong_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_ushort_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_octet_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_char_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } # if (defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)) && !defined (ACE_LACKS_NATIVE_WCHAR_T) template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_wchar_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } #endif template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_float_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_double_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_ulonglong_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_longdouble_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_boolean_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence & target) { typedef TAO::bounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); for(CORBA::ULong i = 0; i < new_length; ++i) { if (!(strm >> buffer[i])) { return false; } } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_basic_string_sequence & target) { typedef typename TAO::bounded_basic_string_sequence sequence; typedef typename sequence::element_traits::string_var string_var; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); for(CORBA::ULong i = 0; i < new_length; ++i) { string_var string; if (!(strm >> string.inout ())) { return false; } else { tmp[i] = string._retn (); } } tmp.swap(target); return true; } template bool demarshal_sequence(stream & strm, TAO::bounded_object_reference_sequence & target) { typedef typename TAO::bounded_object_reference_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if ((new_length > strm.length()) || (new_length > target.maximum ())) { return false; } sequence tmp; tmp.length(new_length); typename sequence::value_type * buffer = tmp.get_buffer(); for(CORBA::ULong i = 0; i < new_length; ++i) { if (!(strm >> buffer[i])) { return false; } } tmp.swap(target); return true; } } namespace TAO { template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_short_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_long_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_ulong_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_ushort_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_octet_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_char_array (source.get_buffer (), length); } # if (defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR)) && !defined (ACE_LACKS_NATIVE_WCHAR_T) template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_wchar_array (source.get_buffer (), length); } #endif template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_float_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_double_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_ulonglong_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_longdouble_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } return strm.write_boolean_array (source.get_buffer (), length); } template bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } for(CORBA::ULong i = 0; i < length; ++i) { if (!(strm << source[i])) { return false; } } return true; } template bool marshal_sequence(stream & strm, const TAO::bounded_basic_string_sequence & source) { if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } for(CORBA::ULong i = 0; i < length; ++i) { if (!(strm << source[i])) { return false; } } return true; } template bool marshal_sequence(stream & strm, const TAO::bounded_object_reference_sequence & source) { typedef typename TAO::bounded_object_reference_sequence::object_type object_type; if (0 == &source) ACE_THROW_RETURN (::CORBA::BAD_PARAM(0, CORBA::COMPLETED_MAYBE), false); ::CORBA::ULong const length = source.length (); if (!(strm << length)) { return false; } for(CORBA::ULong i = 0; i < length; ++i) { if (!TAO::Objref_Traits::marshal (source[i], strm)) { return false; } } return true; } } // namespace TAO TAO_END_VERSIONED_NAMESPACE_DECL #endif /* guard_bounded_sequence_cdr */