clean up String/StringParse utility functions
String::splitOn family does not check if it succeeded in finding the split. The situation that the split occurs on the end of the string or did not occur at all can not be differentiated.
Furthermore, an 'accept' mode should remember which String was accepted. Maybe acceptIn(String&, ...)
(with ... the candidates). This is useful for timecache.cpp:136.
Should look at all the StringParse::splitOn applications, because these applications can have a different meaning with the latest patch, in which splitOn requires the split to occur.
Is splitOn really needed? Is span(to, !split).accept(split) the same as splitOn? In that case, we can potentially remove splitOn. Is the same for chars, not for strings!
How to deal with optional parsing? Maybe add flags to all operations with Matched(String&matchedString) and Optional(bool& succeeded) and SkipMatched() (for the splitOn).
Goals:
- easy of use
- readability
- correctness
Extra:
-
hou vorige 'matched' bij in StringParser object -
hou plek van error bij -
hou huidige StringParse::OptionalBlock bij (in Debug mode)
API:
-
String::parse() to start parsing -
expect(...), ignore case mode -
number(N&, min, max) -
having/span/while([Prefix&,] char expr) -
until([Prefix&,] String...) -
matched(String& matched) -
matchedLength(StringLength& length) -
skip (skip matched string) -
empty, nonEmpty, equals, notEquals, greater, less, in(T value, begin, end), in(T value, T... args) -
error (set default error to specific one) -
remaining -
position(int& error, int pos) -
beginOptional(StringParse::OptionalBlock&block), endOptional(StringParse::OptionalBlock&), in dit StringParse::OptionalBlock zit een success functie. Daarin wordt ook vorige StringParse opgeslagen. -
Maar ook error checking gedaan of huidige begin en eind klopt met elkaar (counting integer?). -
In debug mode moet StringParse::OptionalBlock ook een inUse bool hebben, die false moet zijn bij beginOptional.