Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSAError.h
1 
2 /* ===================================================================
3 *
4 * T R A D I N G S Y S T E M A P I ™
5 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
6 * A L L R I G H T S R E S E R V E D
7 *
8 * Consult your license regarding permissions and restrictions.
9 * You may obtain a copy of the License at:
10 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
11 *
12 * ====================================================================
13 */
14 
15 #ifndef TSA_ERROR__INCLUDED
16 #define TSA_ERROR__INCLUDED
17 
18 #include <exception>
19 #include <string>
20 
21 #include "TSATypeDef.h"
22 #include "TSASupport.h"
23 
24 namespace tsa {
25 
31  /*
32  ** ================================================================
33  ** >>> class exception <<<
34  ** ================================================================
35  */
36 
37  class dll_export exception : public std::exception {
38  public:
39  struct source_location {
40  std::string m_file;
41  int m_line;
42  source_location(const char* file, int line);
43  source_location(void);
44  std::string to_string(void)const;
45  };
46  protected:
47  std::string m_what;
48  std::string m_origin;
49  std::string m_msg;
50  identifier_t m_id = tsa::undefined_id;
51  source_location m_src_loc;
52  std::string file_from_path(const tsa::string& path);
53  void print_to_IDE_output(const char*);
54  public:
56  const std::string& message(void)const;
58  const std::string& origin(void)const;
60  std::string line(void)const;
62  identifier_t id(void)const;
63  public:
65  exception(void);
67  exception(const char* message);
69  exception(const char* message, const source_location& src_loc);
71  exception(const std::string& message, const source_location& src_loc);
73  exception(const char* origin, const char* message,const source_location& src_loc);
74  exception(const std::string& origin, const std::string& message,const source_location& src_loc);
76  exception(const object* raisingClassPtr, const std::string& message,
77  const source_location& sourceLocation);
78 
80  virtual ~exception() throw();
81  public:
83  void id(identifier_t);
85  virtual const char* what() const throw();
86 
87  void construct_message(void);
88  };
89 
92 #define SLOC tsa::exception::source_location(__FILE__, __LINE__)
93 
94 
95  /*
96  ** ================================================================
97  ** >>> class series_bounds_error <<<
98  ** ================================================================
99  */
100 
102 
103  class dll_export series_bounds_error : public tsa::exception {
104  public:
105  identifier_t m_series_state_id;
106  size_t m_data_index;
107  tsa::string m_series_name;
108  public:
110  series_bounds_error(identifier_t m_series_state_id, size_t index);
112  series_bounds_error(const tsa::string& series_name, identifier_t series_state_id, size_t data_index);
114  series_bounds_error(void);
116  virtual ~series_bounds_error(void);
117  };
118 
119 
120 #ifdef _WIN32
121 
122  /*
123  ** ================================================================
124  ** >>> CLASS WIN_STRUCTURED_EXCEPTION <<<
125  ** ================================================================
126  */
127 
130  class dll_export win_structured_exception : public exception {
131  private:
132  unsigned nSE;
133  public:
135  win_structured_exception(unsigned n);
137  win_structured_exception();
139  virtual ~win_structured_exception() { ; }
141  unsigned GetSENumber();
142  };
143 #endif
144 }//tsa
146 
147 #endif
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
Class tsa::exception used by most classes of the Trading System API library. The class inherits from ...
Definition: TSAError.h:37
Exception class thrown by series when insufficient data.
Definition: TSAError.h:103
int64_t identifier_t
type for ID&#39;s
Definition: TSATypeDef.h:117