Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / CDR / tc.cpp
blob1b24186d9b14eca6c0a05d327e56ebafbae2ef11
2 //=============================================================================
3 /**
4 * @file tc.cpp
6 * Verify that the basic typecodes are able to interpret their CDR
7 * buffers.
9 * @author Carlos O'Ryan
11 //=============================================================================
14 #include "tao/AnyTypeCode/TypeCode.h"
15 #include "tao/AnyTypeCode/TypeCode_Constants.h"
16 #include "tao/ORB.h"
17 #include "tao/SystemException.h"
18 #include "tao/debug.h"
20 #include "ace/Log_Msg.h"
22 // In this version of TAO typecodes are based on CDR, we have to
23 // verify that CDR offers the services needed for Typecode...
24 int
25 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
27 try
29 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
31 static const CORBA::TypeCode_ptr tcs[]=
33 CORBA::_tc_null,
34 CORBA::_tc_void,
35 CORBA::_tc_short,
36 CORBA::_tc_long,
37 CORBA::_tc_ushort,
38 CORBA::_tc_ulong,
39 CORBA::_tc_float,
40 CORBA::_tc_double,
41 CORBA::_tc_boolean,
42 CORBA::_tc_char,
43 CORBA::_tc_octet,
44 CORBA::_tc_any,
45 CORBA::_tc_TypeCode,
46 CORBA::_tc_Principal,
47 CORBA::_tc_Object,
48 // CORBA::_tc_struct,
49 // CORBA::_tc_union,
50 // CORBA::_tc_enum,
51 CORBA::_tc_string,
52 // CORBA::_tc_sequence,
53 // CORBA::_tc_array,
54 // CORBA::_tc_alias,
55 // CORBA::_tc_except,
56 CORBA::_tc_longlong,
57 CORBA::_tc_ulonglong,
58 CORBA::_tc_longdouble,
59 CORBA::_tc_wchar,
60 CORBA::_tc_wstring,
61 CORBA::_tc_UNKNOWN,
62 CORBA::_tc_BAD_PARAM,
63 CORBA::_tc_NO_MEMORY,
64 CORBA::_tc_IMP_LIMIT,
65 CORBA::_tc_COMM_FAILURE,
66 CORBA::_tc_INV_OBJREF,
67 CORBA::_tc_OBJECT_NOT_EXIST,
68 CORBA::_tc_NO_PERMISSION,
69 CORBA::_tc_INTERNAL,
70 CORBA::_tc_MARSHAL,
71 CORBA::_tc_INITIALIZE,
72 CORBA::_tc_NO_IMPLEMENT,
73 CORBA::_tc_BAD_TYPECODE,
74 CORBA::_tc_BAD_OPERATION,
75 CORBA::_tc_NO_RESOURCES,
76 CORBA::_tc_NO_RESPONSE,
77 CORBA::_tc_PERSIST_STORE,
78 CORBA::_tc_BAD_INV_ORDER,
79 CORBA::_tc_TRANSIENT,
80 CORBA::_tc_FREE_MEM,
81 CORBA::_tc_INV_IDENT,
82 CORBA::_tc_INV_FLAG,
83 CORBA::_tc_INTF_REPOS,
84 CORBA::_tc_BAD_CONTEXT,
85 CORBA::_tc_OBJ_ADAPTER,
86 CORBA::_tc_DATA_CONVERSION,
87 CORBA::TypeCode::_tc_Bounds,
88 CORBA::TypeCode::_tc_BadKind
91 static int n = sizeof (tcs) / sizeof (tcs[0]);
93 for (const CORBA::TypeCode_ptr *i = tcs;
94 i != tcs + n;
95 ++i)
97 CORBA::TypeCode_ptr tc = *i;
99 CORBA::TCKind k = tc->kind ();
101 switch (k)
103 case CORBA::tk_objref:
104 case CORBA::tk_struct:
105 case CORBA::tk_union:
106 case CORBA::tk_enum:
107 case CORBA::tk_alias:
108 case CORBA::tk_except:
110 const char *id = tc->id ();
112 const char *name = tc->name ();
114 CORBA::ULong length = 0;
116 if (TAO_debug_level > 0)
118 ACE_DEBUG ((LM_DEBUG,
119 "ID = '%C'\n"
120 "%{%{ NAME = %C%$"
121 " KIND = %d%$"
122 " LENGTH = %d"
123 "%}%}\n",
124 (id?id:"empty ID"),
125 (name?name:"empty name"),
127 length));
129 break;
131 default:
132 if (TAO_debug_level > 0)
134 ACE_DEBUG ((LM_DEBUG,
135 "basic type: %d\n",
136 k));
138 break;
142 catch (const CORBA::Exception& ex)
144 ex._tao_print_exception ("TC");
145 return 1;
148 return 0;