@@ -67,7 +67,6 @@ namespace seqan {
6767..include:seqan/gff_io.h
6868*/
6969
70- // TODO(singer): const should be non const, but is const elsewhere
7170struct TagGff_ ;
7271typedef Tag<TagGff_> Gff;
7372
@@ -88,7 +87,6 @@ typedef Tag<TagGff_> Gff;
8887..include:seqan/gff_io.h
8988*/
9089
91- // TODO(singer): const should be non const, but is const elsewhere
9290struct TagGtf_ ;
9391typedef Tag<TagGtf_> Gtf;
9492
@@ -306,11 +304,9 @@ template <typename TForwardIter, typename TKeyString, typename TValueString>
306304inline void
307305_parseReadGffKeyValue (TValueString & outValue, TKeyString & key, TForwardIter & iter)
308306{
309- IsWhitespace isWhitespace;
310-
311307 // TODO(singer): AssertList functor would be need
312308 char c = value (iter);
313- if (c == ' ' || c == ' \t ' || c == ' \n ' || c == ' =' )
309+ if (IsWhitespace ()(c) || c == ' =' )
314310 {
315311 throw std::runtime_error (" The key field of an attribute is empty!" );
316312 return ; // Key cannot be empty.
@@ -319,8 +315,7 @@ _parseReadGffKeyValue(TValueString & outValue, TKeyString & key, TForwardIter &
319315 for (; !atEnd (iter); goNext (iter))
320316 {
321317 c = value (iter);
322- // if (IsWhitespace(c) || c == '=' || c == ';')
323- if (c == ' \n ' || c == ' \r ' || c == ' ' || c == ' =' || c == ' ;' )
318+ if (IsNewline ()(c) || c == ' ' || c == ' =' || c == ' ;' )
324319 break ;
325320 appendValue (key, c);
326321 }
@@ -330,35 +325,35 @@ _parseReadGffKeyValue(TValueString & outValue, TKeyString & key, TForwardIter &
330325 return ;
331326 }
332327
333- if ( value (iter) == ' \r ' || value (iter) == ' \n ' )
328+ if ( IsNewline ()( value (iter)) )
334329 return ;
335330
336331 skipUntil (iter, NotFunctor<IsWhitespace>());
337332
338333 if (value (iter) == ' =' )
339334 {
340335 skipOne (iter);
336+ skipUntil (iter, NotFunctor<IsWhitespace>());
341337 }
342338
343339 if (value (iter) == ' "' )
344340 {
345341 // Handle the case of a string literal.
346342 skipOne (iter);
343+ skipUntil (iter, NotFunctor<IsWhitespace>());
347344 readUntil (outValue, iter, OrFunctor<EqualsChar<' "' >, AssertFunctor<NotFunctor<IsNewline>, ParseError, Gff> >());
348345 skipOne (iter);
349346
350347 // Go over the trailing semicolon and any trailing space.
351- while (!atEnd (iter) && (value (iter) == ' ;' || value (iter) == ' ' ))
352- goNext (iter);
348+ skipUntil (iter, NotFunctor<OrFunctor<EqualsChar<' ;' >, EqualsChar<' ' > > >());
353349 }
354350 else
355351 {
356352 // Read until the first semicolon, return at whitespace.
357353 readUntil (outValue, iter, OrFunctor<EqualsChar<' ;' >, IsNewline>());
358354
359355 // Skip semicolon and spaces if any.
360- while (!atEnd (iter) && (value (iter) == ' ;' || value (iter) == ' ' ))
361- goNext (iter);
356+ skipUntil (iter, NotFunctor<OrFunctor<EqualsChar<' ;' >, EqualsChar<' ' > > >());
362357 }
363358 return ;
364359}
@@ -430,8 +425,6 @@ inline void clear(GffRecord & record)
430425..include:seqan/gff_io.h
431426*/
432427
433- // TODO(singer): no checking if record is complete
434- // TODO(singer): no checking whether lexicalCast is working
435428template <typename TFwdIterator>
436429inline void
437430_readGffRecord (GffRecord & record, TFwdIterator & iter, GffContext & context)
@@ -483,31 +476,19 @@ _readGffRecord(GffRecord & record, TFwdIterator & iter, GffContext & context)
483476 skipOne (iter, IsTab ());
484477
485478 // read column 7: strand
486- // TODO(singer): readUntil taking a char would be good!
487- // TODO(singer): readOne
488- record.strand = value (iter);
489- if (record.strand != ' -' &&record.strand != ' +' )
490- {
491- record.strand = ' .' ;
492- }
493- skipOne (iter);
479+ readOne (record.strand , iter, OrFunctor<OrFunctor<EqualsChar<' -' >, EqualsChar<' +' > >, EqualsChar<' .' > >());
494480 skipOne (iter, IsTab ());
495481
496482 // read column 8: phase
497- record.phase = value (iter);
498- if (record.phase != ' 0' && record.phase != ' 1' && record.phase != ' 2' )
499- {
500- record.phase = ' .' ;
501- }
502- skipOne (iter);
503- skipOne (iter, IsTab ());
504-
483+ readOne (record.phase , iter, OrFunctor<OrFunctor<EqualsChar<' 0' >, EqualsChar<' 1' > >, OrFunctor<EqualsChar<' 2' >, EqualsChar<' .' > > >());
484+
505485 // It's fine if there are no attributes and the line ends here.
506486 if (atEnd (iter) || isNewline (value (iter)))
507487 {
508488 skipLine (iter);
509489 return ;
510490 }
491+ skipOne (iter, IsTab ());
511492
512493 // read column 9: attributes
513494 while (!atEnd (iter))
@@ -611,7 +592,7 @@ _writePossiblyInQuotes(TTarget& target, TString & source, TMustBeQuotedFunctor c
611592 for (TIter it = begin (source, Standard ()); it != itEnd; ++it)
612593 {
613594 // we have a problem if the string contains a '"' or a line break
614- if (*it == ' \n ' || *it == ' "' )
595+ if (value (it) ==' \n ' || value (it) == ' "' )
615596 throw std::runtime_error (" Attribute contains illegal character!" );
616597
617598 if (func (*it))
@@ -757,13 +738,9 @@ _writeRecordImpl(TTarget & target, GffRecord const & record, TSeqId const & ref,
757738
758739 // write column 2: source
759740 if (empty (record.source ))
760- {
761741 writeValue (target, ' .' );
762- }
763742 else
764- {
765743 write (target, record.source );
766- }
767744 writeValue (target, ' \t ' );
768745
769746 // write column 3: type
0 commit comments