| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <regex> | ||
| 2 | #include <iostream> | ||
| 3 | |||
| 4 | namespace na64dp { | ||
| 5 | namespace nameutils { | ||
| 6 | |||
| 7 | // This regex fits usual TBname + "extended" TBnames used by NA64sw. Usual ones | ||
| 8 | // are typical notions of detector stations, like MM03X or ECAL0. Extended | ||
| 9 | // has payloads after `:` or `-` sign. This regex, however, does not allow to | ||
| 10 | // mix this -- expression like MM03X:14 will not pass, but MM03:X14 or MM03X | ||
| 11 | // will do. | ||
| 12 | const std::regex gNameRx("^([A-Z]+)(\\d{1,2})?[:-]?([^\\d\\W]?[\\w-]*)?$"); | ||
| 13 | const int gNameGroupNo = 1 | ||
| 14 | , gStatNumGroupNo = 2 | ||
| 15 | , gPayloadGroupNo = 3 | ||
| 16 | ; | ||
| 17 | |||
| 18 | bool | ||
| 19 | 21 | tokenize_name_str( const std::string & str | |
| 20 | , std::string & detName | ||
| 21 | , std::string & number | ||
| 22 | , std::string & payload ) { | ||
| 23 | 21 | std::smatch m; | |
| 24 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 2 times.
|
21 | if( std::regex_match(str, m, gNameRx) ) { |
| 25 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | detName = m[gNameGroupNo].str(); |
| 26 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | number = m[gStatNumGroupNo].str(); |
| 27 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | payload = m[gPayloadGroupNo].str(); |
| 28 | 19 | return true; | |
| 29 | } | ||
| 30 | 2 | return false; | |
| 31 | 21 | } | |
| 32 | |||
| 33 | |||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 |