# HG changeset patch # User deba # Date 1116421367 0 # Node ID 14c75970840e58961e6b4774dbcd69e50fd4912d # Parent 91eb709836973bd738ed7a603f5743d77333d37f Two minor changes. DefaultReader comment lines diff -r 91eb70983697 -r 14c75970840e src/lemon/bits/item_reader.h --- a/src/lemon/bits/item_reader.h Wed May 18 09:39:06 2005 +0000 +++ b/src/lemon/bits/item_reader.h Wed May 18 13:02:47 2005 +0000 @@ -341,6 +341,30 @@ } }; + template <> + class DefaultReader { + public: + typedef std::string Value; + + void read(std::istream& is, Value& value) const { + char c; + if (!(is >> c)) return; + is.putback(c); + switch (c) { + case '\"': + QuotedStringReader().read(is, value); + break; + case '(': + ParsedStringReader().read(is, value); + break; + default: + is >> value; + break; + } + } + + }; + template class DefaultReader > : public PushBackReader > {}; @@ -368,27 +392,7 @@ /// The default item reader for skipping a value in the stream. /// /// \author Balazs Dezso - class DefaultSkipper { - public: - typedef std::string Value; - - void read(std::istream& is, Value& value) const { - char c; - if (!(is >> c)) return; - is.putback(c); - switch (c) { - case '\"': - QuotedStringReader().read(is, value); - break; - case '(': - ParsedStringReader().read(is, value); - break; - default: - DefaultReader().read(is, value); - break; - } - } - }; + class DefaultSkipper : public DefaultReader {}; /// \ingroup item_io /// \brief Standard ReaderTraits for the GraphReader class. diff -r 91eb70983697 -r 14c75970840e src/lemon/lemon_reader.h --- a/src/lemon/lemon_reader.h Wed May 18 09:39:06 2005 +0000 +++ b/src/lemon/lemon_reader.h Wed May 18 13:02:47 2005 +0000 @@ -99,8 +99,8 @@ /// header line of the section. Each next lines belong to this section /// while it does not starts with \c \@ character. This line can start a /// new section or if it can close the file with the \c \@end line. - /// The file format ignore the empty lines and it may contain comments - /// started with a \c # character to the end of the line. + /// The file format ignore the empty and comment lines. The line is + /// comment line if it starts with a \c # character. /// /// The framework provides an abstract LemonReader::SectionReader class /// what defines the interface of a SectionReader. The SectionReader @@ -108,8 +108,8 @@ /// decides if it want to process the next section. Several SectionReaders /// can be attached to an LemonReader and the first attached what can /// process the section will be used. Its \c read() member will called - /// with a stream contains the section. From this stream the empty lines - /// and comments are filtered out. + /// with a stream contains the section. From this stream the empty and + /// comment lines are filtered out. /// /// \relates GraphReader /// \relates NodeSetReader @@ -133,9 +133,8 @@ enum skip_state_type { no_skip, - after_comment, after_endl, - empty_line + comment_line }; char_type small_buf[1]; @@ -180,20 +179,9 @@ case '\n': skip_state = after_endl; return true; - case '#': - skip_state = after_comment; - return false; default: return true; } - case after_comment: - switch (c) { - case '\n': - skip_state = after_endl; - return true; - default: - return false; - } case after_endl: switch (c) { case '@': @@ -201,7 +189,7 @@ case '\n': return false; case '#': - skip_state = empty_line; + skip_state = comment_line; return false; default: if (!isspace(c)) { @@ -212,7 +200,7 @@ } } break; - case empty_line: + case comment_line: switch (c) { case '\n': skip_state = after_endl;