本文整理汇总了C++中corba::Any::impl方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::impl方法的具体用法?C++ Any::impl怎么用?C++ Any::impl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::Any
的用法示例。
在下文中一共展示了Any::impl方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: in
void
TAO_ConstantDef_i::value_i (const CORBA::Any &value)
{
CORBA::TypeCode_var my_tc =
this->type_i ();
CORBA::TypeCode_var val_tc = value.type ();
CORBA::Boolean const equal_tc =
my_tc.in ()->equal (val_tc.in ());
if (!equal_tc)
{
return;
}
ACE_Message_Block *mb = 0;
TAO::Any_Impl *impl = value.impl ();
if (impl->encoded ())
{
TAO::Unknown_IDL_Type *unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
mb = unk->_tao_get_cdr ().steal_contents ();
}
else
{
TAO_OutputCDR out;
impl->marshal_value (out);
TAO_InputCDR in (out);
mb = in.steal_contents ();
}
ACE_Auto_Ptr<ACE_Message_Block> safe (mb);
CORBA::TCKind kind = val_tc->kind ();
switch (kind)
{
// The data for these types will be aligned to an 8-byte
// boundary, while the rd_ptr may not.
case CORBA::tk_double:
case CORBA::tk_ulonglong:
case CORBA::tk_longlong:
case CORBA::tk_longdouble:
mb->rd_ptr (ACE_ptr_align_binary (mb->rd_ptr (),
ACE_CDR::MAX_ALIGNMENT));
break;
default:
break;
}
mb->crunch ();
this->repo_->config ()->set_binary_value (this->section_key_,
"value",
mb->base (),
mb->length ());
}
示例2: return
CORBA::Boolean
operator<< (TAO_OutputCDR &cdr, const CORBA::Any &any)
{
TAO::Any_Impl *impl = any.impl ();
if (impl != 0)
{
return impl->marshal (cdr);
}
return (cdr << CORBA::_tc_null);
}
示例3: key
int
TAO_Log_Constraint_Visitor::visit_identifier (ETCL_Identifier *ident)
{
int return_value = -1;
const char *name = ident->value ();
ACE_CString key (name, 0, false);
CORBA::Any any;
if (this->property_lookup_.find (key, any) == 0)
{
if (any.impl() != 0)
{
this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (&any));
return_value = 0;
}
}
return return_value;
}
示例4: INTERNAL
void
TAO_DynEnum_i::init (const CORBA::Any &any)
{
CORBA::TypeCode_var tc = any.type ();
CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in ());
if (kind != CORBA::tk_enum)
{
throw DynamicAny::DynAnyFactory::InconsistentTypeCode ();
}
this->type_ = tc;
TAO::Any_Impl *impl = any.impl ();
if (impl->encoded ())
{
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
throw CORBA::INTERNAL ();
// We don't want unk's rd_ptr to move, in case we are shared by
// another Any, so we use this to copy the state, not the buffer.
TAO_InputCDR for_reading (unk->_tao_get_cdr ());
for_reading.read_ulong (this->value_);
}
else
{
TAO_OutputCDR out;
impl->marshal_value (out);
TAO_InputCDR in (out);
in.read_ulong (this->value_);
}
this->init_common ();
}
示例5: for_reading
CORBA::Boolean
TAO::Any_Array_Impl_T<T_slice, T_forany>::extract (const CORBA::Any & any,
_tao_destructor destructor,
CORBA::TypeCode_ptr tc,
T_slice *& _tao_elem)
{
_tao_elem = 0;
try
{
CORBA::TypeCode_ptr any_tc = any._tao_get_typecode ();
CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc);
if (_tao_equiv == false)
{
return false;
}
TAO::Any_Impl *impl = any.impl ();
if (!impl->encoded ())
{
TAO::Any_Array_Impl_T<T_slice, T_forany> *narrow_impl =
dynamic_cast <TAO::Any_Array_Impl_T <T_slice, T_forany> *> (impl);
if (narrow_impl == 0)
{
return false;
}
_tao_elem = reinterpret_cast <T_slice*> (narrow_impl->value_);
return true;
}
TAO::Any_Array_Impl_T<T_slice, T_forany> *replacement = 0;
typedef TAO::Any_Array_Impl_T<T_slice, T_forany> ARRAY_ANY_IMPL;
ACE_NEW_RETURN (replacement,
ARRAY_ANY_IMPL (destructor,
any_tc,
T_forany::tao_alloc ()),
false);
#if defined (ACE_HAS_CPP11)
std::unique_ptr<TAO::Any_Array_Impl_T<T_slice, T_forany> > replacement_safety (replacement);
#else
auto_ptr<TAO::Any_Array_Impl_T<T_slice, T_forany> > replacement_safety (replacement);
#endif /* ACE_HAS_CPP11 */
// We know this will work since the unencoded case is covered above.
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
return false;
// We don't want the rd_ptr of unk to move, in case it is
// shared by another Any. This copies the state, not the buffer.
TAO_InputCDR for_reading (unk->_tao_get_cdr ());
CORBA::Boolean const good_decode =
replacement->demarshal_value (for_reading);
if (good_decode)
{
_tao_elem = reinterpret_cast <T_slice*> (replacement->value_);
const_cast<CORBA::Any &> (any).replace (replacement);
replacement_safety.release ();
return true;
}
// Duplicated by Any_Impl base class constructor.
::CORBA::release (any_tc);
}
catch (const ::CORBA::Exception&)
{
}
return false;
}
示例6: cdr
void
TAO_DynSequence_i::from_any (const CORBA::Any & any)
{
if (this->destroyed_)
{
throw ::CORBA::OBJECT_NOT_EXIST ();
}
CORBA::TypeCode_var tc = any.type ();
CORBA::Boolean equivalent =
this->type_.in ()->equivalent (tc.in ());
if (equivalent)
{
// Get the CDR stream of the Any, if there isn't one, make one.
TAO::Any_Impl *impl = any.impl ();
TAO_OutputCDR out;
TAO_InputCDR cdr (static_cast<ACE_Message_Block *> (0));
if (impl->encoded ())
{
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
throw CORBA::INTERNAL ();
cdr = unk->_tao_get_cdr ();
}
else
{
impl->marshal_value (out);
TAO_InputCDR tmp_in (out);
cdr = tmp_in;
}
CORBA::ULong arg_length;
// If the any is a sequence, first 4 bytes of cdr hold the
// length.
cdr.read_ulong (arg_length);
// If the array grows, we must do it now.
if (arg_length > this->component_count_)
{
this->da_members_.size (arg_length);
}
CORBA::TypeCode_var field_tc =
this->get_element_type ();
for (CORBA::ULong i = 0; i < arg_length; ++i)
{
CORBA::Any field_any;
TAO_InputCDR unk_in (cdr);
TAO::Unknown_IDL_Type *field_unk = 0;
ACE_NEW (field_unk,
TAO::Unknown_IDL_Type (field_tc.in (),
unk_in));
field_any.replace (field_unk);
if (i < this->component_count_)
{
this->da_members_[i]->destroy ();
}
this->da_members_[i] =
TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any&> (
field_any._tao_get_typecode (),
field_any,
this->allow_truncation_ );
// Move to the next field in the CDR stream.
(void) TAO_Marshal_Object::perform_skip (field_tc.in (), &cdr);
}
// Destroy any dangling members.
for (CORBA::ULong j = arg_length; j < this->component_count_; ++j)
{
this->da_members_[j]->destroy ();
}
// If the array shrinks, we must wait until now to do it.
if (arg_length < this->component_count_)
{
this->da_members_.size (arg_length);
}
// Now we can update component_count_.
this->component_count_ = arg_length;
this->current_position_ = arg_length ? 0 : -1;
}
else
{
throw DynamicAny::DynAny::TypeMismatch ();
}
}
示例7: for_reading
CORBA::Boolean
Any_Basic_Impl::extract (const CORBA::Any &any,
CORBA::TypeCode_ptr tc,
void *_tao_elem)
{
try
{
CORBA::TypeCode_ptr any_tc = any._tao_get_typecode ();
CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc);
if (!_tao_equiv)
{
return false;
}
TAO::Any_Impl * const impl = any.impl ();
if (impl && !impl->encoded ())
{
TAO::Any_Basic_Impl * const narrow_impl =
dynamic_cast<TAO::Any_Basic_Impl *> (impl);
if (narrow_impl == 0)
{
return false;
}
Any_Basic_Impl::assign_value (_tao_elem, narrow_impl);
return true;
}
TAO::Any_Basic_Impl *replacement =
TAO::Any_Basic_Impl::create_empty (any_tc);
auto_ptr<TAO::Any_Basic_Impl> replacement_safety (replacement);
// We know this will work since the unencoded case is covered above.
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
return false;
// Get the kind of the type where we are extracting in ie. the
// aliased type if there are any. Passing the aliased kind
// will not help.
CORBA::TCKind const tck = tc->kind ();
// We don't want the rd_ptr of unk to move, in case it is
// shared by another Any. This copies the state, not the buffer.
TAO_InputCDR for_reading (unk->_tao_get_cdr ());
CORBA::Boolean const good_decode =
replacement->demarshal_value (for_reading,
static_cast<CORBA::Long> (tck));
if (good_decode)
{
Any_Basic_Impl::assign_value (_tao_elem,
replacement,
tck);
const_cast<CORBA::Any &> (any).replace (replacement);
replacement_safety.release ();
return true;
}
// Duplicated by Any_Impl base class constructor.
::CORBA::release (any_tc);
}
catch (const ::CORBA::Exception&)
{
}
return false;
}
示例8: cdr
void
TAO_DynArray_i::from_any (const CORBA::Any& any)
{
if (this->destroyed_)
{
throw ::CORBA::OBJECT_NOT_EXIST ();
}
CORBA::TypeCode_var tc = any.type ();
CORBA::Boolean equivalent = this->type_.in ()->equivalent (tc.in ());
if (equivalent)
{
// Get the CDR stream of the Any,if there isn't one, make one.
TAO::Any_Impl *impl = any.impl ();
TAO_OutputCDR out;
TAO_InputCDR cdr (static_cast<ACE_Message_Block *> (0));
if (impl->encoded ())
{
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
throw CORBA::INTERNAL ();
cdr = unk->_tao_get_cdr ();
}
else
{
impl->marshal_value (out);
TAO_InputCDR tmp_in (out);
cdr = tmp_in;
}
CORBA::ULong length = static_cast<CORBA::ULong> (this->da_members_.size ());
CORBA::ULong arg_length = this->get_tc_length (tc.in ());
if (length != arg_length)
{
throw DynamicAny::DynAny::TypeMismatch ();
}
CORBA::TypeCode_var field_tc = this->get_element_type ();
for (CORBA::ULong i = 0; i < arg_length; ++i)
{
CORBA::Any field_any;
TAO_InputCDR unk_in (cdr);
TAO::Unknown_IDL_Type *field_unk = 0;
ACE_NEW (field_unk,
TAO::Unknown_IDL_Type (field_tc.in (), unk_in));
field_any.replace (field_unk);
this->da_members_[i]->destroy ();
this->da_members_[i] =
TAO::MakeDynAnyUtils::make_dyn_any_t<const CORBA::Any&> (
field_any._tao_get_typecode (),
field_any,
this->allow_truncation_ );
// Move to the next field in the CDR stream.
(void) TAO_Marshal_Object::perform_skip (field_tc.in (), &cdr);
}
this->current_position_ = arg_length ? 0 : -1;
}
else
{
throw DynamicAny::DynAny::TypeMismatch ();
}
}
示例9: for_reading
CORBA::Boolean
TAO::Any_Impl_T<T>::extract (const CORBA::Any & any,
_tao_destructor destructor,
CORBA::TypeCode_ptr tc,
T *& _tao_elem)
{
_tao_elem = 0;
try
{
CORBA::TypeCode_ptr any_tc = any._tao_get_typecode ();
CORBA::Boolean const _tao_equiv = any_tc->equivalent (tc);
if (_tao_equiv == false)
{
return false;
}
TAO::Any_Impl * const impl = any.impl ();
if (impl && !impl->encoded ())
{
TAO::Any_Impl_T<T> * const narrow_impl =
dynamic_cast <TAO::Any_Impl_T<T> *> (impl);
if (narrow_impl == 0)
{
return false;
}
_tao_elem = (T *) narrow_impl->value_;
return true;
}
TAO::Any_Impl_T<T> *replacement = 0;
ACE_NEW_RETURN (replacement,
TAO::Any_Impl_T<T> (destructor,
any_tc,
0),
false);
auto_ptr<TAO::Any_Impl_T<T> > replacement_safety (replacement);
// We know this will work since the unencoded case is covered above.
TAO::Unknown_IDL_Type * const unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
if (!unk)
return false;
// We don't want the rd_ptr of unk to move, in case it is
// shared by another Any. This copies the state, not the buffer.
TAO_InputCDR for_reading (unk->_tao_get_cdr ());
CORBA::Boolean const good_decode =
replacement->demarshal_value (for_reading);
if (good_decode)
{
_tao_elem = const_cast<T *> (replacement->value_);
const_cast<CORBA::Any &> (any).replace (replacement);
replacement_safety.release ();
return true;
}
// Duplicated by Any_Impl base class constructor.
::CORBA::release (any_tc);
}
catch (const ::CORBA::Exception&)
{
}
return false;
}