My Project
exception.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2014, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 
12 #ifdef __cplusplus
13 
14 #include <iostream>
15 #include <af/defines.h>
16 
17 namespace af {
18 
19 class AFAPI exception : public std::exception
20 {
21 private:
22  char m_msg[1024];
23  af_err m_err;
24 public:
25  af_err err() { return m_err; }
26  exception();
27  exception(const char *msg);
28  exception(const char *file, unsigned line, af_err err);
29  exception(const char *msg, const char *file, unsigned line, af_err err);
30 #if AF_API_VERSION >= 33
31  exception(const char *msg, const char *func, const char *file, unsigned line, af_err err);
32 #endif
33  virtual ~exception() throw() {}
34  virtual const char *what() const throw() { return m_msg; }
35  friend inline std::ostream& operator<<(std::ostream &s, const exception &e)
36  { return s << e.what(); }
37 };
38 
39 }
40 
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 AFAPI void af_get_last_error(char **msg, dim_t *len);
48 AFAPI const char *af_err_to_string(const af_err err);
49 
50 #ifdef __cplusplus
51 }
52 #endif
af_err_to_string
const AFAPI char * af_err_to_string(const af_err err)
dim_t
long long dim_t
Definition: defines.h:49
AFAPI
#define AFAPI
Definition: defines.h:30
af
Definition: algorithm.h:13
af::exception
Definition: exception.h:24
af_get_last_error
AFAPI void af_get_last_error(char **msg, dim_t *len)
af::operator<<
AFAPI array operator<<(const array &lhs, const array &rhs)
Performs an left shift operation on two arrays or an array and a value.
af_err
af_err
Definition: defines.h:62
defines.h