Two minor changes.
DefaultReader<std::string>
comment lines
1.1 --- a/src/lemon/bits/item_reader.h Wed May 18 09:39:06 2005 +0000
1.2 +++ b/src/lemon/bits/item_reader.h Wed May 18 13:02:47 2005 +0000
1.3 @@ -341,6 +341,30 @@
1.4 }
1.5 };
1.6
1.7 + template <>
1.8 + class DefaultReader<std::string> {
1.9 + public:
1.10 + typedef std::string Value;
1.11 +
1.12 + void read(std::istream& is, Value& value) const {
1.13 + char c;
1.14 + if (!(is >> c)) return;
1.15 + is.putback(c);
1.16 + switch (c) {
1.17 + case '\"':
1.18 + QuotedStringReader().read(is, value);
1.19 + break;
1.20 + case '(':
1.21 + ParsedStringReader().read(is, value);
1.22 + break;
1.23 + default:
1.24 + is >> value;
1.25 + break;
1.26 + }
1.27 + }
1.28 +
1.29 + };
1.30 +
1.31 template <typename Item>
1.32 class DefaultReader<std::vector<Item> >
1.33 : public PushBackReader<std::vector<Item> > {};
1.34 @@ -368,27 +392,7 @@
1.35 /// The default item reader for skipping a value in the stream.
1.36 ///
1.37 /// \author Balazs Dezso
1.38 - class DefaultSkipper {
1.39 - public:
1.40 - typedef std::string Value;
1.41 -
1.42 - void read(std::istream& is, Value& value) const {
1.43 - char c;
1.44 - if (!(is >> c)) return;
1.45 - is.putback(c);
1.46 - switch (c) {
1.47 - case '\"':
1.48 - QuotedStringReader().read(is, value);
1.49 - break;
1.50 - case '(':
1.51 - ParsedStringReader().read(is, value);
1.52 - break;
1.53 - default:
1.54 - DefaultReader<std::string>().read(is, value);
1.55 - break;
1.56 - }
1.57 - }
1.58 - };
1.59 + class DefaultSkipper : public DefaultReader<std::string> {};
1.60
1.61 /// \ingroup item_io
1.62 /// \brief Standard ReaderTraits for the GraphReader class.
2.1 --- a/src/lemon/lemon_reader.h Wed May 18 09:39:06 2005 +0000
2.2 +++ b/src/lemon/lemon_reader.h Wed May 18 13:02:47 2005 +0000
2.3 @@ -99,8 +99,8 @@
2.4 /// header line of the section. Each next lines belong to this section
2.5 /// while it does not starts with \c \@ character. This line can start a
2.6 /// new section or if it can close the file with the \c \@end line.
2.7 - /// The file format ignore the empty lines and it may contain comments
2.8 - /// started with a \c # character to the end of the line.
2.9 + /// The file format ignore the empty and comment lines. The line is
2.10 + /// comment line if it starts with a \c # character.
2.11 ///
2.12 /// The framework provides an abstract LemonReader::SectionReader class
2.13 /// what defines the interface of a SectionReader. The SectionReader
2.14 @@ -108,8 +108,8 @@
2.15 /// decides if it want to process the next section. Several SectionReaders
2.16 /// can be attached to an LemonReader and the first attached what can
2.17 /// process the section will be used. Its \c read() member will called
2.18 - /// with a stream contains the section. From this stream the empty lines
2.19 - /// and comments are filtered out.
2.20 + /// with a stream contains the section. From this stream the empty and
2.21 + /// comment lines are filtered out.
2.22 ///
2.23 /// \relates GraphReader
2.24 /// \relates NodeSetReader
2.25 @@ -133,9 +133,8 @@
2.26
2.27 enum skip_state_type {
2.28 no_skip,
2.29 - after_comment,
2.30 after_endl,
2.31 - empty_line
2.32 + comment_line
2.33 };
2.34
2.35 char_type small_buf[1];
2.36 @@ -180,20 +179,9 @@
2.37 case '\n':
2.38 skip_state = after_endl;
2.39 return true;
2.40 - case '#':
2.41 - skip_state = after_comment;
2.42 - return false;
2.43 default:
2.44 return true;
2.45 }
2.46 - case after_comment:
2.47 - switch (c) {
2.48 - case '\n':
2.49 - skip_state = after_endl;
2.50 - return true;
2.51 - default:
2.52 - return false;
2.53 - }
2.54 case after_endl:
2.55 switch (c) {
2.56 case '@':
2.57 @@ -201,7 +189,7 @@
2.58 case '\n':
2.59 return false;
2.60 case '#':
2.61 - skip_state = empty_line;
2.62 + skip_state = comment_line;
2.63 return false;
2.64 default:
2.65 if (!isspace(c)) {
2.66 @@ -212,7 +200,7 @@
2.67 }
2.68 }
2.69 break;
2.70 - case empty_line:
2.71 + case comment_line:
2.72 switch (c) {
2.73 case '\n':
2.74 skip_state = after_endl;