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
57fb153c
Commit
57fb153c
authored
Apr 03, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/Interface: pass std::string_view to GetSong()
parent
212401d6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
20 deletions
+13
-20
Interface.hxx
src/db/Interface.hxx
+1
-1
Uri.hxx
src/db/Uri.hxx
+0
-6
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+3
-3
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+3
-5
SimpleDatabasePlugin.hxx
src/db/plugins/simple/SimpleDatabasePlugin.hxx
+1
-1
UpnpDatabasePlugin.cxx
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+5
-4
No files found.
src/db/Interface.hxx
View file @
57fb153c
...
...
@@ -75,7 +75,7 @@ public:
* directory (UTF-8)
* @return a pointer that must be released with ReturnSong()
*/
virtual
const
LightSong
*
GetSong
(
const
char
*
uri_utf8
)
const
=
0
;
virtual
const
LightSong
*
GetSong
(
std
::
string_view
uri_utf8
)
const
=
0
;
/**
* Mark the song object as "unused". Call this on objects
...
...
src/db/Uri.hxx
View file @
57fb153c
...
...
@@ -23,12 +23,6 @@
#include <string_view>
static
inline
bool
isRootDirectory
(
const
char
*
name
)
{
return
name
[
0
]
==
0
||
(
name
[
0
]
==
'/'
&&
name
[
1
]
==
0
);
}
static
inline
bool
isRootDirectory
(
std
::
string_view
name
)
noexcept
{
return
name
.
empty
()
||
(
name
.
size
()
==
1
&&
name
.
front
()
==
'/'
);
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
57fb153c
...
...
@@ -121,7 +121,7 @@ public:
void
Open
()
override
;
void
Close
()
noexcept
override
;
const
LightSong
*
GetSong
(
const
char
*
uri_utf8
)
const
override
;
const
LightSong
*
GetSong
(
std
::
string_view
uri_utf8
)
const
override
;
void
ReturnSong
(
const
LightSong
*
song
)
const
noexcept
override
;
void
Visit
(
const
DatabaseSelection
&
selection
,
...
...
@@ -641,12 +641,12 @@ ProxyDatabase::OnIdle() noexcept
}
const
LightSong
*
ProxyDatabase
::
GetSong
(
const
char
*
uri
)
const
ProxyDatabase
::
GetSong
(
std
::
string_view
uri
)
const
{
// TODO: eliminate the const_cast
const_cast
<
ProxyDatabase
*>
(
this
)
->
EnsureConnected
();
if
(
!
mpd_send_list_meta
(
connection
,
uri
))
if
(
!
mpd_send_list_meta
(
connection
,
std
::
string
(
uri
).
c_str
()
))
ThrowError
(
connection
);
struct
mpd_song
*
song
=
mpd_recv_song
(
connection
);
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
57fb153c
...
...
@@ -197,7 +197,7 @@ SimpleDatabase::Close() noexcept
}
const
LightSong
*
SimpleDatabase
::
GetSong
(
const
char
*
uri
)
const
SimpleDatabase
::
GetSong
(
std
::
string_view
uri
)
const
{
assert
(
root
!=
nullptr
);
assert
(
prefixed_light_song
==
nullptr
);
...
...
@@ -211,10 +211,8 @@ SimpleDatabase::GetSong(const char *uri) const
/* pass the request to the mounted database */
protect
.
unlock
();
/* note: r.rest.data() is actually null-terminated
because it points inside the "uri" parameter */
const
LightSong
*
song
=
r
.
directory
->
mounted_database
->
GetSong
(
r
.
rest
.
data
()
);
r
.
directory
->
mounted_database
->
GetSong
(
r
.
rest
);
if
(
song
==
nullptr
)
return
nullptr
;
...
...
@@ -224,7 +222,7 @@ SimpleDatabase::GetSong(const char *uri) const
return
prefixed_light_song
;
}
if
(
r
.
rest
.
data
()
==
nullptr
)
if
(
r
.
rest
.
empty
()
)
/* it's a directory */
throw
DatabaseError
(
DatabaseErrorCode
::
NOT_FOUND
,
"No such song"
);
...
...
src/db/plugins/simple/SimpleDatabasePlugin.hxx
View file @
57fb153c
...
...
@@ -114,7 +114,7 @@ public:
void
Open
()
override
;
void
Close
()
noexcept
override
;
const
LightSong
*
GetSong
(
const
char
*
uri_utf8
)
const
override
;
const
LightSong
*
GetSong
(
std
::
string_view
uri_utf8
)
const
override
;
void
ReturnSong
(
const
LightSong
*
song
)
const
noexcept
override
;
void
Visit
(
const
DatabaseSelection
&
selection
,
...
...
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
View file @
57fb153c
...
...
@@ -62,8 +62,9 @@ class UpnpSong : UpnpSongData, public LightSong {
std
::
string
real_uri2
;
public
:
UpnpSong
(
UPnPDirObject
&&
object
,
std
::
string
&&
_uri
)
noexcept
:
UpnpSongData
(
std
::
move
(
_uri
),
std
::
move
(
object
.
tag
)),
template
<
typename
U
>
UpnpSong
(
UPnPDirObject
&&
object
,
U
&&
_uri
)
noexcept
:
UpnpSongData
(
std
::
forward
<
U
>
(
_uri
),
std
::
move
(
object
.
tag
)),
LightSong
(
UpnpSongData
::
uri
.
c_str
(),
UpnpSongData
::
tag
),
real_uri2
(
std
::
move
(
object
.
url
))
{
real_uri
=
real_uri2
.
c_str
();
...
...
@@ -87,7 +88,7 @@ public:
void
Open
()
override
;
void
Close
()
noexcept
override
;
const
LightSong
*
GetSong
(
const
char
*
uri_utf8
)
const
override
;
const
LightSong
*
GetSong
(
std
::
string_view
uri_utf8
)
const
override
;
void
ReturnSong
(
const
LightSong
*
song
)
const
noexcept
override
;
void
Visit
(
const
DatabaseSelection
&
selection
,
...
...
@@ -185,7 +186,7 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const noexcept
// Get song info by path. We can receive either the id path, or the titles
// one
const
LightSong
*
UpnpDatabase
::
GetSong
(
const
char
*
uri
)
const
UpnpDatabase
::
GetSong
(
std
::
string_view
uri
)
const
{
auto
vpath
=
SplitString
(
uri
,
'/'
);
if
(
vpath
.
empty
())
...
...
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