| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | # include "na64util/na64/event-id.hh" | ||
| 2 | # include "na64util/str-fmt.hh" | ||
| 3 | |||
| 4 | namespace na64dp { | ||
| 5 | |||
| 6 | std::string | ||
| 7 | 3 | EventID::to_str() const { | |
| 8 | char bf[128]; | ||
| 9 |
1/1✓ Branch 1 taken 3 times.
|
3 | na64sw_eid2str( _eid, bf, sizeof(bf) ); |
| 10 |
1/1✓ Branch 1 taken 3 times.
|
6 | return bf; |
| 11 | } | ||
| 12 | |||
| 13 | std::ostream & | ||
| 14 | ✗ | operator<<( std::ostream & stream, const EventID & eid ) { | |
| 15 | ✗ | stream << eid.to_str(); | |
| 16 | ✗ | return stream; | |
| 17 | } | ||
| 18 | |||
| 19 | EventID | ||
| 20 | 1 | EventID::from_str( const std::string & stlString ) { | |
| 21 | char * endPtr; | ||
| 22 |
1/1✓ Branch 2 taken 1 times.
|
1 | na64sw_EventID_t eid = na64sw_str2eid( stlString.c_str(), &endPtr ); |
| 23 |
1/1✓ Branch 1 taken 1 times.
|
1 | if( na64sw_get_reservedBit(eid) |
| 24 | ✗ | && 0 == na64sw_get_runNo(eid) | |
| 25 | ✗ | && 0 == na64sw_get_spillNo(eid) | |
| 26 |
2/5✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
|
1 | && 0 == na64sw_get_eventNo(eid) |
| 27 | ) { | ||
| 28 | std::string substring( stlString.begin() | ||
| 29 | ✗ | , stlString.begin() + (endPtr - stlString.data()) ); | |
| 30 | // TODO: dedicated exception class | ||
| 31 | ✗ | NA64DP_RUNTIME_ERROR( "Unable to interpret string \"%s\" as an event ID." | |
| 32 | , substring.c_str() ); | ||
| 33 | } | ||
| 34 | 1 | return EventID(eid); | |
| 35 | } | ||
| 36 | |||
| 37 | namespace util { | ||
| 38 | |||
| 39 | 35 | void reset( EventID & eid ) { | |
| 40 | 35 | eid = EventID(); | |
| 41 | 35 | } | |
| 42 | |||
| 43 | } | ||
| 44 | |||
| 45 | } // namespace na64 | ||
| 46 | |||
| 47 |