#ifndef guard_unbounded_sequence_cdr #define guard_unbounded_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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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; } #if (TAO_NO_COPY_OCTET_SEQUENCES == 1) template bool demarshal_sequence(stream & strm, TAO::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); tmp.length(new_length); if (ACE_BIT_DISABLED (strm.start ()->flags (), ACE_Message_Block::DONT_DELETE)) { TAO_ORB_Core* orb_core = strm.orb_core (); if (orb_core != 0 && strm.orb_core ()->resource_factory ()-> input_cdr_allocator_type_locked () == 1) { tmp.replace (new_length, strm.start ()); tmp.mb ()->wr_ptr (tmp.mb()->rd_ptr () + new_length); strm.skip_bytes (new_length); tmp.swap(target); return true; } } typename sequence::value_type * buffer = tmp.get_buffer(); if (!strm.read_octet_array (buffer, new_length)) { return false; } tmp.swap(target); return true; } #else template bool demarshal_sequence(stream & strm, TAO::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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; } #endif template bool demarshal_sequence(stream & strm, TAO::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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) template bool demarshal_sequence(stream & strm, TAO::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_value_sequence & target) { typedef TAO::unbounded_value_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::details::unbounded_basic_string_sequence & target) { typedef TAO::details::unbounded_basic_string_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_object_reference_sequence & target) { typedef TAO::unbounded_object_reference_sequence sequence; ::CORBA::ULong new_length = 0; if (!(strm >> new_length)) { return false; } if (new_length > strm.length()) { return false; } sequence tmp(new_length); 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::unbounded_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::unbounded_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::unbounded_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::unbounded_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); } #if (TAO_NO_COPY_OCTET_SEQUENCES == 1) template bool marshal_sequence(stream & strm, const TAO::unbounded_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; } if (source.mb ()) { return strm.write_octet_array_mb (source.mb ()); } return strm.write_octet_array (source.get_buffer (), length); } #else template bool marshal_sequence(stream & strm, const TAO::unbounded_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); } #endif template bool marshal_sequence(stream & strm, const TAO::unbounded_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) template bool marshal_sequence(stream & strm, const TAO::unbounded_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::unbounded_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::unbounded_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::unbounded_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::unbounded_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::unbounded_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::unbounded_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::details::unbounded_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::unbounded_object_reference_sequence & source) { typedef typename TAO::unbounded_object_reference_sequence::object_type objec_t; 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; } } TAO_END_VERSIONED_NAMESPACE_DECL #endif /* guard_unbounded_sequence_cdr */