SDIFType.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef __SDIFType__
00023 #define __SDIFType__
00024 
00025 
00026 #include <string.h>
00027 #include "DataTypes.hxx"
00028 
00029 namespace SDIF
00030 {
00031 
00036         class TypeId
00037         {
00038         friend class File;
00039         protected:
00041                 CLAM::TByte mData[4];
00042         public:
00046                 TypeId(const char* str = "\0\0\0\0")
00047                 {
00048                         memcpy(mData,str,4);    
00049                 }
00054                 bool operator == (const TypeId& cmp) { return !memcmp(mData,cmp.mData,4); }
00055 
00058                 const char* String(void) const
00059                 {
00060                         static char str[5];
00061                         memcpy(str,mData,4);
00062                         str[4]='\0';
00063                         return str;
00064                 }
00065 
00066                 static TypeId sDefault;
00067         };
00068 
00069         enum DataType
00070         {
00071                 eUnknown  = 0,
00072                 eFloat32  =   0x4, // 32-bit big-endian IEEE 754 float, 4 bytes
00073                 eFloat64  =   0x8, // 64-bit big-endian IEEE 754 float, 8 bytes
00074                 eInt32    = 0x104, // 32-bit big-endian two's complement integer, 4 bytes
00075                 eInt64    = 0x108, // 64-bit big-endian two's complement integer, 8 bytes
00076                 eUint42   = 0x204, // 32-bit big-endian unsigned integer, 4 bytes
00077                 eUTF8byte = 0x301, // Byte of UTF8-encoded text, 1 bytes
00078                 eByte     = 0x401  // Arbitrary byte, 1 bytes
00079         };
00080 
00081         template <class T> class GetType
00082         {
00083         public:
00084                 static DataType Get(void) { return eUnknown; }
00085         };
00086         
00087         class TUTF8byte
00088         {
00089         public:
00090                 char c;
00091         };
00092         
00093         template <> class GetType<CLAM::TFloat32>{public:static DataType Get(void){return eFloat32;}};
00094         template <> class GetType<CLAM::TFloat64>{public:static DataType Get(void){return eFloat64;}};
00095         template <> class GetType<CLAM::TInt32>{public:static DataType Get(void){return eInt32;}};
00096         template <> class GetType<CLAM::TInt64>{public:static DataType Get(void){return eInt64;}};
00097         template <> class GetType<TUTF8byte>{public:static DataType Get(void){return eUTF8byte;}};
00098         template <> class GetType<CLAM::TByte>{public:static DataType Get(void){return eByte;}};
00099 
00100 }
00101 #endif
00102 
Generated by  doxygen 1.6.3