diff options
author | Moritz Pflanzer <moritz.pflanzer@arm.com> | 2017-09-01 12:56:06 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 014fb63fdd21afa772dd3086553a741f9f55c543 (patch) | |
tree | d778d9e76123308d0e88a1ec29314af9942b43e2 /framework/command_line/EnumListOption.h | |
parent | cbc5a13fe813664740a2970fb35b5950ea492654 (diff) | |
download | ComputeLibrary-014fb63fdd21afa772dd3086553a741f9f55c543.tar.gz |
COMPMID-415: Fix list commandline options
Change-Id: I72f2552cc9809d4c5b053733b8e326c5aed72bc0
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/86115
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'framework/command_line/EnumListOption.h')
-rw-r--r-- | framework/command_line/EnumListOption.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/framework/command_line/EnumListOption.h b/framework/command_line/EnumListOption.h index 41c5b6ee85..d19bfbdc0f 100644 --- a/framework/command_line/EnumListOption.h +++ b/framework/command_line/EnumListOption.h @@ -85,17 +85,21 @@ bool EnumListOption<T>::parse(std::string value) { // Remove default values _values.clear(); + _is_set = true; try { std::stringstream stream{ value }; - T typed_value{}; + std::string item; - while(stream.good()) + while(!std::getline(stream, item, ',').fail()) { - stream >> typed_value; + std::stringstream item_stream(item); + T typed_value{}; - if(!stream.fail()) + item_stream >> typed_value; + + if(!item_stream.fail()) { if(_allowed_values.count(typed_value) == 0) { @@ -106,14 +110,9 @@ bool EnumListOption<T>::parse(std::string value) _values.emplace_back(typed_value); } - if(!stream.eof()) - { - stream.ignore(1, ','); - } + _is_set = _is_set && !item_stream.fail(); } - _is_set = !stream.fail(); - return _is_set; } catch(const std::invalid_argument &) @@ -133,7 +132,7 @@ std::string EnumListOption<T>::help() const msg << value << ","; } - msg << "} - " << _help; + msg << "}[,{...}[,...]] - " << _help; return msg.str(); } |