Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ef68946e
Commit
ef68946e
authored
Dec 03, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CueParser: use class TagBuilder
parent
a5574f91
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
+27
-16
CueParser.cxx
src/cue/CueParser.cxx
+17
-14
CueParser.hxx
src/cue/CueParser.hxx
+10
-2
No files found.
src/cue/CueParser.cxx
View file @
ef68946e
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include <stdlib.h>
CueParser
::
CueParser
()
CueParser
::
CueParser
()
:
state
(
HEADER
),
header_tag
(
new
Tag
()),
:
state
(
HEADER
),
current
(
nullptr
),
current
(
nullptr
),
previous
(
nullptr
),
previous
(
nullptr
),
finished
(
nullptr
),
finished
(
nullptr
),
...
@@ -39,8 +39,6 @@ CueParser::CueParser()
...
@@ -39,8 +39,6 @@ CueParser::CueParser()
CueParser
::~
CueParser
()
CueParser
::~
CueParser
()
{
{
delete
header_tag
;
if
(
current
!=
nullptr
)
if
(
current
!=
nullptr
)
current
->
Free
();
current
->
Free
();
...
@@ -109,7 +107,7 @@ cue_next_value(char **pp)
...
@@ -109,7 +107,7 @@ cue_next_value(char **pp)
}
}
static
void
static
void
cue_add_tag
(
Tag
&
tag
,
TagType
type
,
char
*
p
)
cue_add_tag
(
Tag
Builder
&
tag
,
TagType
type
,
char
*
p
)
{
{
const
char
*
value
=
cue_next_value
(
&
p
);
const
char
*
value
=
cue_next_value
(
&
p
);
if
(
value
!=
nullptr
)
if
(
value
!=
nullptr
)
...
@@ -118,7 +116,7 @@ cue_add_tag(Tag &tag, TagType type, char *p)
...
@@ -118,7 +116,7 @@ cue_add_tag(Tag &tag, TagType type, char *p)
}
}
static
void
static
void
cue_parse_rem
(
char
*
p
,
Tag
&
tag
)
cue_parse_rem
(
char
*
p
,
Tag
Builder
&
tag
)
{
{
const
char
*
type
=
cue_next_token
(
&
p
);
const
char
*
type
=
cue_next_token
(
&
p
);
if
(
type
==
nullptr
)
if
(
type
==
nullptr
)
...
@@ -129,13 +127,13 @@ cue_parse_rem(char *p, Tag &tag)
...
@@ -129,13 +127,13 @@ cue_parse_rem(char *p, Tag &tag)
cue_add_tag
(
tag
,
type2
,
p
);
cue_add_tag
(
tag
,
type2
,
p
);
}
}
Tag
*
Tag
Builder
*
CueParser
::
GetCurrentTag
()
CueParser
::
GetCurrentTag
()
{
{
if
(
state
==
HEADER
)
if
(
state
==
HEADER
)
return
header_tag
;
return
&
header_tag
;
else
if
(
state
==
TRACK
)
else
if
(
state
==
TRACK
)
return
current
->
tag
;
return
&
song_
tag
;
else
else
return
nullptr
;
return
nullptr
;
}
}
...
@@ -172,6 +170,9 @@ CueParser::Commit()
...
@@ -172,6 +170,9 @@ CueParser::Commit()
if
(
current
==
nullptr
)
if
(
current
==
nullptr
)
return
;
return
;
assert
(
current
->
tag
==
nullptr
);
current
->
tag
=
song_tag
.
Commit
();
finished
=
previous
;
finished
=
previous
;
previous
=
current
;
previous
=
current
;
current
=
nullptr
;
current
=
nullptr
;
...
@@ -188,7 +189,7 @@ CueParser::Feed2(char *p)
...
@@ -188,7 +189,7 @@ CueParser::Feed2(char *p)
return
;
return
;
if
(
strcmp
(
command
,
"REM"
)
==
0
)
{
if
(
strcmp
(
command
,
"REM"
)
==
0
)
{
Tag
*
tag
=
GetCurrentTag
();
Tag
Builder
*
tag
=
GetCurrentTag
();
if
(
tag
!=
nullptr
)
if
(
tag
!=
nullptr
)
cue_parse_rem
(
p
,
*
tag
);
cue_parse_rem
(
p
,
*
tag
);
}
else
if
(
strcmp
(
command
,
"PERFORMER"
)
==
0
)
{
}
else
if
(
strcmp
(
command
,
"PERFORMER"
)
==
0
)
{
...
@@ -202,14 +203,14 @@ CueParser::Feed2(char *p)
...
@@ -202,14 +203,14 @@ CueParser::Feed2(char *p)
?
TAG_ARTIST
?
TAG_ARTIST
:
TAG_ALBUM_ARTIST
;
:
TAG_ALBUM_ARTIST
;
Tag
*
tag
=
GetCurrentTag
();
Tag
Builder
*
tag
=
GetCurrentTag
();
if
(
tag
!=
nullptr
)
if
(
tag
!=
nullptr
)
cue_add_tag
(
*
tag
,
type
,
p
);
cue_add_tag
(
*
tag
,
type
,
p
);
}
else
if
(
strcmp
(
command
,
"TITLE"
)
==
0
)
{
}
else
if
(
strcmp
(
command
,
"TITLE"
)
==
0
)
{
if
(
state
==
HEADER
)
if
(
state
==
HEADER
)
cue_add_tag
(
*
header_tag
,
TAG_ALBUM
,
p
);
cue_add_tag
(
header_tag
,
TAG_ALBUM
,
p
);
else
if
(
state
==
TRACK
)
else
if
(
state
==
TRACK
)
cue_add_tag
(
*
current
->
tag
,
TAG_TITLE
,
p
);
cue_add_tag
(
song_
tag
,
TAG_TITLE
,
p
);
}
else
if
(
strcmp
(
command
,
"FILE"
)
==
0
)
{
}
else
if
(
strcmp
(
command
,
"FILE"
)
==
0
)
{
Commit
();
Commit
();
...
@@ -251,8 +252,10 @@ CueParser::Feed2(char *p)
...
@@ -251,8 +252,10 @@ CueParser::Feed2(char *p)
state
=
TRACK
;
state
=
TRACK
;
current
=
Song
::
NewRemote
(
filename
.
c_str
());
current
=
Song
::
NewRemote
(
filename
.
c_str
());
assert
(
current
->
tag
==
nullptr
);
assert
(
current
->
tag
==
nullptr
);
current
->
tag
=
new
Tag
(
*
header_tag
);
current
->
tag
->
AddItem
(
TAG_TRACK
,
nr
);
song_tag
=
header_tag
;
song_tag
.
AddItem
(
TAG_TRACK
,
nr
);
last_updated
=
false
;
last_updated
=
false
;
}
else
if
(
state
==
IGNORE_TRACK
)
{
}
else
if
(
state
==
IGNORE_TRACK
)
{
return
;
return
;
...
...
src/cue/CueParser.hxx
View file @
ef68946e
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#define MPD_CUE_PARSER_HXX
#define MPD_CUE_PARSER_HXX
#include "check.h"
#include "check.h"
#include "tag/TagBuilder.hxx"
#include "Compiler.h"
#include "Compiler.h"
#include <string>
#include <string>
...
@@ -59,7 +60,14 @@ class CueParser {
...
@@ -59,7 +60,14 @@ class CueParser {
/**
/**
* Tags read from the CUE header.
* Tags read from the CUE header.
*/
*/
Tag
*
header_tag
;
TagBuilder
header_tag
;
/**
* Tags read for the current song (attribute #current). When
* #current gets moved to #previous, TagBuilder::Commit() will
* be called.
*/
TagBuilder
song_tag
;
std
::
string
filename
;
std
::
string
filename
;
...
@@ -121,7 +129,7 @@ public:
...
@@ -121,7 +129,7 @@ public:
private
:
private
:
gcc_pure
gcc_pure
Tag
*
GetCurrentTag
();
Tag
Builder
*
GetCurrentTag
();
/**
/**
* Commit the current song. It will be moved to "previous",
* Commit the current song. It will be moved to "previous",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment