OnixS C++ SGX Titan ITCH Market Data Handler  1.2.2
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 #include "NamespaceHelper.h"
26 
27 ONIXS_HANDLER_NAMESPACE_BEGIN
28 
29 /*
30  Exception
31 */
32 
34 {
35  size_t ref_count;
36  std::string message;
37 
38  Implementation () : ref_count (1) {}
39 };
40 
41 Exception::Exception (const char* method_name, const char* message)
42  : impl_ (new Implementation)
43 {
44  if (message && *message)
45  impl_->message += message;
46 
47  touch (method_name);
48 }
49 
51  : impl_ (e.impl_)
52 {
53  impl_->ref_count++;
54 }
55 
57 {
58  if (!--impl_->ref_count)
59  delete impl_;
60 }
61 
63 {
64  Exception tmp = e;
65 
66  std::swap (tmp.impl_, impl_);
67 
68  return *this;
69 }
70 
72 {
73  return impl_->message.c_str ();
74 }
75 
76 void Exception::touch (const char* method_name)
77 {
78  if (!method_name || !*method_name)
79  return;
80 
81  impl_->message += "\n at ";
82  impl_->message += method_name;
83 }
84 
85 /*
86  OperationException
87 */
88 
89 OperationException::OperationException (const char* source, const char* message)
90  : Exception (source, message)
91 {
92 }
93 
94 /*
95  NotImplementedException
96 */
97 
98 ONIXS_HANDLER_NAMESPACE_END
Basic exception class for this namespace.
Definition: Exception.h:32
~Exception() ONIXS_SGXTITAN_ITCH_OVERRIDE
Destructor.
Definition: Exception.cpp:56
OperationException(const char *source, const char *message)
Constructor.
Definition: Exception.cpp:89
#define ONIXS_SGXTITAN_ITCH_NOTHROW
Definition: Compiler.h:27
Exception(const char *method_name, const char *message)
Constructor.
Definition: Exception.cpp:41
Exception & operator=(const Exception &)
Assignment.
Definition: Exception.cpp:62
const char * what() const ONIXS_SGXTITAN_ITCH_OVERRIDE
Returns information about error.
Definition: Exception.cpp:71
void touch(const char *method_name)
Add information about context of exception.
Definition: Exception.cpp:76