Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AnyPrinter.cc

00001 /*
00002   AnyPrinter: dynamic print Any Value, use DynAny parsing.
00003   (part of realization of UA_KIEV_GRAD::Debug::AnyPrinter)
00004 
00005   (C) Ruslan Shevchenko <Ruslan@Shevchenko.Kiev.UA>, 1998
00006   AnyPrinter.cc,v 1.1 2004/03/05 17:12:50 stack Exp
00007 */
00008 
00009 #include "config.h"
00010 
00011 #include <iostream>
00012 
00013 #include <BrokerC.h>
00014 #include <Typecode.h>
00015 
00016 #include <AnyPrinter.hh>
00017 
00018 using namespace std;
00019 
00020 extern CORBA::ORB* myORB;
00021 
00022 void AnyPrinter::print_to_stream(ostream& os, const CORBA::Any& value)
00023 {
00024     CORBA::TypeCode_var tc;
00025 
00026     tc = value.type();
00027     if (tc.in() == NULL) {
00028         cerr << "Illegal ANY" << endl;
00029         throw CORBA::BAD_TYPECODE();
00030         return;
00031     }
00032     switch(tc->kind()){
00033     case CORBA::tk_null:
00034         os << "null-typed" << endl;
00035         break;
00036     case CORBA::tk_void:
00037         os << "void" << endl;
00038         break;
00039     case CORBA::tk_short:
00040         {
00041             CORBA::Short sh;
00042             value >>= sh;
00043             os << sh<<endl;
00044         }
00045         break;
00046     case CORBA::tk_long:
00047         {
00048             CORBA::Long l;
00049             value >>= l;
00050             os << l << endl;
00051         }
00052         break;
00053     case CORBA::tk_ushort:
00054         {
00055             CORBA::UShort ush;
00056             value >>= ush;
00057             os << ush << endl;
00058         }
00059         break;
00060     case CORBA::tk_ulong:
00061         {
00062             CORBA::ULong ul;
00063             value >>= ul;
00064             os << ul << endl;
00065         }
00066         break;
00067     case CORBA::tk_float:
00068         {
00069             CORBA::Float fl;
00070             value >>= fl;
00071             os << fl << endl;
00072         }
00073         break;
00074     case CORBA::tk_double:
00075         {
00076             CORBA::Double d;
00077             value >>= d;
00078             os << "double:" << d << endl;
00079         }
00080         break;
00081     case CORBA::tk_boolean:
00082         {
00083             CORBA::Boolean b;
00084             value >>= CORBA::Any::to_boolean(b);
00085             os << "boolean:" << (int)b << endl;
00086         }
00087         break;
00088     case CORBA::tk_char:
00089         {
00090             CORBA::Char ch;
00091             value >>= CORBA::Any::to_char(ch);
00092             os << "char:" << ch << endl;
00093         }
00094         break;
00095     case CORBA::tk_octet:
00096         { CORBA::Octet oc;
00097         value >>= CORBA::Any::to_octet(oc);
00098         os << "octet:" << oc << endl;
00099         }
00100         break;
00101     default:
00102         os << "unknown type" << endl;
00103         break;
00104     }
00105 }

Generated on Fri Oct 22 07:50:24 2004 for CPU Broker by  doxygen 1.3.9.1