Parser for flexible number list specifications.
This utility class parses string representations of number lists that combine three different notations:
- (i) Space-separated integers: "1 3 7 14"
- (ii) Range notation: "13-27" generates 13, 14, 15, ..., 26, 27
- (iii) Sequence notation: "10:20:2" generates 10, 12, 14, 16, 18, 20
These forms can be combined in a single string, e.g., "1 5-8 10:20:2" produces [1, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20].
Use cases: Specifying run numbers, histogram lists, or parameter indices on command line or in configuration files.
Definition at line 1399 of file PMusr.h.
| bool PStringNumberList::Parse |
( |
std::string & | errorMsg, |
|
|
bool | ignoreFirstToken = false ) |
|
virtual |
Parses the input string and generates the number list.
- Parameters
-
| errorMsg | Reference to string that will contain error message if parsing fails |
| ignoreFirstToken | If true, skips the first space-separated token (useful when first token is a label) |
- Returns
- true if parsing succeeded, false on error
Helper class which parses list of numbers of the following 3 forms and its combination. (i) list of integers separted by spaces, e.g. 1 3 7 14 (ii) a range of integers of the form nS-nE, e.g. 13-27 which will generate 13, 14, 15, .., 26, 27 (iii) a sequence of integers of the form nS:nE:nStep, e.g. 10:20:2 which will generate 10, 12, 14, .., 18, 20
- Parameters
-
| errorMsg | error message |
| ignoreFirstToken | if true, the first parse token will be ignored |
- Returns
- true if parse has been successful, otherwise false
Definition at line 2007 of file PMusr.cpp.
References fList, fString, IsNumber(), and StripSpaces().
Referenced by addRun_filter_runList(), and main().