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
6e47e797
Commit
6e47e797
authored
Jan 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfigData: move functions into the class
parent
d9ea3082
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
38 deletions
+37
-38
ConfigData.cxx
src/ConfigData.cxx
+19
-22
ConfigData.hxx
src/ConfigData.hxx
+12
-8
ConfigFile.cxx
src/ConfigFile.cxx
+2
-2
Main.cxx
src/Main.cxx
+1
-2
DumpDatabase.cxx
test/DumpDatabase.cxx
+1
-2
run_encoder.cxx
test/run_encoder.cxx
+1
-1
test_vorbis_encoder.cxx
test/test_vorbis_encoder.cxx
+1
-1
No files found.
src/ConfigData.cxx
View file @
6e47e797
...
...
@@ -39,22 +39,10 @@ config_param::~config_param()
g_free
(
value
);
}
void
config_add_block_param
(
struct
config_param
*
param
,
const
char
*
name
,
const
char
*
value
,
int
line
)
const
block_param
*
config_param
::
GetBlockParam
(
const
char
*
name
)
const
{
assert
(
config_get_block_param
(
param
,
name
)
==
NULL
);
param
->
block_params
.
emplace_back
(
name
,
value
,
line
);
}
const
struct
block_param
*
config_get_block_param
(
const
struct
config_param
*
param
,
const
char
*
name
)
{
if
(
param
==
NULL
)
return
NULL
;
for
(
auto
&
i
:
param
->
block_params
)
{
for
(
const
auto
&
i
:
block_params
)
{
if
(
i
.
name
==
name
)
{
i
.
used
=
true
;
return
&
i
;
...
...
@@ -68,8 +56,10 @@ const char *
config_get_block_string
(
const
struct
config_param
*
param
,
const
char
*
name
,
const
char
*
default_value
)
{
const
struct
block_param
*
bp
=
config_get_block_param
(
param
,
name
);
if
(
param
==
nullptr
)
return
default_value
;
const
block_param
*
bp
=
param
->
GetBlockParam
(
name
);
if
(
bp
==
NULL
)
return
default_value
;
...
...
@@ -90,7 +80,10 @@ config_dup_block_path(const struct config_param *param, const char *name,
assert
(
error_r
!=
NULL
);
assert
(
*
error_r
==
NULL
);
const
struct
block_param
*
bp
=
config_get_block_param
(
param
,
name
);
if
(
param
==
nullptr
)
return
nullptr
;
const
block_param
*
bp
=
param
->
GetBlockParam
(
name
);
if
(
bp
==
NULL
)
return
NULL
;
...
...
@@ -107,14 +100,15 @@ unsigned
config_get_block_unsigned
(
const
struct
config_param
*
param
,
const
char
*
name
,
unsigned
default_value
)
{
const
struct
block_param
*
bp
=
config_get_block_param
(
param
,
name
);
long
value
;
char
*
endptr
;
if
(
param
==
nullptr
)
return
default_value
;
const
block_param
*
bp
=
param
->
GetBlockParam
(
name
);
if
(
bp
==
NULL
)
return
default_value
;
value
=
strtol
(
bp
->
value
.
c_str
(),
&
endptr
,
0
);
char
*
endptr
;
long
value
=
strtol
(
bp
->
value
.
c_str
(),
&
endptr
,
0
);
if
(
*
endptr
!=
0
)
MPD_ERROR
(
"Not a valid number in line %i"
,
bp
->
line
);
...
...
@@ -128,7 +122,10 @@ bool
config_get_block_bool
(
const
struct
config_param
*
param
,
const
char
*
name
,
bool
default_value
)
{
const
struct
block_param
*
bp
=
config_get_block_param
(
param
,
name
);
if
(
param
==
nullptr
)
return
default_value
;
const
block_param
*
bp
=
param
->
GetBlockParam
(
name
);
bool
success
,
value
;
if
(
bp
==
NULL
)
...
...
src/ConfigData.hxx
View file @
6e47e797
...
...
@@ -68,8 +68,20 @@ struct config_param {
config_param
(
int
_line
=-
1
)
:
value
(
nullptr
),
line
(
_line
),
used
(
false
)
{}
gcc_nonnull_all
config_param
(
const
char
*
_value
,
int
_line
=-
1
);
~
config_param
();
gcc_nonnull_all
void
AddBlockParam
(
const
char
*
_name
,
const
char
*
_value
,
int
_line
=-
1
)
{
block_params
.
emplace_back
(
_name
,
_value
,
_line
);
}
gcc_nonnull_all
gcc_pure
const
block_param
*
GetBlockParam
(
const
char
*
_name
)
const
;
#endif
};
...
...
@@ -85,14 +97,6 @@ struct ConfigData {
extern
"C"
{
#endif
void
config_add_block_param
(
struct
config_param
*
param
,
const
char
*
name
,
const
char
*
value
,
int
line
);
gcc_pure
const
struct
block_param
*
config_get_block_param
(
const
struct
config_param
*
param
,
const
char
*
name
);
gcc_pure
const
char
*
config_get_block_string
(
const
struct
config_param
*
param
,
const
char
*
name
,
...
...
src/ConfigFile.cxx
View file @
6e47e797
...
...
@@ -75,7 +75,7 @@ config_read_name_value(struct config_param *param, char *input, unsigned line,
return
false
;
}
const
struct
block_param
*
bp
=
config_get_block_param
(
param
,
name
);
const
struct
block_param
*
bp
=
param
->
GetBlockParam
(
name
);
if
(
bp
!=
NULL
)
{
g_set_error
(
error_r
,
config_quark
(),
0
,
"
\"
%s
\"
is duplicate, first defined on line %i"
,
...
...
@@ -83,7 +83,7 @@ config_read_name_value(struct config_param *param, char *input, unsigned line,
return
false
;
}
config_add_block_param
(
param
,
name
,
value
,
line
);
param
->
AddBlockParam
(
name
,
value
,
line
);
return
true
;
}
...
...
src/Main.cxx
View file @
6e47e797
...
...
@@ -190,8 +190,7 @@ glue_db_init_and_load(void)
if
(
param
==
NULL
&&
path
!=
NULL
)
{
allocated
=
new
config_param
(
"database"
,
path
->
line
);
config_add_block_param
(
allocated
,
"path"
,
path
->
value
,
path
->
line
);
allocated
->
AddBlockParam
(
"path"
,
path
->
value
,
path
->
line
);
param
=
allocated
;
}
...
...
test/DumpDatabase.cxx
View file @
6e47e797
...
...
@@ -108,8 +108,7 @@ main(int argc, char **argv)
const
struct
config_param
*
path
=
config_get_param
(
CONF_DB_FILE
);
config_param
param
(
"database"
,
path
->
line
);
if
(
path
!=
nullptr
)
config_add_block_param
(
&
param
,
"path"
,
path
->
value
,
path
->
line
);
param
.
AddBlockParam
(
"path"
,
path
->
value
,
path
->
line
);
Database
*
db
=
plugin
->
create
(
&
param
,
&
error
);
...
...
test/run_encoder.cxx
View file @
6e47e797
...
...
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
}
config_param
param
;
config_add_block_param
(
&
param
,
"quality"
,
"5.0"
,
-
1
);
param
.
AddBlockParam
(
"quality"
,
"5.0"
,
-
1
);
encoder
=
encoder_init
(
plugin
,
&
param
,
&
error
);
if
(
encoder
==
NULL
)
{
...
...
test/test_vorbis_encoder.cxx
View file @
6e47e797
...
...
@@ -54,7 +54,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
assert
(
plugin
!=
NULL
);
config_param
param
;
config_add_block_param
(
&
param
,
"quality"
,
"5.0"
,
-
1
);
param
.
AddBlockParam
(
"quality"
,
"5.0"
,
-
1
);
struct
encoder
*
encoder
=
encoder_init
(
plugin
,
&
param
,
NULL
);
assert
(
encoder
!=
NULL
);
...
...
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