TagLib API Documentation
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 do { \
28 if(!(cond)) { \
29 setValid(false); \
30 return; \
31 } \
32 } while(0)
33
34#define READ(setter, type, read) \
35 do { \
36 type number; \
37 READ_ASSERT(read(number)); \
38 setter(number); \
39 } while(0)
40
41#define READ_BYTE(setter) READ(setter, unsigned char, readByte)
42#define READ_U16L(setter) READ(setter, unsigned short, readU16L)
43#define READ_U32L(setter) READ(setter, unsigned long, readU32L)
44#define READ_U16B(setter) READ(setter, unsigned short, readU16B)
45#define READ_U32B(setter) READ(setter, unsigned long, readU32B)
46
47#define READ_STRING(setter, size) \
48 do { \
49 String s; \
50 READ_ASSERT(readString(s, size)); \
51 setter(s); \
52 } while(0)
53
54#define READ_AS(type, name, read) \
55 type name = 0; \
56 READ_ASSERT(read(name))
57
58#define READ_BYTE_AS(name) READ_AS(unsigned char, name, readByte)
59#define READ_U16L_AS(name) READ_AS(unsigned short, name, readU16L)
60#define READ_U32L_AS(name) READ_AS(unsigned long, name, readU32L)
61#define READ_U16B_AS(name) READ_AS(unsigned short, name, readU16B)
62#define READ_U32B_AS(name) READ_AS(unsigned long, name, readU32B)
63
64#define READ_STRING_AS(name, size) \
65 String name; \
66 READ_ASSERT(readString(name, size))
67#endif