summaryrefslogtreecommitdiff
path: root/TAO/tao/Exception.cpp
blob: b6de9c41fced5663c1d70dfd6bcc6da749984528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// -*- C++ -*-
#include "tao/Exception.h"
#include "tao/SystemException.h"
#include "tao/Environment.h"
#include "tao/ORB_Constants.h"
#include "tao/CORBA_String.h"
#include "tao/CDR.h"
#include "tao/debug.h"

#include "ace/Malloc.h"
#include "ace/SString.h"
#include "ace/OS_NS_string.h"


#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
// Needed for ostream& operator<< (ostream &os, const CORBA::Exception &e)
// FUZZ: disable check_for_streams_include
#include "ace/streams.h"
#endif /* (ACE_LACKS_IOSTREAM_TOTALLY) */

#if !defined (__ACE_INLINE__)
# include "tao/Exception.inl"
#endif /* __ACE_INLINE__ */

#include "ace/OS_NS_stdio.h"

// ****************************************************************

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

CORBA::Exception::Exception (const char * repository_id,
                             const char * local_name)
  : id_ (CORBA::string_dup (repository_id)),
    name_ (CORBA::string_dup (local_name))
{
}

CORBA::Exception::Exception (const CORBA::Exception &src)
  : id_ (CORBA::string_dup (src.id_)),
    name_ (CORBA::string_dup (src.name_))
{
}

// NOTE: It's this code, not anything defined in a subclass, which is
// responsible for releasing any storage owned by the exception.  It
// can do this because it's got the local name and the id.

CORBA::Exception::Exception (void)
  : id_ (),
    name_ ()
{
}

CORBA::Exception::~Exception (void)
{
}

CORBA::Exception &
CORBA::Exception::operator= (const CORBA::Exception &src)
{
  if (this != &src)
    {
      this->id_ = CORBA::string_dup (src.id_);
      this->name_ = CORBA::string_dup (src.name_);
    }

  return *this;
}

const char *
CORBA::Exception::_rep_id (void) const
{
  return this->id_.in ();
}

const char *
CORBA::Exception::_name (void) const
{
  return this->name_.in ();
}

void
CORBA::Exception::_tao_print_exception (const char *user_provided_info,
                                        FILE *) const
{
  TAOLIB_ERROR ((LM_ERROR,
              ACE_TEXT ("(%P|%t) EXCEPTION, %C\n")
              ACE_TEXT ("%C\n"),
              user_provided_info,
              this->_info ().c_str ()));
}

#if defined (ACE_USES_WCHAR)
void
CORBA::Exception::_tao_print_exception (const ACE_WCHAR_T *info,
                                        FILE *f) const
{
  // Even though this call causes additional type conversions, this is
  // better for the maintenance.  Plus, this will occur only on
  // exception anyway.
  this->_tao_print_exception (ACE_TEXT_ALWAYS_CHAR (info), f);
}
#endif  // ACE_USES_WCHAR

void
CORBA::Exception::_tao_any_destructor (void *x)
{
  CORBA::Exception *tmp = static_cast<CORBA::Exception *> (x);
  delete tmp;
}

#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)

namespace CORBA
{
  ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
                                const CORBA::Exception &e)
  {
    os << e._name () << " (" << e._rep_id () << ')';

    return os;
  }

  ACE_OSTREAM_TYPE& operator<< (ACE_OSTREAM_TYPE &os,
                                const CORBA::Exception *e)
  {
    os << e->_name () << " (" << e->_rep_id () << ')';

    return os;
  }
}

#endif /* (ACE_LACKS_IOSTREAM_TOTALLY) */

TAO_END_VERSIONED_NAMESPACE_DECL