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
5869a4ba
Commit
5869a4ba
authored
Feb 07, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/cue/CueParser: use std::unique_ptr
parent
ac9a9326
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
22 deletions
+12
-22
CueParser.cxx
src/playlist/cue/CueParser.cxx
+7
-17
CueParser.hxx
src/playlist/cue/CueParser.hxx
+5
-5
No files found.
src/playlist/cue/CueParser.cxx
View file @
5869a4ba
...
...
@@ -22,20 +22,12 @@
#include "util/Alloc.hxx"
#include "util/StringUtil.hxx"
#include "util/CharUtil.hxx"
#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
CueParser
::~
CueParser
()
{
delete
current
;
delete
previous
;
delete
finished
;
}
static
const
char
*
cue_next_word
(
char
*
p
,
char
**
pp
)
{
...
...
@@ -160,9 +152,9 @@ CueParser::Commit()
assert
(
!
current
->
GetTag
().
IsDefined
());
current
->
SetTag
(
song_tag
.
Commit
());
finished
=
previous
;
previous
=
current
;
current
=
nullptr
;
finished
=
std
::
move
(
previous
)
;
previous
=
std
::
move
(
current
)
;
current
.
reset
()
;
}
void
...
...
@@ -237,7 +229,7 @@ CueParser::Feed2(char *p)
}
state
=
TRACK
;
current
=
new
DetachedSong
(
filename
);
current
.
reset
(
new
DetachedSong
(
filename
)
);
assert
(
!
current
->
GetTag
().
IsDefined
());
song_tag
=
header_tag
;
...
...
@@ -297,11 +289,9 @@ CueParser::Get()
deliver all remaining (partial) results */
assert
(
current
==
nullptr
);
finished
=
previous
;
previous
=
nullptr
;
finished
=
std
::
move
(
previous
)
;
previous
.
reset
()
;
}
DetachedSong
*
song
=
finished
;
finished
=
nullptr
;
return
song
;
return
finished
.
release
();
}
src/playlist/cue/CueParser.hxx
View file @
5869a4ba
...
...
@@ -21,10 +21,12 @@
#define MPD_CUE_PARSER_HXX
#include "check.h"
#include "DetachedSong.hxx"
#include "tag/TagBuilder.hxx"
#include "Compiler.h"
#include <string>
#include <memory>
class
DetachedSong
;
struct
Tag
;
...
...
@@ -74,19 +76,19 @@ class CueParser {
/**
* The song currently being edited.
*/
DetachedSong
*
current
=
nullptr
;
std
::
unique_ptr
<
DetachedSong
>
current
;
/**
* The previous song. It is remembered because its end_time
* will be set to the current song's start time.
*/
DetachedSong
*
previous
=
nullptr
;
std
::
unique_ptr
<
DetachedSong
>
previous
;
/**
* A song that is completely finished and can be returned to
* the caller via cue_parser_get().
*/
DetachedSong
*
finished
=
nullptr
;
std
::
unique_ptr
<
DetachedSong
>
finished
;
/**
* Tracks whether cue_parser_finish() has been called. If
...
...
@@ -96,8 +98,6 @@ class CueParser {
bool
end
=
false
;
public
:
~
CueParser
();
/**
* Feed a text line from the CUE file into the parser. Call
* cue_parser_get() after this to see if a song has been finished.
...
...
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