Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASfpga
VILLASfpga
Commits
23f03192
Commit
23f03192
authored
Sep 20, 2018
by
Daniel Krebs
Browse files
utils: add string joining helper
parent
cad2103b
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/villas/utils.hpp
View file @
23f03192
...
...
@@ -9,6 +9,8 @@ namespace utils {
std
::
vector
<
std
::
string
>
tokenize
(
std
::
string
s
,
std
::
string
delimiter
);
std
::
string
join
(
std
::
vector
<
std
::
string
>
strings
,
std
::
string
delimiter
);
template
<
typename
T
>
void
...
...
lib/common/utils.cpp
View file @
23f03192
...
...
@@ -31,5 +31,24 @@ tokenize(std::string s, std::string delimiter)
return
tokens
;
}
std
::
string
join
(
std
::
vector
<
std
::
string
>
strings
,
std
::
string
delimiter
)
{
std
::
string
out
;
for
(
size_t
i
=
0
;
i
<
strings
.
size
();
i
++
)
{
const
auto
&
s
=
strings
[
i
];
if
(
s
.
length
()
>
0
)
{
out
+=
strings
[
i
];
if
(
i
<
(
strings
.
size
()
-
1
)
and
strings
[
i
+
1
].
length
()
>
0
)
out
+=
delimiter
;
}
}
return
out
;
}
}
// namespace utils
}
// namespace villas
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