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
af33a9f4
Commit
af33a9f4
authored
Jul 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Block: allow moving name and value
parent
e9a45708
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
Block.hxx
src/config/Block.hxx
+9
-5
Configured.cxx
src/db/Configured.cxx
+3
-3
DumpDatabase.cxx
test/DumpDatabase.cxx
+1
-1
No files found.
src/config/Block.hxx
View file @
af33a9f4
...
...
@@ -40,9 +40,11 @@ struct BlockParam {
*/
mutable
bool
used
=
false
;
template
<
typename
N
,
typename
V
>
gcc_nonnull_all
BlockParam
(
const
char
*
_name
,
const
char
*
_value
,
int
_line
=-
1
)
:
name
(
_name
),
value
(
_value
),
line
(
_line
)
{}
BlockParam
(
N
&&
_name
,
V
&&
_value
,
int
_line
=-
1
)
noexcept
:
name
(
std
::
forward
<
N
>
(
_name
)),
value
(
std
::
forward
<
V
>
(
_value
)),
line
(
_line
)
{}
int
GetIntValue
()
const
;
...
...
@@ -92,10 +94,12 @@ struct ConfigBlock {
return
block_params
.
empty
();
}
template
<
typename
N
,
typename
V
>
gcc_nonnull_all
void
AddBlockParam
(
const
char
*
_name
,
const
char
*
_value
,
int
_line
=-
1
)
{
block_params
.
emplace_back
(
_name
,
_value
,
_line
);
void
AddBlockParam
(
N
&&
_name
,
V
&&
_value
,
int
_line
=-
1
)
noexcept
{
block_params
.
emplace_back
(
std
::
forward
<
N
>
(
_name
),
std
::
forward
<
V
>
(
_value
),
_line
);
}
gcc_nonnull_all
gcc_pure
...
...
src/db/Configured.cxx
View file @
af33a9f4
...
...
@@ -43,7 +43,7 @@ CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop,
listener
,
*
param
);
else
if
(
path
!=
nullptr
)
{
ConfigBlock
block
(
path
->
line
);
block
.
AddBlockParam
(
"path"
,
path
->
value
.
c_str
()
,
path
->
line
);
block
.
AddBlockParam
(
"path"
,
path
->
value
,
path
->
line
);
return
DatabaseGlobalInit
(
main_event_loop
,
io_event_loop
,
listener
,
block
);
}
else
{
...
...
@@ -54,12 +54,12 @@ CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop,
return
nullptr
;
const
auto
db_file
=
cache_dir
/
Path
::
FromFS
(
PATH_LITERAL
(
"mpd.db"
));
const
auto
db_file_utf8
=
db_file
.
ToUTF8
();
auto
db_file_utf8
=
db_file
.
ToUTF8
();
if
(
db_file_utf8
.
empty
())
return
nullptr
;
ConfigBlock
block
;
block
.
AddBlockParam
(
"path"
,
db_file_utf8
.
c_str
(
),
-
1
);
block
.
AddBlockParam
(
"path"
,
std
::
move
(
db_file_utf8
),
-
1
);
return
DatabaseGlobalInit
(
main_event_loop
,
io_event_loop
,
listener
,
block
);
}
...
...
test/DumpDatabase.cxx
View file @
af33a9f4
...
...
@@ -135,7 +135,7 @@ try {
const
auto
*
path
=
config_get_param
(
ConfigOption
::
DB_FILE
);
ConfigBlock
block
(
path
!=
nullptr
?
path
->
line
:
-
1
);
if
(
path
!=
nullptr
)
block
.
AddBlockParam
(
"path"
,
path
->
value
.
c_str
()
,
path
->
line
);
block
.
AddBlockParam
(
"path"
,
path
->
value
,
path
->
line
);
Database
*
db
=
plugin
->
create
(
init
.
GetEventLoop
(),
init
.
GetEventLoop
(),
...
...
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