Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / tests / InterfaceRepo / Bug_3155_Regression / test_idl.cpp
blob6bb7e0f1aa95cc43d0e4556df398b7514c5d990e
1 #include "tao/IFR_Client/IFR_ComponentsC.h"
2 #include "ace/Get_Opt.h"
3 #include "tao/ORB.h"
5 namespace
7 const ACE_TCHAR *ifr_ior_file = 0;
8 const ACE_TCHAR *idl_value = 0;
11 int
12 parse_args (int argc, ACE_TCHAR *argv[])
14 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("i:s:"));
15 const unsigned char full_success = 0x03;
16 unsigned char success = 0;
18 while (true)
20 int c = get_opts ();
21 if (success == full_success)
23 break;
26 if (c == -1)
28 ACE_ERROR_RETURN ((LM_ERROR,
29 "usage: %s"
30 " -i <ifr_ior>"
31 " -s <idl_valuetype>"
32 "\n",
33 argv [0]),
34 -1);
37 switch (c)
39 case 'i':
40 ifr_ior_file = get_opts.opt_arg ();
41 success |= 0x01;
42 break;
43 case 's':
44 idl_value = get_opts.opt_arg ();
45 success |= 0x02;
46 break;
50 // Indicates successful parsing of the command line
51 return 0;
54 // ----------------------------------------------------------------------
56 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
58 try
60 // init orb
61 CORBA::ORB_var the_orb =
62 CORBA::ORB_init (argc, argv);
64 if (parse_args (argc, argv) == -1)
66 return -1;
69 // get IFR
70 CORBA::Object_var objref =
71 the_orb->string_to_object (ifr_ior_file);
72 if (objref.in () == 0)
74 ACE_ERROR_RETURN ((LM_ERROR,
75 "The received objref is nil\n"),
76 -1);
79 CORBA::ComponentIR::Repository_var the_repo_ref;
80 try
82 the_repo_ref = CORBA::ComponentIR::Repository::_narrow (objref.in ());
84 catch (const CORBA::Exception &ex)
86 ex._tao_print_exception ("Can't narrow the IFR:");
87 return 1;
90 // search in repository
91 CORBA::Contained_var current_contained =
92 the_repo_ref->lookup_id (ACE_TEXT_ALWAYS_CHAR (idl_value));
93 if (CORBA::is_nil(current_contained.in ()))
95 ACE_ERROR_RETURN ((LM_ERROR,
96 "Can't look up the valuetype\n"),
97 -1);
100 // get value type definition
101 CORBA::ExtValueDef_var value_def =
102 CORBA::ExtValueDef::_narrow (current_contained.in ());
103 CORBA::ExtValueDef::ExtFullValueDescription_var value_descr;
106 value_descr = value_def->describe_ext_value ();
108 catch (const CORBA::Exception &ex)
110 ex._tao_print_exception ("Can't describe_ext_value:");
111 return 1;
114 CORBA::ValueMemberSeq& the_value_members =
115 value_descr->members;
116 for (CORBA::ULong ct = 0; ct < the_value_members.length (); ++ct)
118 const CORBA::ValueMember& current_member =
119 the_value_members [ct];
120 ACE_DEBUG ((LM_DEBUG,
121 "value type member '%C'\n",
122 current_member.name.in ()));
125 catch (const CORBA::Exception &ex)
127 ex._tao_print_exception ("MAIN: Unexpected CORBA exception caught:");
128 return 1;
130 return 0;