@@ -105,14 +105,12 @@ class DPLRawParser
105105 Iterator () = delete ;
106106
107107 Iterator (InputRecord& parent, input_iterator it, input_iterator end, std::vector<InputSpec> const & filterSpecs, fair::Severity sev = fair::Severity::alarm, size_t maxErrMsg = -1 , size_t * cntErrMsg = nullptr )
108- : mParent (parent), mInputIterator (it), mEnd (end), mPartIterator (mInputIterator .begin()), mParser (std::make_unique<parser_type>(reinterpret_cast <const char *>(&initializer), sizeof (initializer))), mCurrent (mParser ->begin ()), mFilterSpecs(filterSpecs), mMaxFailureMessages(maxErrMsg), mExtFailureCounter(cntErrMsg), mSeverity(sev)
108+ : mParent (parent), mInputIterator (it), mEnd (end), mCurrentRange (it.parts()), mPartIterator (mCurrentRange .begin()), mParser (std::make_unique<parser_type>(reinterpret_cast <const char *>(&initializer), sizeof (initializer))), mCurrent (mParser ->begin ()), mFilterSpecs(filterSpecs), mMaxFailureMessages(maxErrMsg), mExtFailureCounter(cntErrMsg), mSeverity(sev)
109109 {
110110 mParser .reset ();
111111 next ();
112112 }
113113
114- ~Iterator () = default ;
115-
116114 // prefix increment
117115 self_type& operator ++()
118116 {
@@ -205,7 +203,7 @@ class DPLRawParser
205203
206204 friend std::ostream& operator <<(std::ostream& os, self_type const & it)
207205 {
208- if (it.mInputIterator != it.mEnd && it.mPartIterator != it.mInputIterator .end () && it.mParser != nullptr ) {
206+ if (it.mInputIterator != it.mEnd && it.mPartIterator != it.mCurrentRange .end () && it.mParser != nullptr ) {
209207 os << it.mCurrent ;
210208 }
211209 return os;
@@ -223,7 +221,7 @@ class DPLRawParser
223221 friend std::ostream& operator <<(std::ostream& os, Fmt<FmtCtrl> const & fmt)
224222 {
225223 auto const & it = fmt.it ;
226- if (it.mInputIterator != it.mEnd && it.mPartIterator != it.mInputIterator .end () && it.mParser != nullptr ) {
224+ if (it.mInputIterator != it.mEnd && it.mPartIterator != it.mCurrentRange .end () && it.mParser != nullptr ) {
227225 if constexpr (FmtCtrl == raw_parser::FormatSpec::Info) {
228226 // TODO: need to propagate the format spec also on the RawParser object
229227 // for now this operation prints the RDH version info and the table header
@@ -236,8 +234,10 @@ class DPLRawParser
236234 }
237235
238236 private:
239- // the iterator over the parts in one channel
240- using part_iterator = typename input_iterator::const_iterator;
237+ // the range over parts in one slot — must be stored as a member so the
238+ // part_iterator (which holds a pointer into it) does not dangle
239+ using part_range = InputRecord::PartRange;
240+ using part_iterator = InputSpan::Iterator<part_range, const DataRef>;
241241 // the iterator over the over the parser pages
242242 using parser_iterator = typename parser_type::const_iterator;
243243
@@ -265,15 +265,15 @@ class DPLRawParser
265265
266266 while (mInputIterator != mEnd ) {
267267 bool isInitial = mParser == nullptr ;
268- while (mPartIterator != mInputIterator .end ()) {
268+ while (mPartIterator != mCurrentRange .end ()) {
269269 // first increment on the parser level
270270 if (mParser && mCurrent != mParser ->end () && ++mCurrent != mParser ->end ()) {
271271 // we have an active parser and there is still data at the incremented iterator
272272 return true ;
273273 }
274274 // now increment on the level of one input
275275 mParser .reset ();
276- if (!isInitial && ( mPartIterator == mInputIterator . end () || ++mPartIterator == mInputIterator .end () )) {
276+ if (!isInitial && ++mPartIterator == mCurrentRange .end ()) {
277277 // no more parts, go to next input
278278 break ;
279279 }
@@ -312,14 +312,16 @@ class DPLRawParser
312312 }
313313 } // end loop over parts on one input
314314 ++mInputIterator ;
315- mPartIterator = mInputIterator .begin ();
315+ mCurrentRange = mInputIterator .parts ();
316+ mPartIterator = mCurrentRange .begin ();
316317 } // end loop over inputs
317318 return false ;
318319 }
319320
320321 InputRecord& mParent ;
321322 input_iterator mInputIterator ;
322323 input_iterator mEnd ;
324+ part_range mCurrentRange ; // declared before mPartIterator — initialized first
323325 part_iterator mPartIterator ;
324326 std::unique_ptr<parser_type> mParser ;
325327 parser_iterator mCurrent ;
@@ -355,4 +357,4 @@ class DPLRawParser
355357
356358} // namespace o2::framework
357359
358- #endif // FRAMEWORK_UTILS_DPLRAWPARSER_H
360+ #endif // FRAMEWORK_UTILS_DPLRAWPARSER_H
0 commit comments