OpenMW
components/interpreter/types.hpp
Go to the documentation of this file.
00001 #ifndef INTERPRETER_TYPES_H_INCLUDED
00002 #define INTERPRETER_TYPES_H_INCLUDED
00003 
00004 #include <stdexcept>
00005 
00006 namespace Interpreter
00007 {
00008     typedef unsigned int Type_Code; // 32 bit
00009 
00010     typedef unsigned int Type_Data; // 32 bit
00011     
00012     typedef short Type_Short; // 16 bit
00013     
00014     typedef int Type_Integer; // 32 bit
00015     
00016     typedef float Type_Float; // 32 bit
00017     
00018     union Data
00019     {
00020         Type_Integer mInteger;
00021         Type_Float mFloat;
00022     };
00023     
00024     template<typename T>
00025     T& getData (Data& data)
00026     {
00027         throw std::runtime_error ("unsupported data type");
00028     }
00029     
00030     template<>
00031     inline Type_Integer& getData (Data& data)
00032     {
00033         return data.mInteger;
00034     }
00035     
00036     template<>
00037     inline Type_Float& getData (Data& data)
00038     {
00039         return data.mFloat;
00040     }    
00041 }
00042 
00043 #endif
00044