Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
compose
legacystack
cpp_tools
Commits
8e1b595a
Commit
8e1b595a
authored
Jul 26, 2021
by
ESTERIE Pierre
Browse files
Add support for vector of strings
parent
ac32a6e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
cl_parser/include/cpp_tools/cl_parser/tcli.hpp
View file @
8e1b595a
...
...
@@ -24,20 +24,44 @@ namespace cpp_tools::cl_parser
template
<
typename
ValueType
>
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
std
::
vector
<
ValueType
>
&
t
)
{
bool
first
=
true
;
double
val
;
char
delimiter
;
while
(
!
is
.
eof
())
bool
first
=
true
;
ValueType
val
;
char
delimiter
;
while
(
!
is
.
eof
())
{
// The first object is not delimited
first
?
(
first
=
false
)
:
((
is
>>
delimiter
),
true
);
// Get the value
is
>>
val
;
t
.
emplace_back
(
val
);
}
return
is
;
}
inline
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
std
::
vector
<
std
::
string
>&
t
)
{
char
val
{
'\0'
};
std
::
string
s
;
char
delimiter
{
','
};
while
(
!
is
.
eof
())
{
// Get the value
is
>>
val
;
s
.
push_back
(
val
);
if
(
val
==
delimiter
)
{
// The first object is not delimited
first
?
(
first
=
false
)
:
((
is
>>
delimiter
),
true
);
// Get the value
is
>>
val
;
t
.
emplace_back
(
val
);
s
.
erase
(
s
.
size
()
-
1
);
t
.
emplace_back
(
s
);
s
.
clear
();
}
return
is
;
}
/**
if
(
!
s
.
empty
())
{
t
.
emplace_back
(
s
);
}
return
is
;
}
/**
>>>>>>> 105ed9b (Add support for vector of strings)
* \brief Get container size
*/
template
<
class
C
>
...
...
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