void Any_Handler::extract_into_any (const Any& desc, CORBA::Any& toconfig) { DANCE_TRACE("Any_Handler::extract_into_any"); try { DynamicAny::DynAny_var dyn = DYNANY_HANDLER->extract_into_dynany (desc.type (), desc.value ()); CORBA::Any_var any_safe (dyn->to_any ()); toconfig = *any_safe; dyn->destroy (); } catch (CORBA::Exception &ex) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Any_Handler::extract_into_any -") ACE_TEXT (" Caught CORBA Exception while extracting into") ACE_TEXT (" dynany: %C\n"), ex._info ().c_str ())); throw Config_Error (ACE_TEXT (""), ACE_TEXT ("CORBA Exception while extracting into dynany\n")); } catch (Config_Error &ex) { throw ex; } catch (...) { throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Caught error whilst parsing XML into Any\n")); } }
void DynAnyAnalyzer::analyze (DynamicAny::DynAny_ptr da) { CORBA::TypeCode_var tc = da->type (); CORBA::TCKind kind = tc->kind (); CORBA::TypeCode_var dup = CORBA::TypeCode::_duplicate (tc.in ()); // strip aliases while (kind == CORBA::tk_alias) { dup = dup->content_type (); kind = dup->kind (); } switch (kind) { case CORBA::tk_struct: { DynamicAny::DynStruct_var ds = DynamicAny::DynStruct::_narrow (da); tab (level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, "STRUCT\n")); } if (da->seek (0) ) { level_++; do { DynamicAny::DynAny_var cc = ds->current_component (); DynamicAny::FieldName_var fn = ds->current_member_name (); tab(level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, "Member = %C\n", fn.in ())); } if (!CORBA::is_nil (cc.in ())) { this->analyze (cc.in ()); } } while (da->next ()); level_--; } } break; // end tk_struct case CORBA::tk_sequence: { if (TAO_DynCommon::is_basic_type_seq (tc.in ())) { this->analyze_basic_seq (dup.in (), da); } else { DynamicAny::DynSequence_var ds = DynamicAny::DynSequence::_narrow (da); int i = 0; tab(level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, "SEQUENCE\n")); } if (ds->seek (0UL)) { level_++; do { tab(level_); if (debug_) ACE_DEBUG ((LM_DEBUG, "[%d]\n", i)); DynamicAny::DynAny_var cc (ds->current_component ()); if (!CORBA::is_nil (cc.in ())) { analyze (cc.in ()); } i++; } while (da->next ()); level_--; } } } break; // end tk_sequence case CORBA::tk_array: { tab (level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, "ARRAY\n")); } level_++; CORBA::ULong const len = dup->length (); for (CORBA::ULong i = 0 ; i < len; ++i) { tab (level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, "[%d]\n", i)); } DynamicAny::DynAny_var cc = da->current_component(); if (!CORBA::is_nil (cc.in ())) { analyze (cc.in ()); } da->next (); } level_--; } break; case CORBA::tk_union: { DynamicAny::DynUnion_var value = DynamicAny::DynUnion::_narrow (da); if (!value->has_no_active_member ()) { DynamicAny::DynAny_var disc = value->member (); if (!CORBA::is_nil (disc.in ())) { this->analyze (disc.in ()); } } } break; case CORBA::tk_any: { DynamicAny::DynAny_var dynany; CORBA::Any_var any = da->get_any (); dynany = dynany_factory_->create_dyn_any (any.in ()); if (!CORBA::is_nil (dynany.in ())) { this->analyze (dynany.in ()); } dynany->destroy (); } break; case CORBA::tk_enum: { DynamicAny::DynEnum_var value = DynamicAny::DynEnum::_narrow (da); CORBA::String_var s = value->get_as_string (); tab (level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, " Value (enum) = %C\n", s.in())); } } break; CASEE (boolean, Boolean, " Value (bool) = %d\n"); CASEE (short, Short, " Value (short) = %d\n"); CASEE (ushort, UShort, " Value (ushort) = %u\n"); CASEE (long, Long, " Value (long) = %d\n"); CASEE (ulong, ULong, " Value (ulong) = %u\n"); CASEE (longlong, LongLong, " Value (longlong) %Ld\n"); CASEE (ulonglong, ULongLong, " Value (ulonglong) %Lu\n"); CASEE (char, Char, " Value (char) = %c\n"); CASEE (float, Float, " Value (float) = %f\n"); CASEE (double, Double, " Value (double) = %f\n"); CASEE (octet, Octet, " Value (octet) = %c\n"); case CORBA::tk_string: { CORBA::String_var b (da->get_string ()); tab (level_); if (debug_) { ACE_DEBUG ((LM_DEBUG, " Value (string) = %C\n", b.in ())); } } break; case CORBA::tk_TypeCode: { tab (level_); if (debug_) { CORBA::TCKind const kind = da->get_typecode ()->kind (); ACE_DEBUG ((LM_DEBUG, " Value (TypeCode) = %d\n", static_cast<int> (kind))); } } break; default: { tab (level_); if (debug_) { CORBA::TCKind const kind = tc->kind (); ACE_DEBUG ((LM_DEBUG, " unhandled typecode = %d\n", static_cast<int> (kind))); } } break; } if (debug_) { ACE_DEBUG ((LM_DEBUG, "\n")); } }