PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/gme/M3u_Playlist.h

http://game-music-emu.googlecode.com/
C++ Header | 67 lines | 50 code | 11 blank | 6 comment | 0 complexity | 703cd3b2a7219e298829b74e901a1a51 MD5 | raw file
 1// M3U playlist file parser, with support for subtrack information
 2
 3// Game_Music_Emu 0.5.5
 4#ifndef M3U_PLAYLIST_H
 5#define M3U_PLAYLIST_H
 6
 7#include "blargg_common.h"
 8#include "Data_Reader.h"
 9
10class M3u_Playlist {
11public:
12	// Load playlist data
13	blargg_err_t load( const char* path );
14	blargg_err_t load( Data_Reader& in );
15	blargg_err_t load( void const* data, long size );
16	
17	// Line number of first parse error, 0 if no error. Any lines with parse
18	// errors are ignored.
19	int first_error() const { return first_error_; }
20	
21	struct info_t
22	{
23		const char* title;
24		const char* composer;
25		const char* engineer;
26		const char* ripping;
27		const char* tagging;
28	};
29	info_t const& info() const { return info_; }
30	
31	struct entry_t
32	{
33		const char* file; // filename without stupid ::TYPE suffix
34		const char* type; // if filename has ::TYPE suffix, this will be "TYPE". "" if none.
35		const char* name;
36		bool decimal_track; // true if track was specified in hex
37		// integers are -1 if not present
38		int track;  // 1-based
39		int length; // seconds
40		int intro;
41		int loop;
42		int fade;
43		int repeat; // count
44	};
45	entry_t const& operator [] ( int i ) const { return entries [i]; }
46	int size() const { return entries.size(); }
47	
48	void clear();
49	
50private:
51	blargg_vector<entry_t> entries;
52	blargg_vector<char> data;
53	int first_error_;
54	info_t info_;
55	
56	blargg_err_t parse();
57	blargg_err_t parse_();
58};
59
60inline void M3u_Playlist::clear()
61{
62	first_error_ = 0;
63	entries.clear();
64	data.clear();
65}
66
67#endif