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