MPEG CDVA Experimentation Model (CXM)
1.0
Compact Descriptors for Visual Analisys
src
evx
base.h
Go to the documentation of this file.
1
2
/*
3
//
4
// Copyright (c) 2002-2014 Joe Bertolami. All Right Reserved.
5
//
6
// base.h
7
//
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are met:
10
//
11
// * Redistributions of source code must retain the above copyright notice, this
12
// list of conditions and the following disclaimer.
13
//
14
// * Redistributions in binary form must reproduce the above copyright notice,
15
// this list of conditions and the following disclaimer in the documentation
16
// and/or other materials provided with the distribution.
17
//
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
//
29
// Additional Information:
30
//
31
// For more information, visit http://www.bertolami.com.
32
//
33
*/
34
35
#ifndef __EV_BASE_H__
36
#define __EV_BASE_H__
37
38
/**********************************************************************************
39
//
40
// Platform definitions
41
//
42
**********************************************************************************/
43
44
#if defined (_WIN32) || defined (_WIN64)
45
#include "windows.h"
46
47
#pragma warning (disable : 4244) // conversion, possible loss of data
48
#pragma warning (disable : 4018) // signed / unsigned mismatch
49
#pragma warning (disable : 4996) // deprecated interfaces
50
#pragma warning (disable : 4221) // empty translation unit
51
#pragma warning (disable : 4273) // inconsistent linkage
52
53
#define EVX_PLATFORM_WINDOWS // building a Windows application
54
#elif defined (__APPLE__)
55
#include "TargetConditionals.h"
56
#import "Foundation/Foundation.h"
57
#include "unistd.h"
58
#include "sys/types.h"
59
#include "ctype.h"
60
61
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
62
#define EVX_PLATFORM_IOS // building an application for iOS
63
#elif TARGET_OS_MAC
64
#define EVX_PLATFORM_MACOSX // building a Mac OSX application
65
#endif
66
#else
67
#include "unistd.h"
68
#include "sys/types.h"
69
#include "ctype.h"
70
71
#define EVX_PLATFORM_LINUX
72
#endif
73
74
/**********************************************************************************
75
//
76
// Debug definitions
77
//
78
**********************************************************************************/
79
80
#if defined (EVX_PLATFORM_WINDOWS)
81
#ifdef _DEBUG
82
#define EVX_DEBUG _DEBUG
83
#elif defined (DEBUG)
84
#define EVX_DEBUG DEBUG
85
#endif
86
#if defined(EVX_DEBUG) && !defined(debug_break)
87
#define debug_break __debugbreak
88
#endif
89
#define __EVX_FUNCTION__ __FUNCTION__
90
#elif defined (EVX_PLATFORM_IOS) || defined (EVX_PLATFORM_MACOSX) || defined (EVX_PLATFORM_LINUX)
91
#ifdef DEBUG
92
#define EVX_DEBUG DEBUG
93
#if !defined(debug_break)
94
#define debug_break() __builtin_trap()
95
#endif
96
#endif
97
#define __EVX_FUNCTION__ __func__
98
#endif
99
100
/**********************************************************************************
101
//
102
// Standard headers
103
//
104
**********************************************************************************/
105
106
#include "stdio.h"
107
#include "stdlib.h"
108
#include "stdarg.h"
109
110
/**********************************************************************************
111
//
112
// Standard types
113
//
114
**********************************************************************************/
115
116
namespace
evx
{
117
118
#if defined (EVX_PLATFORM_WINDOWS)
119
typedef
INT64
int64
;
120
typedef
INT32
int32
;
121
typedef
INT16
int16
;
122
typedef
INT8
int8
;
123
124
typedef
UINT64
uint64
;
125
typedef
UINT32
uint32
;
126
typedef
UINT16
uint16
;
127
typedef
UINT8
uint8
;
128
#elif defined (EVX_PLATFORM_IOS) || defined (EVX_PLATFORM_MACOSX) || defined (EVX_PLATFORM_LINUX)
129
typedef
int64_t
int64
;
130
typedef
int32_t
int32
;
131
typedef
int16_t
int16
;
132
typedef
int8_t
int8
;
133
134
typedef
u_int64_t
uint64
;
135
typedef
u_int32_t
uint32
;
136
typedef
u_int16_t
uint16
;
137
typedef
u_int8_t
uint8
;
138
#endif
139
140
typedef
float
float32
;
141
typedef
double
float64
;
142
typedef
wchar_t
wchar
;
143
144
}
// namespace evx
145
146
/**********************************************************************************
147
//
148
// Status codes
149
//
150
**********************************************************************************/
151
152
namespace
evx
{
typedef
uint8
evx_status
; }
153
154
#define EVX_SUCCESS (0)
155
#define EVX_ERROR_INVALIDARG (1)
156
#define EVX_ERROR_NOTIMPL (2)
157
#define EVX_ERROR_OUTOFMEMORY (3)
158
#define EVX_ERROR_UNDEFINED (4)
159
#define EVX_ERROR_HARDWAREFAIL (5)
160
#define EVX_ERROR_INVALID_INDEX (6)
161
#define EVX_ERROR_CAPACITY_LIMIT (7)
162
#define EVX_ERROR_INVALID_RESOURCE (8)
163
#define EVX_ERROR_OPERATION_TIMEDOUT (9)
164
#define EVX_ERROR_EXECUTION_FAILURE (10)
165
#define EVX_ERROR_PERMISSION_DENIED (11)
166
#define EVX_ERROR_IO_FAILURE (12)
167
#define EVX_ERROR_RESOURCE_UNREACHABLE (13)
168
#define EVX_ERROR_SYSTEM_FAILURE (14)
169
#define EVX_ERROR_NOT_READY (15)
170
#define EVX_ERROR_OPERATION_COMPLETED (16)
171
#define EVX_ERROR_RESOURCE_UNUSED (17)
172
173
/**********************************************************************************
174
//
175
// Debug support
176
//
177
**********************************************************************************/
178
179
#ifdef EVX_DEBUG
180
#define EVX_PARAM_CHECK (1)
181
#define evx_err(fmt, ...) do { printf("[EVX-ERR] "); \
182
printf(fmt, ##__VA_ARGS__); \
183
printf("\n"); debug_break(); \
184
} while(0)
185
186
#define evx_msg(fmt, ...) do { printf("[EVX-MSG] "); \
187
printf(fmt, ##__VA_ARGS__); \
188
printf("\n"); \
189
} while(0)
190
#else
191
#define EVX_PARAM_CHECK (0)
192
#define evx_err(fmt, ...)
193
#define evx_msg(fmt, ...)
194
#endif
195
196
#define EVX_ERROR_CREATE_STRING(x) ((char *) #x)
197
#define evx_post_error(x) post_error_i(x, EVX_ERROR_CREATE_STRING(x), __EVX_FUNCTION__, (char *) __FILE__, __LINE__)
198
199
namespace
evx
{
200
201
inline
uint32
post_error_i
(
uint8
error,
const
char
*error_string,
const
char
*
function
,
const
char
*filename,
uint32
line)
202
{
203
#ifdef EVX_DEBUG
204
const
char
*path = filename;
205
for
(
int32
i = (
int32
) strlen(filename); i >= 0; --i)
206
{
207
if
(filename[ i ] ==
'/'
)
208
break
;
209
210
path = &filename[i];
211
}
212
213
evx_err
(
"*** RIP *** %s @ %s in %s:%i"
, error_string,
function
, path, line);
214
#endif
215
return
error;
216
}
217
218
}
// namespace evx
219
220
/**********************************************************************************
221
//
222
// Standard helpers
223
//
224
**********************************************************************************/
225
226
#define EVX_DISABLE_COPY_AND_ASSIGN(type) \
227
type(const type &rvalue); \
228
type &operator = (const type &rvalue);
229
230
#endif // __EV_BASE_H__
evx::uint8
u_int8_t uint8
Definition:
base.h:137
evx::float32
float float32
Definition:
base.h:140
evx::int32
int32_t int32
Definition:
base.h:130
evx
Definition:
base.h:116
evx::post_error_i
uint32 post_error_i(uint8 error, const char *error_string, const char *function, const char *filename, uint32 line)
Definition:
base.h:201
evx::uint16
u_int16_t uint16
Definition:
base.h:136
evx::wchar
wchar_t wchar
Definition:
base.h:142
evx::int16
int16_t int16
Definition:
base.h:131
evx::uint64
u_int64_t uint64
Definition:
base.h:134
evx::float64
double float64
Definition:
base.h:141
evx::uint32
u_int32_t uint32
Definition:
base.h:135
evx::evx_status
uint8 evx_status
Definition:
base.h:152
evx::int8
int8_t int8
Definition:
base.h:132
evx::int64
int64_t int64
Definition:
base.h:129
evx_err
#define evx_err(fmt,...)
Definition:
base.h:192
Generated on Mon Sep 11 2017 18:23:40 for MPEG CDVA Experimentation Model (CXM) by
1.8.13