MPD  0.20.15
CueParser.hxx
Go to the documentation of this file.
1 /*
2  * Copyright 2003-2017 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef MPD_CUE_PARSER_HXX
21 #define MPD_CUE_PARSER_HXX
22 
23 #include "check.h"
24 #include "DetachedSong.hxx"
25 #include "tag/TagBuilder.hxx"
26 #include "Compiler.h"
27 
28 #include <string>
29 #include <memory>
30 
31 class CueParser {
32  enum {
36  HEADER,
37 
41  WAVE,
42 
46  IGNORE_FILE,
47 
51  TRACK,
52 
56  IGNORE_TRACK,
57  } state = HEADER;
58 
62  TagBuilder header_tag;
63 
69  TagBuilder song_tag;
70 
71  std::string filename;
72 
76  std::unique_ptr<DetachedSong> current;
77 
82  std::unique_ptr<DetachedSong> previous;
83 
88  std::unique_ptr<DetachedSong> finished;
89 
94  bool end = false;
95 
96 public:
101  void Feed(const char *line) noexcept;
102 
108  void Finish() noexcept;
109 
117  std::unique_ptr<DetachedSong> Get() noexcept;
118 
119 private:
120  gcc_pure
121  TagBuilder *GetCurrentTag() noexcept;
122 
128  void Commit() noexcept;
129 
130  void Feed2(char *p) noexcept;
131 };
132 
133 #endif
void Finish() noexcept
Tell the parser that the end of the file has been reached.
A class that constructs Tag objects.
Definition: TagBuilder.hxx:36
void Feed(const char *line) noexcept
Feed a text line from the CUE file into the parser.
std::unique_ptr< DetachedSong > Get() noexcept
Check if a song was finished by the last Feed() or Finish() call.
#define gcc_pure
Definition: Compiler.h:116