diff --git a/include/ss/parser.hpp b/include/ss/parser.hpp index ab9dfc7..b73ccf5 100644 --- a/include/ss/parser.hpp +++ b/include/ss/parser.hpp @@ -90,6 +90,12 @@ class parser { : values_{values}, parser_{parser} { } + // tries to convert the same line as different output if the + // previous conversion was not successful, returns composite + // containing itself and the new output as optional + // if a parameter is passed which can be invoked with + // the new output, it will be invoked if the returned value + // of the conversion is valid template composite>> or_else(Fun&& fun = None{}) { @@ -112,6 +118,8 @@ class parser { return {std::move(values), parser_}; } + auto values() { return values_; } + private: template no_void_validator_tup_t try_same() { @@ -128,6 +136,8 @@ class parser { parser& parser_; }; + // tries to convert a line, but returns a composite which is + // able to chain additional conversions in case of failure template composite>> try_next( Fun&& fun = None{}) {