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
15c36bae
Commit
15c36bae
authored
Jul 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Data: add method FindBlock()
parent
33deb84a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
12 deletions
+25
-12
Data.cxx
src/config/Data.cxx
+20
-0
Data.hxx
src/config/Data.hxx
+4
-0
Global.cxx
src/config/Global.cxx
+1
-12
No files found.
src/config/Data.cxx
View file @
15c36bae
...
...
@@ -21,6 +21,8 @@
#include "Data.hxx"
#include "Param.hxx"
#include "Block.hxx"
#include "system/FatalError.hxx"
#include "util/StringAPI.hxx"
void
ConfigData
::
Clear
()
...
...
@@ -35,3 +37,21 @@ ConfigData::Clear()
i
=
nullptr
;
}
}
const
ConfigBlock
*
ConfigData
::
FindBlock
(
ConfigBlockOption
option
,
const
char
*
key
,
const
char
*
value
)
const
noexcept
{
for
(
const
auto
*
block
=
GetBlock
(
option
);
block
!=
nullptr
;
block
=
block
->
next
)
{
const
char
*
value2
=
block
->
GetBlockValue
(
key
);
if
(
value2
==
nullptr
)
FormatFatalError
(
"block without '%s' in line %d"
,
key
,
block
->
line
);
if
(
StringIsEqual
(
value2
,
value
))
return
block
;
}
return
nullptr
;
}
src/config/Data.hxx
View file @
15c36bae
...
...
@@ -42,6 +42,10 @@ struct ConfigData {
const
ConfigBlock
*
GetBlock
(
ConfigBlockOption
option
)
const
noexcept
{
return
blocks
[
size_t
(
option
)];
}
gcc_pure
const
ConfigBlock
*
FindBlock
(
ConfigBlockOption
option
,
const
char
*
key
,
const
char
*
value
)
const
noexcept
;
};
#endif
src/config/Global.cxx
View file @
15c36bae
...
...
@@ -89,18 +89,7 @@ config_get_block(ConfigBlockOption option) noexcept
const
ConfigBlock
*
config_find_block
(
ConfigBlockOption
option
,
const
char
*
key
,
const
char
*
value
)
{
for
(
const
auto
*
block
=
config_get_block
(
option
);
block
!=
nullptr
;
block
=
block
->
next
)
{
const
char
*
value2
=
block
->
GetBlockValue
(
key
);
if
(
value2
==
nullptr
)
FormatFatalError
(
"block without '%s' name in line %d"
,
key
,
block
->
line
);
if
(
strcmp
(
value2
,
value
)
==
0
)
return
block
;
}
return
nullptr
;
return
config_data
.
FindBlock
(
option
,
key
,
value
);
}
const
char
*
...
...
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