modfileprivate.h
Go to the documentation of this file.
1 /***************************************************************************
2  copyright : (C) 2011 by Mathias Panzenböck
3  email : grosser.meister.morti@gmx.net
4  ***************************************************************************/
5 
6 /***************************************************************************
7  * This library is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU Lesser General Public License version *
9  * 2.1 as published by the Free Software Foundation. *
10  * *
11  * This library is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the Free Software *
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19  * MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef TAGLIB_MODFILEPRIVATE_H
23 #define TAGLIB_MODFILEPRIVATE_H
24 
25 // some helper-macros only used internally by (s3m|it|xm)file.cpp
26 #define READ_ASSERT(cond) \
27  if(!(cond)) \
28  { \
29  setValid(false); \
30  return; \
31  }
32 
33 #define READ(setter,type,read) \
34  { \
35  type number; \
36  READ_ASSERT(read(number)); \
37  setter(number); \
38  }
39 
40 #define READ_BYTE(setter) READ(setter,uchar,readByte)
41 #define READ_U16L(setter) READ(setter,ushort,readU16L)
42 #define READ_U32L(setter) READ(setter,ulong,readU32L)
43 #define READ_U16B(setter) READ(setter,ushort,readU16B)
44 #define READ_U32B(setter) READ(setter,ulong,readU32B)
45 
46 #define READ_STRING(setter,size) \
47  { \
48  String s; \
49  READ_ASSERT(readString(s, size)); \
50  setter(s); \
51  }
52 
53 #define READ_AS(type,name,read) \
54  type name = 0; \
55  READ_ASSERT(read(name));
56 
57 #define READ_BYTE_AS(name) READ_AS(uchar,name,readByte)
58 #define READ_U16L_AS(name) READ_AS(ushort,name,readU16L)
59 #define READ_U32L_AS(name) READ_AS(ulong,name,readU32L)
60 #define READ_U16B_AS(name) READ_AS(ushort,name,readU16B)
61 #define READ_U32B_AS(name) READ_AS(ulong,name,readU32B)
62 
63 #define READ_STRING_AS(name,size) \
64  String name; \
65  READ_ASSERT(readString(name, size));
66 
67 #endif