[Feature] Improve uri handling.
[Khopper.git] / plugins / cuesheet / cuesheetparser.hpp
blob390eba1973ea69fc37ee895e23781bb095c07446
1 /**
2 * @file cuesheetparser.hpp
3 * @author Wei-Cheng Pan
5 * Copyright (C) 2008 Wei-Cheng Pan <legnaleurc@gmail.com>
7 * This file is part of Khopper.
9 * Khopper is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * Khopper is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef KHOPPER_ALBUM_CUESHEETPARSER_HPP
23 #define KHOPPER_ALBUM_CUESHEETPARSER_HPP
25 #include "cuesheet.hpp"
26 #include "cuesheettrack.hpp"
28 #include "khopper/error.hpp"
29 #include "khopper/playlist.hpp"
30 #include "khopper/track.hpp"
32 #include <QtCore/QDir>
33 #include <QtCore/QString>
35 #include <vector>
36 #include <string>
38 namespace khopper {
40 namespace album {
42 /**
43 * @brief The CUE parser
45 class CueSheetParser {
46 public:
47 static PlayList load( const QString & content, const QDir & dir );
49 private:
50 /**
51 * @brief Give a CUE Sheet content and create this object
52 * @param [in] content CHESheet content
53 * @param [in] dirPath where the CUE sheet comes from
54 * @throws ParsingError Invalid CUE format
55 * @throws CodecError Decode media error
56 * @throws IOError File not openable
58 CueSheetParser( const QString & content, const QDir & dir );
60 void parseCue_( QString, const QDir & );
61 void parseSingle_( const QString &, const QString & );
62 void parseFile_( const QString &, const QString &, const QDir & );
63 void parseFlags_( const QString & );
64 void parseIndex_( const QString &, const QString &, const QString &, const QString &, const QString & );
65 void parseComment_( const QString &, const QString & );
66 void parseTrack_( const QString &, const QString & );
67 void parseGarbage_( const QString & );
69 void updateLastTrack_();
71 /**
72 * @brief Set media file
73 * @param [in] filePath Audio path
74 * @throws CodecError Decode media error
75 * @throws IOError File not openable
77 //void setMedia_( const QUrl & uri );
79 PlayList playList_;
80 std::shared_ptr< CueSheet > album_;
81 QString currentFilePath_;
82 QString currentFileType_;
83 std::shared_ptr< CueSheetTrack > previousTrack_;
84 std::shared_ptr< CueSheetTrack > currentTrack_;
85 unsigned int trackIndex_;
90 namespace error {
92 /// Parsing error policy
93 class Parsing {};
94 /// Error on parsing
95 typedef Error< Parsing > ParsingError;
101 #endif