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
b50d7954
Commit
b50d7954
authored
Jan 11, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp: move stringToTokens() to Util.cxx
parent
8351543c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
36 deletions
+44
-36
UpnpDatabasePlugin.cxx
src/db/UpnpDatabasePlugin.cxx
+1
-36
Util.cxx
src/db/upnp/Util.cxx
+35
-0
Util.hxx
src/db/upnp/Util.hxx
+8
-0
No files found.
src/db/UpnpDatabasePlugin.cxx
View file @
b50d7954
...
...
@@ -24,6 +24,7 @@
#include "upnp/Discovery.hxx"
#include "upnp/ContentDirectoryService.hxx"
#include "upnp/Directory.hxx"
#include "upnp/Util.hxx"
#include "LazyDatabase.hxx"
#include "DatabasePlugin.hxx"
#include "DatabaseSelection.hxx"
...
...
@@ -146,42 +147,6 @@ private:
Error
&
error
)
const
;
};
gcc_pure
static
std
::
vector
<
std
::
string
>
stringToTokens
(
const
std
::
string
&
str
,
const
char
*
delims
=
"/"
,
bool
skipinit
=
true
)
{
std
::
vector
<
std
::
string
>
tokens
;
std
::
string
::
size_type
startPos
=
0
;
// Skip initial delims, return empty if this eats all.
if
(
skipinit
&&
(
startPos
=
str
.
find_first_not_of
(
delims
,
0
))
==
std
::
string
::
npos
)
return
tokens
;
while
(
startPos
<
str
.
size
())
{
// Find next delimiter or end of string (end of token)
auto
pos
=
str
.
find_first_of
(
delims
,
startPos
);
// Add token to the vector and adjust start
if
(
pos
==
std
::
string
::
npos
)
{
tokens
.
push_back
(
str
.
substr
(
startPos
));
break
;
}
else
if
(
pos
==
startPos
)
{
// Dont' push empty tokens after first
if
(
tokens
.
empty
())
tokens
.
push_back
(
std
::
string
());
startPos
=
++
pos
;
}
else
{
tokens
.
push_back
(
str
.
substr
(
startPos
,
pos
-
startPos
));
startPos
=
++
pos
;
}
}
return
tokens
;
}
Database
*
UpnpDatabase
::
Create
(
gcc_unused
EventLoop
&
loop
,
gcc_unused
DatabaseListener
&
listener
,
...
...
src/db/upnp/Util.cxx
View file @
b50d7954
...
...
@@ -89,6 +89,41 @@ path_getfather(const std::string &s)
return
father
;
}
std
::
vector
<
std
::
string
>
stringToTokens
(
const
std
::
string
&
str
,
const
char
*
delims
,
bool
skipinit
)
{
std
::
vector
<
std
::
string
>
tokens
;
std
::
string
::
size_type
startPos
=
0
;
// Skip initial delims, return empty if this eats all.
if
(
skipinit
&&
(
startPos
=
str
.
find_first_not_of
(
delims
,
0
))
==
std
::
string
::
npos
)
return
tokens
;
while
(
startPos
<
str
.
size
())
{
// Find next delimiter or end of string (end of token)
auto
pos
=
str
.
find_first_of
(
delims
,
startPos
);
// Add token to the vector and adjust start
if
(
pos
==
std
::
string
::
npos
)
{
tokens
.
push_back
(
str
.
substr
(
startPos
));
break
;
}
else
if
(
pos
==
startPos
)
{
// Dont' push empty tokens after first
if
(
tokens
.
empty
())
tokens
.
push_back
(
std
::
string
());
startPos
=
++
pos
;
}
else
{
tokens
.
push_back
(
str
.
substr
(
startPos
,
pos
-
startPos
));
startPos
=
++
pos
;
}
}
return
tokens
;
}
template
<
class
T
>
bool
csvToStrings
(
const
std
::
string
&
s
,
T
&
tokens
)
...
...
src/db/upnp/Util.hxx
View file @
b50d7954
...
...
@@ -20,7 +20,10 @@
#ifndef MPD_UPNP_UTIL_HXX
#define MPD_UPNP_UTIL_HXX
#include "Compiler.h"
#include <string>
#include <vector>
std
::
string
caturl
(
const
std
::
string
&
s1
,
const
std
::
string
&
s2
);
...
...
@@ -31,6 +34,11 @@ trimstring(std::string &s, const char *ws = " \t\n");
std
::
string
path_getfather
(
const
std
::
string
&
s
);
gcc_pure
std
::
vector
<
std
::
string
>
stringToTokens
(
const
std
::
string
&
str
,
const
char
*
delims
=
"/"
,
bool
skipinit
=
true
);
template
<
class
T
>
bool
csvToStrings
(
const
std
::
string
&
s
,
T
&
tokens
);
...
...
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