OpenDDS  Snapshot(2023/04/28-20:55)
Exception.cpp
Go to the documentation of this file.
1 #include <tao/Exception.h>
2 #include <tao/SystemException.h>
3 #include <tao/Environment.h>
4 #include <tao/ORB_Constants.h>
5 #include <tao/CORBA_String.h>
6 #include <tao/Version.h>
7 
8 #include <ace/OS_NS_stdio.h>
9 #include <ace/Malloc.h>
10 #include <ace/SString.h>
11 #include <ace/OS_NS_string.h>
12 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
13 // Needed for ostream& operator<< (ostream &os, const CORBA::Exception &e)
14 // FUZZ: disable check_for_streams_include
15 # include <ace/streams.h>
16 #endif /* (ACE_LACKS_IOSTREAM_TOTALLY) */
17 
18 #if !defined (__ACE_INLINE__)
19 # include <tao/Exception.inl>
20 #endif /* __ACE_INLINE__ */
21 
22 // ****************************************************************
23 
25 
26 CORBA::Exception::Exception (const char * repository_id,
27  const char * local_name)
28  : id_ (CORBA::string_dup (repository_id)),
29  name_ (CORBA::string_dup (local_name))
30 {
31  ACE_ASSERT (this->id_.in () != 0 && this->name_.in () != 0);
32 }
33 
35  : id_ (CORBA::string_dup (src.id_)),
36  name_ (CORBA::string_dup (src.name_))
37 {
38  ACE_ASSERT (this->id_.in () != 0 && this->name_.in () != 0);
39 }
40 
41 // NOTE: It's this code, not anything defined in a subclass, which is
42 // responsible for releasing any storage owned by the exception. It
43 // can do this because it's got the local name and the id.
44 
45 #if TAO_MAJOR_VERSION == 2
47  : id_ (),
48  name_ ()
49 {
50 }
51 
53 {
54 }
55 #endif
56 
59 {
60  this->id_ = CORBA::string_dup (src.id_);
61  ACE_ASSERT (this->id_.in () != 0);
62 
63  this->name_ = CORBA::string_dup (src.name_);
64  ACE_ASSERT (this->name_.in () != 0);
65 
66  return *this;
67 }
68 
69 const char *
70 CORBA::Exception::_rep_id (void) const
71 {
72  return this->id_.in ();
73 }
74 
75 const char *
76 CORBA::Exception::_name (void) const
77 {
78  return this->name_.in ();
79 }
80 
81 void
82 CORBA::Exception::_tao_print_exception (const char *user_provided_info,
83  FILE *) const
84 {
85  ACE_ERROR ((LM_ERROR,
86  ACE_TEXT ("(%P|%t) EXCEPTION, %C\n")
87  ACE_TEXT ("%C\n"),
88  user_provided_info,
89  this->_info ().c_str ()));
90 }
91 
92 #if defined (ACE_USES_WCHAR)
93 void
94 CORBA::Exception::_tao_print_exception (const ACE_WCHAR_T *info,
95  FILE *f) const
96 {
97  // Even though this call causes additional type conversions, this is
98  // better for the maintenance. Plus, this will occur only on
99  // exception anyway.
100  this->_tao_print_exception (ACE_TEXT_ALWAYS_CHAR (info), f);
101 }
102 #endif // ACE_USES_WCHAR
103 
104 void
106 {
107  CORBA::Exception *tmp = static_cast<CORBA::Exception *> (x);
108  delete tmp;
109 }
110 
111 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
112 
113 namespace CORBA
114 {
115  ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
116  const CORBA::Exception &e)
117  {
118  os << e._name () << " (" << e._rep_id () << ')';
119 
120  return os;
121  }
122 
123  ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
124  const CORBA::Exception *e)
125  {
126  os << e->_name () << " (" << e->_rep_id () << ')';
127 
128  return os;
129  }
130 }
131 
132 #endif /* (ACE_LACKS_IOSTREAM_TOTALLY) */
133 
#define ACE_ERROR(X)
#define TAO_BEGIN_VERSIONED_NAMESPACE_DECL
CORBA::String_var id_
static void _tao_any_destructor(void *)
Definition: Exception.cpp:105
virtual const char * _rep_id(void) const
Definition: Exception.cpp:70
CORBA::String_var name_
Exception & operator=(const Exception &src)
Definition: Exception.cpp:58
virtual ~Exception(void)
char * string_dup(const char *)
ACE_CDR::Boolean operator<<(Serializer &serializer, CoherentChangeControl &value)
Marshal/Insertion into a buffer.
virtual const char * _name(void) const
Definition: Exception.cpp:76
#define ACE_ASSERT(X)
Char * string_dup(const Char *str)
#define TAO_END_VERSIONED_NAMESPACE_DECL
void _tao_print_exception(const char *info, FILE *f=stdout) const
Definition: Exception.cpp:82