libsidplayfp 2.15.0
stil.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 1998, 2002 by LaLa <LaLa@C64.org>
5 * Copyright 2012-2013 Leandro Nini <drfiemost@users.sourceforge.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22
23#ifndef STIL_H
24#define STIL_H
25
26#include <string>
27#include <algorithm>
28#include <map>
29#include <iosfwd>
30
31#include "stildefs.h"
32
45class STIL_EXTERN STIL
46{
47public:
48
51 {
52 all,
53 name,
54 author,
55 title,
56 artist,
57 comment
58 };
59
62 {
63 NO_STIL_ERROR = 0,
69 CRITICAL_STIL_ERROR = 10,
74 NO_BUG_DIRS
75 };
76
79
80 //----//
81
88 STIL(const char *stilPath = DEFAULT_PATH_TO_STIL, const char *bugsPath = DEFAULT_PATH_TO_BUGLIST);
89
102 const char *getVersion();
103
111 float getVersionNo();
112
125 bool setBaseDir(const char *pathToHVSC);
126
135 float getSTILVersionNo();
136
177 const char *getEntry(const char *relPathToEntry, int tuneNo = 0, STILField field = all);
178
183 const char *getAbsEntry(const char *absPathToEntry, int tuneNo = 0, STILField field = all);
184
201 const char *getGlobalComment(const char *relPathToEntry);
202
207 const char *getAbsGlobalComment(const char *absPathToEntry);
208
231 const char *getBug(const char *relPathToEntry, int tuneNo = 0);
232
237 const char *getAbsBug(const char *absPathToEntry, int tuneNo = 0);
238
246 inline STILerror getError() const {return (lastError);}
247
255 inline bool hasCriticalError() const
256 {
257 return ((lastError >= CRITICAL_STIL_ERROR) ? true : false);
258 }
259
268 inline const char *getErrorStr() const {return (STIL_ERROR_STR[lastError]);}
269
270private:
271 typedef std::map<std::string, std::streampos> dirList;
272
274 const char *PATH_TO_STIL;
275
277 const char *PATH_TO_BUGLIST;
278
280 std::string versionString;
281
283 float STILVersion;
284
286 std::string baseDir;
287
289
290 dirList stilDirs;
291 dirList bugDirs;
293
298 char STIL_EOL;
299 char STIL_EOL2;
300
302 STILerror lastError;
303
305 static const char *STIL_ERROR_STR[];
306
308
310 std::string entrybuf;
311
313 std::string globalbuf;
314
316 std::string bugbuf;
317
319 std::string resultEntry;
320 std::string resultBug;
321
323
324 void setVersionString();
325
334 bool determineEOL(std::ifstream &stilFile);
335
350 bool getDirs(std::ifstream &inFile, dirList &dirs, bool isSTILFile);
351
363 bool positionToEntry(const char *entryStr, std::ifstream &inFile, dirList &dirs);
364
373 void readEntry(std::ifstream &inFile, std::string &buffer);
374
392 bool getField(std::string &result, const char *buffer, int tuneNo = 0, STILField field = all);
393
406 bool getOneField(std::string &result, const char *start, const char *end, STILField field);
407
417 void getStilLine(std::ifstream &infile, std::string &line);
418};
419
420#endif // STIL_H
Definition stil.h:46
STILerror
Enum that describes the possible errors this class may encounter.
Definition stil.h:62
@ BUG_OPEN
INFO ONLY: failed to open BUGlist.txt.
Definition stil.h:64
@ BASE_DIR_LENGTH
The length of the HVSC base dir was wrong (empty string?)
Definition stil.h:70
@ WRONG_DIR
INFO ONLY: path was not within HVSC base dir.
Definition stil.h:65
@ STIL_OPEN
Failed to open STIL.txt.
Definition stil.h:71
@ NO_EOL
Failed to determine EOL char(s).
Definition stil.h:72
@ WRONG_ENTRY
INFO ONLY: section-global comment was asked for with get*Entry().
Definition stil.h:68
@ NOT_IN_STIL
INFO ONLY: requested entry was not found in STIL.txt.
Definition stil.h:66
@ NOT_IN_BUG
INFO ONLY: requested entry was not found in BUGlist.txt.
Definition stil.h:67
@ NO_STIL_DIRS
Failed to get sections (subdirs) when parsing STIL.txt.
Definition stil.h:73
STILField
Enum to use for asking for specific fields.
Definition stil.h:51
bool hasCriticalError() const
Definition stil.h:255
bool STIL_DEBUG
To turn debug output on.
Definition stil.h:78
const char * getErrorStr() const
Definition stil.h:268
STILerror getError() const
Definition stil.h:246