OnixS C++ SGX Titan OUCH Trading Handler  1.2.0
API documentation
Exception.cpp
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement(the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 #include <string>
20 
21 #include <util/String.h>
22 
24 
25 using namespace OnixS::SgxTitan::Trading::Ouch;
26 
27 /*
28  Exception
29 */
30 
32 {
33  size_t ref_count;
34  std::string message;
35 
36  Implementation() : ref_count(1) {}
37 };
38 
39 Exception::Exception(const char* method_name, const char* message)
40  : impl_(new Implementation)
41 {
42  if(message && *message)
43  impl_->message += message;
44 
45  touch(method_name);
46 }
47 
49  : impl_(e.impl_)
50 {
51  impl_->ref_count++;
52 }
53 
54 Exception::~Exception() ONIXS_SGX_OUCH_NOTHROW
55 {
56  if(!--impl_->ref_count)
57  delete impl_;
58 }
59 
61 {
62  Exception tmp = e;
63 
64  std::swap(tmp.impl_, impl_);
65 
66  return *this;
67 }
68 
69 const char* Exception::what() const ONIXS_SGX_OUCH_NOTHROW
70 {
71  return impl_->message.c_str();
72 }
73 
74 void Exception::touch(const char* method_name)
75 {
76  if(!method_name || !*method_name)
77  return;
78 
79  impl_->message += "\n at ";
80  impl_->message += method_name;
81 }
82 
83 /*
84  OperationException
85 */
86 
87 OperationException::OperationException(const char* source, const char* message)
88  : Exception(source, message)
89 {
90 }
OperationException(const char *source, const char *message)
Constructor.
Definition: Exception.cpp:87
Exception(const char *method_name, const char *message)
Constructor.
Definition: Exception.cpp:39
void touch(const char *method_name)
Add information about context of exception.
Definition: Exception.cpp:74
Exception & operator=(const Exception &)
Assignment.
Definition: Exception.cpp:60
const char * what() const ONIXS_SGX_OUCH_OVERRIDE
Returns information about error.
Definition: Exception.cpp:69
Basic exception class for this namespace.
Definition: Exception.h:31
~Exception() ONIXS_SGX_OUCH_OVERRIDE
Destructor.
Definition: Exception.cpp:54