Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Exception.cpp
blob8868601f717a3a5fb0d7af2a0c3201a999c86540
1 // -*- C++ -*-
2 #include "tao/Exception.h"
3 #include "tao/SystemException.h"
4 #include "tao/Environment.h"
5 #include "tao/ORB_Constants.h"
6 #include "tao/CORBA_String.h"
7 #include "tao/CDR.h"
8 #include "tao/debug.h"
10 #include "ace/Malloc.h"
11 #include "ace/SString.h"
12 #include "ace/OS_NS_string.h"
15 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
16 // Needed for ostream& operator<< (ostream &os, const CORBA::Exception &e)
17 // FUZZ: disable check_for_streams_include
18 #include "ace/streams.h"
19 #endif /* (ACE_LACKS_IOSTREAM_TOTALLY) */
21 #if !defined (__ACE_INLINE__)
22 # include "tao/Exception.inl"
23 #endif /* __ACE_INLINE__ */
25 #include "ace/OS_NS_stdio.h"
27 // ****************************************************************
29 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
31 CORBA::Exception::Exception (const char * repository_id,
32 const char * local_name)
33 : id_ (CORBA::string_dup (repository_id)),
34 name_ (CORBA::string_dup (local_name))
38 CORBA::Exception::Exception (const CORBA::Exception &src)
39 : id_ (CORBA::string_dup (src.id_)),
40 name_ (CORBA::string_dup (src.name_))
44 // NOTE: It's this code, not anything defined in a subclass, which is
45 // responsible for releasing any storage owned by the exception. It
46 // can do this because it's got the local name and the id.
48 CORBA::Exception &
49 CORBA::Exception::operator= (const CORBA::Exception &src)
51 if (this != &src)
53 this->id_ = CORBA::string_dup (src.id_);
54 this->name_ = CORBA::string_dup (src.name_);
57 return *this;
60 const char *
61 CORBA::Exception::_rep_id () const
63 return this->id_.in ();
66 const char *
67 CORBA::Exception::_name () const
69 return this->name_.in ();
72 void
73 CORBA::Exception::_tao_print_exception (const char *user_provided_info,
74 FILE *) const
76 TAOLIB_ERROR ((LM_ERROR,
77 ACE_TEXT ("(%P|%t) EXCEPTION, %C\n")
78 ACE_TEXT ("%C\n"),
79 user_provided_info,
80 this->_info ().c_str ()));
83 #if defined (ACE_USES_WCHAR)
84 void
85 CORBA::Exception::_tao_print_exception (const ACE_WCHAR_T *info,
86 FILE *f) const
88 // Even though this call causes additional type conversions, this is
89 // better for the maintenance. Plus, this will occur only on
90 // exception anyway.
91 this->_tao_print_exception (ACE_TEXT_ALWAYS_CHAR (info), f);
93 #endif // ACE_USES_WCHAR
95 void
96 CORBA::Exception::_tao_any_destructor (void *x)
98 CORBA::Exception *tmp = static_cast<CORBA::Exception *> (x);
99 delete tmp;
102 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
104 namespace CORBA
106 ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
107 const CORBA::Exception &e)
109 os << e._name () << " (" << e._rep_id () << ')';
111 return os;
114 ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
115 const CORBA::Exception *e)
117 os << e->_name () << " (" << e->_rep_id () << ')';
119 return os;
123 #endif /* (ACE_LACKS_IOSTREAM_TOTALLY) */
125 TAO_END_VERSIONED_NAMESPACE_DECL