Implemented playlist storage
[someplayer] / src / filestorage.h
1 #ifndef FILE_STORAGE
2 #define FILE_STORAGE
3
4 #include "someplayer.h"
5 #include "storage.h"
6 #include "playlist.h"
7 #include <QRegExp>
8
9 #define _CURRENT_PLAYLIST_NAME_ "___current"
10 #define _PLAYLIST_FILE_EXTENSION_ "spls"
11 #define _PLAYLIST_SIGNATURE_ "#SOMEPLAYLIST"
12 #define _PLAYLIST_META_KEYWORD_ "#META"
13 #define _PLAYLIST_PATH_KEYWORD_ "#PATH"
14
15 // format:
16 /*
17  #SOMEPLAYLIST
18  #META [seconds],::artist::,::album::,::title::
19  #PATH file_path
20  #META [seconds],::artist::,::album::,::title::
21  #PATH file_path
22  ...
23  */
24
25 // represents file-level storage
26 // it store data into separate files (e.g. playlist)
27
28 using SomePlayer::DataObjects::Playlist;
29
30 namespace SomePlayer {
31         namespace Storage {
32
33                 class FileStorage {
34                 public:
35                         FileStorage(QString path);
36
37                         QList<Playlist> getPlaylists();
38                         QStringList getPlaylistsNames();
39                         Playlist getPlaylist(QString name);
40                         void savePlaylist(Playlist playlist);
41                         void removePlaylist(Playlist playlist);
42                         void removePlaylist(QString name);
43
44                         Playlist getCurrentPlaylist();
45                         void saveCurrentPlaylist(Playlist playlist);
46                 private:
47                         QString _path_prefix;
48                         QRegExp _meta_regexp;
49                         QRegExp _path_regexp;
50                 };
51
52         };
53 };
54
55 #endif