00001 #include "tao/Exception.h"
00002 #include "tao/SystemException.h"
00003 #include "tao/Environment.h"
00004 #include "tao/ORB_Constants.h"
00005 #include "tao/CORBA_String.h"
00006
00007 #include "ace/Malloc.h"
00008 #include "ace/SString.h"
00009 #include "ace/OS_NS_string.h"
00010
00011 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
00012
00013
00014 #include "ace/streams.h"
00015 #endif
00016
00017 #if !defined (__ACE_INLINE__)
00018 # include "tao/Exception.inl"
00019 #endif
00020
00021 #include "ace/OS_NS_stdio.h"
00022
00023
00024
00025
00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00027
00028 CORBA::Exception::Exception (const char * repository_id,
00029 const char * local_name)
00030 : id_ (CORBA::string_dup (repository_id)),
00031 name_ (CORBA::string_dup (local_name))
00032 {
00033 ACE_ASSERT (this->id_.in () != 0 && this->name_.in () != 0);
00034 }
00035
00036 CORBA::Exception::Exception (const CORBA::Exception &src)
00037 : id_ (CORBA::string_dup (src.id_)),
00038 name_ (CORBA::string_dup (src.name_))
00039 {
00040 ACE_ASSERT (this->id_.in () != 0 && this->name_.in () != 0);
00041 }
00042
00043
00044
00045
00046
00047 CORBA::Exception::Exception (void)
00048 : id_ (),
00049 name_ ()
00050 {
00051 }
00052
00053 CORBA::Exception::~Exception (void)
00054 {
00055 }
00056
00057 CORBA::Exception &
00058 CORBA::Exception::operator= (const CORBA::Exception &src)
00059 {
00060 this->id_ = CORBA::string_dup (src.id_);
00061 ACE_ASSERT (this->id_.in () != 0);
00062
00063 this->name_ = CORBA::string_dup (src.name_);
00064 ACE_ASSERT (this->name_.in () != 0);
00065
00066 return *this;
00067 }
00068
00069 const char *
00070 CORBA::Exception::_rep_id (void) const
00071 {
00072 return this->id_.in ();
00073 }
00074
00075 const char *
00076 CORBA::Exception::_name (void) const
00077 {
00078 return this->name_.in ();
00079 }
00080
00081 void
00082 CORBA::Exception::_tao_print_exception (const char *user_provided_info,
00083 FILE *) const
00084 {
00085 ACE_ERROR ((LM_ERROR,
00086 ACE_TEXT ("(%P|%t) EXCEPTION, %C\n")
00087 ACE_TEXT ("%C\n"),
00088 user_provided_info,
00089 this->_info ().c_str ()));
00090 }
00091
00092 #if defined (ACE_USES_WCHAR)
00093 void
00094 CORBA::Exception::_tao_print_exception (const ACE_WCHAR_T *info,
00095 FILE *f) const
00096 {
00097
00098
00099
00100 this->_tao_print_exception (ACE_TEXT_ALWAYS_CHAR (info), f);
00101 }
00102 #endif // ACE_USES_WCHAR
00103
00104 void
00105 CORBA::Exception::_tao_any_destructor (void *x)
00106 {
00107 CORBA::Exception *tmp = static_cast<CORBA::Exception *> (x);
00108 delete tmp;
00109 }
00110
00111 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
00112
00113 namespace CORBA
00114 {
00115 ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
00116 const CORBA::Exception &e)
00117 {
00118 os << e._name () << " (" << e._rep_id () << ')';
00119
00120 return os;
00121 }
00122
00123 ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
00124 const CORBA::Exception *e)
00125 {
00126 os << e->_name () << " (" << e->_rep_id () << ')';
00127
00128 return os;
00129 }
00130 }
00131
00132 #endif
00133
00134 TAO_END_VERSIONED_NAMESPACE_DECL