HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_ErrorUtil.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __HOM_ErrorUtil_h__
10 #define __HOM_ErrorUtil_h__
11 
12 #include "HOM_API.h"
13 #include "HOM_Errors.h"
14 
15 #ifdef SWIG
16 
17 // We can't use templates here because SWIG doesn't seem to be able to handle
18 // the syntax. Just provide the single case we need in hom.i right now.
19 static inline void
20 HOMthrowIfNone(const char *pointer, const char *msg, bool allow_empty)
21 {
22  // We must throw a value error to match what SWIG might do if it
23  // type-checked for None itself.
24  if (!pointer || (!allow_empty && !*pointer))
25  throw HOM_ValueError(msg);
26 }
27 
28 #else // !defined(SWIG)
29 
30 #include <SYS/SYS_Inline.h>
31 
32 template <typename T>
33 void
34 HOMthrowIfNone(const T *pointer, const char *msg, bool allow_empty = true)
35 {
36  // We must throw a value error to match what SWIG might do if it
37  // type-checked for None itself.
38  if (!pointer)
39  throw HOM_ValueError(msg);
40 }
41 
42 template <>
43 SYS_STATIC_INLINE void
44 HOMthrowIfNone<char>(const char *pointer, const char *msg, bool allow_empty)
45 {
46  // We must throw a value error to match what SWIG might do if it
47  // type-checked for None itself.
48  if (!pointer || (!allow_empty && !*pointer))
49  throw HOM_ValueError(msg);
50 }
51 
52 #endif
53 
54 #endif // __HOM_ErrorUtil_h__
GLenum void ** pointer
Definition: glcorearb.h:810
void HOMthrowIfNone(const T *pointer, const char *msg, bool allow_empty=true)
Definition: HOM_ErrorUtil.h:34
SYS_STATIC_INLINE void HOMthrowIfNone< char >(const char *pointer, const char *msg, bool allow_empty)
Definition: HOM_ErrorUtil.h:44