forked from aegoroff/parser3mssql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwexception.cpp
72 lines (62 loc) · 1.7 KB
/
wexception.cpp
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
/*!
* \brief The file contains wide char exception implementation
* \author \verbatim
Created by: Alexander Egorov
\endverbatim
* \date \verbatim
Creation date: 2010-04-11
\endverbatim
* Copyright 2008-2012 Alexander Egorov <[email protected]> (http://www.egoroff.spb.ru)
*/
#include "StdAfx.h"
#include "wexception.h"
wexception::wexception()
try : pMessage_(new std::wstring)
, pMessageStream_(NULL) {} catch (const exception&) {
if (pMessage_ != NULL) {
delete pMessage_;
}
}
;
wexception::wexception(const wexception& rException)
: pMessageStream_(rException.pMessageStream_)
{
pMessage_ = new std::wstring(*(rException.pMessage_));
}
wexception::wexception(const std::wstring* pMessage)
: pMessage_(pMessage)
, pMessageStream_(NULL)
{}
wexception & wexception::operator=(const wexception& rException)
{
if (this != &rException) {
this->wexception::~wexception();
new (this)wexception(rException);
}
return *this;
}
wexception::wexception(const std::wostringstream* pMessageStream)
: pMessageStream_(pMessageStream)
{
pMessage_ = new std::wstring(pMessageStream_->str());
}
wexception::wexception(const wchar_t* pMessage) : pMessageStream_(NULL)
{
assert(pMessage != NULL);
pMessage_ = new std::wstring(pMessage);
}
wexception::~wexception()
{
if (pMessage_ != NULL) {
delete pMessage_;
} else {
assert(FALSE);
}
if (pMessageStream_ != NULL) {
delete pMessageStream_;
}
}
const std::wstring* wexception::GetMessage() const
{
return pMessage_;
}