diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-03-03 03:22:46 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-03-03 03:22:46 +0000 |
commit | 77b85e0fa339b189ce45f67b959eec620c0178e3 (patch) | |
tree | d1e7543aceb745898446fdabd85db589ce1209bc /TAO/tao/TimeBaseC.cpp | |
parent | e1ab4672cd21eddcff17e9dee5d5b58dfb7795fb (diff) | |
download | ATCD-77b85e0fa339b189ce45f67b959eec620c0178e3.tar.gz |
More replacement of Any operators.
Diffstat (limited to 'TAO/tao/TimeBaseC.cpp')
-rw-r--r-- | TAO/tao/TimeBaseC.cpp | 219 |
1 files changed, 195 insertions, 24 deletions
diff --git a/TAO/tao/TimeBaseC.cpp b/TAO/tao/TimeBaseC.cpp index ec2f84b51b3..2d0c76cb4b9 100644 --- a/TAO/tao/TimeBaseC.cpp +++ b/TAO/tao/TimeBaseC.cpp @@ -133,12 +133,21 @@ TAO_NAMESPACE_DEFINE (CORBA::TypeCode_ptr, _tc_IntervalT, &_tc_TAO_tc_TimeBase_I TAO_NAMESPACE_END void operator<<= (CORBA::Any &_tao_any, const TimeBase::UtcT &_tao_elem) // copying { - TimeBase::UtcT *_any_val; + TimeBase::UtcT *_any_val = 0; ACE_NEW (_any_val, TimeBase::UtcT (_tao_elem)); if (!_any_val) return; ACE_TRY_NEW_ENV { - _tao_any.replace (TimeBase::_tc_UtcT, _any_val, 1, ACE_TRY_ENV); // copy the value + TAO_OutputCDR stream; + stream << *_any_val; + _tao_any._tao_replace ( + TimeBase::_tc_UtcT, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _any_val, + ACE_TRY_ENV + ); ACE_TRY_CHECK; } ACE_CATCHANY @@ -152,10 +161,23 @@ void operator<<= (CORBA::Any &_tao_any, TimeBase::UtcT *_tao_elem) // non copyin { ACE_TRY_NEW_ENV { - _tao_any.replace (TimeBase::_tc_UtcT, _tao_elem, 1, ACE_TRY_ENV); // consume it + TAO_OutputCDR stream; + stream << *_tao_elem; + _tao_any._tao_replace ( + TimeBase::_tc_UtcT, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _tao_elem, + ACE_TRY_ENV + ); ACE_TRY_CHECK; } - ACE_CATCHANY {} + ACE_CATCHANY + { + delete _tao_elem; + _tao_elem = 0; + } ACE_ENDTRY; } @@ -164,35 +186,98 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, TimeBase::UtcT *&_tao_el ACE_TRY_NEW_ENV { CORBA::TypeCode_var type = _tao_any.type (); - if (!type->equal (TimeBase::_tc_UtcT, ACE_TRY_ENV)) return 0; // not equal + if (!type->equivalent (TimeBase::_tc_UtcT, ACE_TRY_ENV)) // not equal + { + _tao_elem = 0; + return 0; + } ACE_TRY_CHECK; if (_tao_any.any_owns_data ()) { _tao_elem = (TimeBase::UtcT *)_tao_any.value (); return 1; - } + } else { ACE_NEW_RETURN (_tao_elem, TimeBase::UtcT, 0); - TAO_InputCDR stream (_tao_any._tao_get_cdr (), - _tao_any._tao_byte_order ()); - if (stream.decode (TimeBase::_tc_UtcT, _tao_elem, 0, ACE_TRY_ENV) - == CORBA::TypeCode::TRAVERSE_CONTINUE) + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *_tao_elem) { - ((CORBA::Any *)&_tao_any)->replace (TimeBase::_tc_UtcT, _tao_elem, 1, ACE_TRY_ENV); + ((CORBA::Any *)&_tao_any)->_tao_replace ( + TimeBase::_tc_UtcT, + 1, + ACE_reinterpret_cast (void *, _tao_elem), + ACE_TRY_ENV + ); ACE_TRY_CHECK; return 1; } else { delete _tao_elem; + _tao_elem = 0; } } } ACE_CATCHANY { delete _tao_elem; - return 0; + _tao_elem = 0; + return 0; + } + ACE_ENDTRY; + return 0; +} + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const TimeBase::UtcT *&_tao_elem) +{ + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_var type = _tao_any.type (); + if (!type->equivalent (TimeBase::_tc_UtcT, ACE_TRY_ENV)) // not equal + { + _tao_elem = 0; + return 0; + } + ACE_TRY_CHECK; + if (_tao_any.any_owns_data ()) + { + _tao_elem = (TimeBase::UtcT *)_tao_any.value (); + return 1; + } + else + { + ACE_NEW_RETURN (_tao_elem, TimeBase::UtcT, 0); + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *(TimeBase::UtcT *)_tao_elem) + { + ((CORBA::Any *)&_tao_any)->_tao_replace ( + TimeBase::_tc_UtcT, + 1, + ACE_reinterpret_cast (void *, ACE_const_cast (TimeBase::UtcT *&, _tao_elem)), + ACE_TRY_ENV + ); + ACE_TRY_CHECK; + return 1; + } + else + { + delete ACE_const_cast (TimeBase::UtcT *&, _tao_elem); + _tao_elem = 0; + } + } + } + ACE_CATCHANY + { + delete ACE_const_cast (TimeBase::UtcT *&, _tao_elem); + _tao_elem = 0; + return 0; } ACE_ENDTRY; return 0; @@ -200,12 +285,21 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, TimeBase::UtcT *&_tao_el void operator<<= (CORBA::Any &_tao_any, const TimeBase::IntervalT &_tao_elem) // copying { - TimeBase::IntervalT *_any_val; + TimeBase::IntervalT *_any_val = 0; ACE_NEW (_any_val, TimeBase::IntervalT (_tao_elem)); if (!_any_val) return; ACE_TRY_NEW_ENV { - _tao_any.replace (TimeBase::_tc_IntervalT, _any_val, 1, ACE_TRY_ENV); // copy the value + TAO_OutputCDR stream; + stream << *_any_val; + _tao_any._tao_replace ( + TimeBase::_tc_IntervalT, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _any_val, + ACE_TRY_ENV + ); ACE_TRY_CHECK; } ACE_CATCHANY @@ -219,10 +313,23 @@ void operator<<= (CORBA::Any &_tao_any, TimeBase::IntervalT *_tao_elem) // non c { ACE_TRY_NEW_ENV { - _tao_any.replace (TimeBase::_tc_IntervalT, _tao_elem, 1, ACE_TRY_ENV); // consume it + TAO_OutputCDR stream; + stream << *_tao_elem; + _tao_any._tao_replace ( + TimeBase::_tc_IntervalT, + TAO_ENCAP_BYTE_ORDER, + stream.begin (), + 1, + _tao_elem, + ACE_TRY_ENV + ); ACE_TRY_CHECK; } - ACE_CATCHANY {} + ACE_CATCHANY + { + delete _tao_elem; + _tao_elem = 0; + } ACE_ENDTRY; } @@ -231,36 +338,100 @@ CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, TimeBase::IntervalT *&_t ACE_TRY_NEW_ENV { CORBA::TypeCode_var type = _tao_any.type (); - if (!type->equal (TimeBase::_tc_IntervalT, ACE_TRY_ENV)) return 0; // not equal + if (!type->equivalent (TimeBase::_tc_IntervalT, ACE_TRY_ENV)) // not equal + { + _tao_elem = 0; + return 0; + } ACE_TRY_CHECK; if (_tao_any.any_owns_data ()) { _tao_elem = (TimeBase::IntervalT *)_tao_any.value (); return 1; - } + } else { ACE_NEW_RETURN (_tao_elem, TimeBase::IntervalT, 0); - TAO_InputCDR stream (_tao_any._tao_get_cdr (), - _tao_any._tao_byte_order ()); - if (stream.decode (TimeBase::_tc_IntervalT, _tao_elem, 0, ACE_TRY_ENV) - == CORBA::TypeCode::TRAVERSE_CONTINUE) + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *_tao_elem) { - ((CORBA::Any *)&_tao_any)->replace (TimeBase::_tc_IntervalT, _tao_elem, 1, ACE_TRY_ENV); + ((CORBA::Any *)&_tao_any)->_tao_replace ( + TimeBase::_tc_IntervalT, + 1, + ACE_reinterpret_cast (void *, _tao_elem), + ACE_TRY_ENV + ); ACE_TRY_CHECK; return 1; } else { delete _tao_elem; + _tao_elem = 0; } } } ACE_CATCHANY { delete _tao_elem; - return 0; + _tao_elem = 0; + return 0; } ACE_ENDTRY; return 0; } + +CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, const TimeBase::IntervalT *&_tao_elem) +{ + ACE_TRY_NEW_ENV + { + CORBA::TypeCode_var type = _tao_any.type (); + if (!type->equivalent (TimeBase::_tc_IntervalT, ACE_TRY_ENV)) // not equal + { + _tao_elem = 0; + return 0; + } + ACE_TRY_CHECK; + if (_tao_any.any_owns_data ()) + { + _tao_elem = (TimeBase::IntervalT *)_tao_any.value (); + return 1; + } + else + { + ACE_NEW_RETURN (_tao_elem, TimeBase::IntervalT, 0); + TAO_InputCDR stream ( + _tao_any._tao_get_cdr (), + _tao_any._tao_byte_order () + ); + if (stream >> *(TimeBase::IntervalT *)_tao_elem) + { + ((CORBA::Any *)&_tao_any)->_tao_replace ( + TimeBase::_tc_IntervalT, + 1, + ACE_reinterpret_cast (void *, ACE_const_cast (TimeBase::IntervalT *&, _tao_elem)), + ACE_TRY_ENV + ); + ACE_TRY_CHECK; + return 1; + } + else + { + delete ACE_const_cast (TimeBase::IntervalT *&, _tao_elem); + _tao_elem = 0; + } + } + } + ACE_CATCHANY + { + delete ACE_const_cast (TimeBase::IntervalT *&, _tao_elem); + _tao_elem = 0; + return 0; + } + ACE_ENDTRY; + return 0; +} + |