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
e7eb0495
Commit
e7eb0495
authored
Jan 10, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp/Directory: don't use std::map to parse upnp:class
Reduce excessive bloat.
parent
09b00fa4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
Directory.cxx
src/db/upnp/Directory.cxx
+18
-9
No files found.
src/db/upnp/Directory.cxx
View file @
e7eb0495
...
...
@@ -37,6 +37,18 @@ static const char *const upnptags[] = {
};
static
const
int
nupnptags
=
sizeof
(
upnptags
)
/
sizeof
(
char
*
);
gcc_pure
static
UPnPDirObject
::
ItemClass
ParseItemClass
(
const
char
*
name
)
{
if
(
strcmp
(
name
,
"object.item.audioItem.musicTrack"
)
==
0
)
return
UPnPDirObject
::
ItemClass
::
MUSIC
;
else
if
(
strcmp
(
name
,
"object.item.playlistItem"
)
==
0
)
return
UPnPDirObject
::
ItemClass
::
PLAYLIST
;
else
return
UPnPDirObject
::
ItemClass
::
UNKNOWN
;
}
/**
* An XML parser which builds directory contents from DIDL lite input.
*/
...
...
@@ -49,16 +61,11 @@ class UPnPDirParser final : public CommonExpatParser {
std
::
vector
<
StackEl
>
m_path
;
UPnPDirObject
m_tobj
;
std
::
map
<
std
::
string
,
UPnPDirObject
::
ItemClass
>
m_okitems
;
public
:
UPnPDirParser
(
UPnPDirContent
&
dir
)
:
m_dir
(
dir
)
{
m_okitems
[
"object.item.audioItem.musicTrack"
]
=
UPnPDirObject
::
ItemClass
::
MUSIC
;
m_okitems
[
"object.item.playlistItem"
]
=
UPnPDirObject
::
ItemClass
::
PLAYLIST
;
}
UPnPDirContent
&
m_dir
;
...
...
@@ -97,13 +104,15 @@ protected:
!
m_tobj
.
m_title
.
empty
();
if
(
ok
&&
m_tobj
.
type
==
UPnPDirObject
::
Type
::
ITEM
)
{
auto
it
=
m_okitems
.
find
(
m_tobj
.
m_props
[
"upnp:class"
]);
if
(
it
==
m_okitems
.
end
())
{
const
char
*
item_class_name
=
m_tobj
.
m_props
[
"upnp:class"
].
c_str
();
auto
item_class
=
ParseItemClass
(
item_class_name
);
if
(
item_class
==
UPnPDirObject
::
ItemClass
::
UNKNOWN
)
{
PLOGINF
(
"checkobjok: found object of unknown class: [%s]
\n
"
,
m_tobj
.
m_props
[
"upnp:class"
].
c_str
()
);
item_class_name
);
ok
=
false
;
}
else
{
m_tobj
.
item_class
=
it
->
second
;
m_tobj
.
item_class
=
it
em_class
;
}
}
...
...
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