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
f98bf390
Commit
f98bf390
authored
Sep 12, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Util/IterableSplitString: add template class BasicIterableSplitString
parent
9e7df54c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
IterableSplitString.hxx
src/util/IterableSplitString.hxx
+15
-8
No files found.
src/util/IterableSplitString.hxx
View file @
f98bf390
...
...
@@ -42,23 +42,28 @@
*
* An empty input string returns one empty string.
*/
class
IterableSplitString
{
StringView
s
;
template
<
typename
T
>
class
BasicIterableSplitString
{
typedef
BasicStringView
<
T
>
StringView
;
typedef
typename
StringView
::
value_type
value_type
;
char
separator
;
StringView
s
;
value_type
separator
;
public
:
constexpr
IterableSplitString
(
StringView
_s
,
char
_separator
)
constexpr
BasicIterableSplitString
(
StringView
_s
,
value_type
_separator
)
:
s
(
_s
),
separator
(
_separator
)
{}
class
Iterator
final
{
friend
class
IterableSplitString
;
friend
class
Basic
IterableSplitString
;
StringView
current
,
rest
;
char
separator
;
value_type
separator
;
Iterator
(
StringView
_s
,
char
_separator
)
Iterator
(
StringView
_s
,
value_type
_separator
)
:
rest
(
_s
),
separator
(
_separator
)
{
Next
();
}
...
...
@@ -70,7 +75,7 @@ public:
if
(
rest
.
IsNull
())
current
=
nullptr
;
else
{
const
char
*
i
=
rest
.
Find
(
separator
);
const
auto
*
i
=
rest
.
Find
(
separator
);
if
(
i
==
nullptr
)
{
current
=
rest
;
rest
.
data
=
nullptr
;
...
...
@@ -120,4 +125,6 @@ public:
}
};
using
IterableSplitString
=
BasicIterableSplitString
<
char
>
;
#endif
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