TagLib 1.10 (TagLib: modfileprivate.h Source File)

modfileprivate.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright           : (C) 2011 by Mathias Panzenböck
00003     email               : grosser.meister.morti@gmx.net
00004  ***************************************************************************/
00005 
00006 /***************************************************************************
00007  *   This library is free software; you can redistribute it and/or modify  *
00008  *   it  under the terms of the GNU Lesser General Public License version  *
00009  *   2.1 as published by the Free Software Foundation.                     *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful, but   *
00012  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the Free Software   *
00018  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            *
00019  *   MA  02110-1301  USA                                                   *
00020  ***************************************************************************/
00021 
00022 #ifndef TAGLIB_MODFILEPRIVATE_H
00023 #define TAGLIB_MODFILEPRIVATE_H
00024 
00025 // some helper-macros only used internally by (s3m|it|xm)file.cpp
00026 #define READ_ASSERT(cond) \
00027   if(!(cond)) \
00028   { \
00029     setValid(false); \
00030     return; \
00031   }
00032 
00033 #define READ(setter,type,read) \
00034   { \
00035     type number; \
00036     READ_ASSERT(read(number)); \
00037     setter(number); \
00038   }
00039 
00040 #define READ_BYTE(setter) READ(setter,uchar,readByte)
00041 #define READ_U16L(setter) READ(setter,ushort,readU16L)
00042 #define READ_U32L(setter) READ(setter,ulong,readU32L)
00043 #define READ_U16B(setter) READ(setter,ushort,readU16B)
00044 #define READ_U32B(setter) READ(setter,ulong,readU32B)
00045 
00046 #define READ_STRING(setter,size) \
00047   { \
00048     String s; \
00049     READ_ASSERT(readString(s, size)); \
00050     setter(s); \
00051   }
00052 
00053 #define READ_AS(type,name,read) \
00054   type name = 0; \
00055   READ_ASSERT(read(name));
00056 
00057 #define READ_BYTE_AS(name) READ_AS(uchar,name,readByte)
00058 #define READ_U16L_AS(name) READ_AS(ushort,name,readU16L)
00059 #define READ_U32L_AS(name) READ_AS(ulong,name,readU32L)
00060 #define READ_U16B_AS(name) READ_AS(ushort,name,readU16B)
00061 #define READ_U32B_AS(name) READ_AS(ulong,name,readU32B)
00062 
00063 #define READ_STRING_AS(name,size) \
00064   String name; \
00065   READ_ASSERT(readString(name, size));
00066 
00067 #endif