diff options
author | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
---|---|---|
committer | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
commit | 5a422aba704c375a307a902bafe658342e209906 (patch) | |
tree | 5005011e086bb863d8fb587ad3319bbec59b2447 /src/im_datatype.cpp |
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'src/im_datatype.cpp')
-rw-r--r-- | src/im_datatype.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/im_datatype.cpp b/src/im_datatype.cpp new file mode 100644 index 0000000..c75483e --- /dev/null +++ b/src/im_datatype.cpp @@ -0,0 +1,54 @@ +/** \file + * \brief Data Type Utilities + * + * See Copyright Notice in im_lib.h + * $Id: im_datatype.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + */ + + +#include "im.h" +#include "im_util.h" + +#include <assert.h> + +typedef struct _iTypeInfo +{ + int size; + unsigned long max; + long min; + char* name; +} iTypeInfo; + +static iTypeInfo iTypeInfoTable[] = +{ + {1, 255, 0, "byte"}, + {2, 65535, 0, "ushort"}, + {4, 2147483647, -2147483647-1, "int"}, + {4, 0, 0, "float"}, + {8, 0, 0, "cfloat"} +}; + +const char* imDataTypeName(int data_type) +{ + assert(data_type >= IM_BYTE && data_type <= IM_CFLOAT); + return iTypeInfoTable[data_type].name; +} + +int imDataTypeSize(int data_type) +{ + assert(data_type >= IM_BYTE && data_type <= IM_CFLOAT); + assert(sizeof(int) == 4); + return iTypeInfoTable[data_type].size; +} + +unsigned long imDataTypeIntMax(int data_type) +{ + assert(data_type >= IM_BYTE && data_type <= IM_CFLOAT); + return iTypeInfoTable[data_type].max; +} + +long imDataTypeIntMin(int data_type) +{ + assert(data_type >= IM_BYTE && data_type <= IM_CFLOAT); + return iTypeInfoTable[data_type].min; +} |