/
standard_datatypes.h
105 lines (79 loc) · 3.75 KB
/
standard_datatypes.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// These are declarations for standard inputs to mex files
#ifndef STANDARD_DATATYPES_H
#define STANDARD_DATATYPES_H
#include <string>
// ----------------------------------------------------------------------//
// This is for a string input -------------------------------------------//
// ----------------------------------------------------------------------//
// NOT THREAD SAFE
void get_string(std::string &string,const mxArray *mat_buf); // potentially dangerous because user could change the length of the string
// ----------------------------------------------------------------------//
// This is for double scalar input --------------------------------------//
// ----------------------------------------------------------------------//
// NOT THREAD SAFE
void get_double_scalar(double &scalar,const mxArray *mat_buf);
// ----------------------------------------------------------------------//
// This is for integer scalar input -------------------------------------//
// ----------------------------------------------------------------------//
// NOT THREAD SAFE
void get_integer_scalar(int &scalar,const mxArray *mat_buf);
// ----------------------------------------------------------------------//
// This is for logical scalar input -------------------------------------//
// ----------------------------------------------------------------------//
// NOT THREAD SAFE
void get_logical_scalar(bool &scalar,const mxArray *mat_buf);
// ----------------------------------------------------------------------//
// This is for a double array input -------------------------------------//
// ----------------------------------------------------------------------//
class class_double_array {
public:
// Constructor
class_double_array(); // THREAD SAFE
// Properties
int width;
int height;
double *value;
// Methods
void reset(); // THREAD SAFE
void alloc(const int &h,const int &w); // NOT THREAD SAFE
void free(); // NOT THREAD SAFE
};
// NOT THREAD SAFE
void get_double_array(class_double_array &array,const mxArray *mat_buf);
// ----------------------------------------------------------------------//
// This is for a integer array input ------------------------------------//
// ----------------------------------------------------------------------//
class class_integer_array {
public:
// Constructor
class_integer_array(); // THREAD SAFE
// Properties
int width;
int height;
int *value;
// Methods
void reset(); // THREAD SAFE
void alloc(const int &h,const int &w); // NOT THREAD SAFE
void free(); // NOT THREAD SAFE
};
// NOT THREAD SAFE
void get_integer_array(class_integer_array &array,const mxArray *mat_buf);
// ----------------------------------------------------------------------//
// This is for a logical array input ------------------------------------//
// ----------------------------------------------------------------------//
class class_logical_array {
public:
// Constructor
class_logical_array(); // THREAD SAFE
// Properties
int width;
int height;
bool *value;
// Methods
void reset(); // THREAD SAFE
void alloc(const int &h,const int &w); // NOT THREAD SAFE
void free(); // NOT THREAD SAFE
};
// NOT THREAD SAFE
void get_logical_array(class_logical_array &array,const mxArray *mat_buf);
#endif /* STANDARD_DATATYPES_H */