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
d6553fc6
Commit
d6553fc6
authored
Oct 19, 2013
by
Sebastian Thorarensen
Committed by
Max Kellermann
Oct 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfigData: Add support for signed integers
Now config_param::GetBlockValue() can be used to get signed integers from the configuration.
parent
fc9014f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
ConfigData.cxx
src/ConfigData.cxx
+21
-0
ConfigData.hxx
src/ConfigData.hxx
+6
-0
No files found.
src/ConfigData.cxx
View file @
d6553fc6
...
...
@@ -29,6 +29,17 @@
#include <string.h>
#include <stdlib.h>
int
block_param
::
GetIntValue
()
const
{
char
*
endptr
;
long
value2
=
strtol
(
value
.
c_str
(),
&
endptr
,
0
);
if
(
*
endptr
!=
0
)
FormatFatalError
(
"Not a valid number in line %i"
,
line
);
return
value2
;
}
unsigned
block_param
::
GetUnsignedValue
()
const
{
...
...
@@ -120,6 +131,16 @@ config_param::GetBlockPath(const char *name, Error &error) const
return
GetBlockPath
(
name
,
nullptr
,
error
);
}
int
config_param
::
GetBlockValue
(
const
char
*
name
,
int
default_value
)
const
{
const
block_param
*
bp
=
GetBlockParam
(
name
);
if
(
bp
==
nullptr
)
return
default_value
;
return
bp
->
GetIntValue
();
}
unsigned
config_param
::
GetBlockValue
(
const
char
*
name
,
unsigned
default_value
)
const
{
...
...
src/ConfigData.hxx
View file @
d6553fc6
...
...
@@ -46,6 +46,9 @@ struct block_param {
:
name
(
_name
),
value
(
_value
),
line
(
_line
),
used
(
false
)
{}
gcc_pure
int
GetIntValue
()
const
;
gcc_pure
unsigned
GetUnsignedValue
()
const
;
gcc_pure
...
...
@@ -115,6 +118,9 @@ struct config_param {
AllocatedPath
GetBlockPath
(
const
char
*
name
,
Error
&
error
)
const
;
gcc_pure
int
GetBlockValue
(
const
char
*
name
,
int
default_value
)
const
;
gcc_pure
unsigned
GetBlockValue
(
const
char
*
name
,
unsigned
default_value
)
const
;
gcc_pure
...
...
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