| ... | ... |
@@ -1130,27 +1130,27 @@ |
| 1130 | 1130 |
LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); |
| 1131 | 1131 |
if (!*_is) {
|
| 1132 | 1132 |
throw DataFormatError("Cannot find file");
|
| 1133 | 1133 |
} |
| 1134 | 1134 |
|
| 1135 | 1135 |
bool nodes_done = false; |
| 1136 | 1136 |
bool arcs_done = false; |
| 1137 | 1137 |
bool attributes_done = false; |
| 1138 | 1138 |
std::set<std::string> extra_sections; |
| 1139 | 1139 |
|
| 1140 | 1140 |
line_num = 0; |
| 1141 | 1141 |
readLine(); |
| 1142 |
skipSection(); |
|
| 1142 | 1143 |
|
| 1143 | 1144 |
while (readSuccess()) {
|
| 1144 |
skipSection(); |
|
| 1145 | 1145 |
try {
|
| 1146 | 1146 |
char c; |
| 1147 | 1147 |
std::string section, caption; |
| 1148 | 1148 |
line >> c; |
| 1149 | 1149 |
_reader_bits::readToken(line, section); |
| 1150 | 1150 |
_reader_bits::readToken(line, caption); |
| 1151 | 1151 |
|
| 1152 | 1152 |
if (line >> c) |
| 1153 | 1153 |
throw DataFormatError("Extra character on the end of line");
|
| 1154 | 1154 |
|
| 1155 | 1155 |
if (section == "nodes" && !nodes_done) {
|
| 1156 | 1156 |
if (_nodes_caption.empty() || _nodes_caption == caption) {
|
| ... | ... |
@@ -1169,29 +1169,27 @@ |
| 1169 | 1169 |
attributes_done = true; |
| 1170 | 1170 |
} |
| 1171 | 1171 |
} else {
|
| 1172 | 1172 |
if (extra_sections.find(section) != extra_sections.end()) {
|
| 1173 | 1173 |
std::ostringstream msg; |
| 1174 | 1174 |
msg << "Multiple occurence of section " << section; |
| 1175 | 1175 |
throw DataFormatError(msg.str().c_str()); |
| 1176 | 1176 |
} |
| 1177 | 1177 |
Sections::iterator it = _sections.find(section); |
| 1178 | 1178 |
if (it != _sections.end()) {
|
| 1179 | 1179 |
extra_sections.insert(section); |
| 1180 | 1180 |
it->second->process(*_is, line_num); |
| 1181 |
readLine(); |
|
| 1182 |
} else {
|
|
| 1183 |
readLine(); |
|
| 1184 |
skipSection(); |
|
| 1185 | 1181 |
} |
| 1182 |
readLine(); |
|
| 1183 |
skipSection(); |
|
| 1186 | 1184 |
} |
| 1187 | 1185 |
} catch (DataFormatError& error) {
|
| 1188 | 1186 |
error.line(line_num); |
| 1189 | 1187 |
throw; |
| 1190 | 1188 |
} |
| 1191 | 1189 |
} |
| 1192 | 1190 |
|
| 1193 | 1191 |
if (!nodes_done) {
|
| 1194 | 1192 |
throw DataFormatError("Section @nodes not found");
|
| 1195 | 1193 |
} |
| 1196 | 1194 |
|
| 1197 | 1195 |
if (!arcs_done) {
|
| ... | ... |
@@ -1972,27 +1970,27 @@ |
| 1972 | 1970 |
/// This function starts the batch processing |
| 1973 | 1971 |
void run() {
|
| 1974 | 1972 |
|
| 1975 | 1973 |
LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); |
| 1976 | 1974 |
|
| 1977 | 1975 |
bool nodes_done = false; |
| 1978 | 1976 |
bool edges_done = false; |
| 1979 | 1977 |
bool attributes_done = false; |
| 1980 | 1978 |
std::set<std::string> extra_sections; |
| 1981 | 1979 |
|
| 1982 | 1980 |
line_num = 0; |
| 1983 | 1981 |
readLine(); |
| 1982 |
skipSection(); |
|
| 1984 | 1983 |
|
| 1985 | 1984 |
while (readSuccess()) {
|
| 1986 |
skipSection(); |
|
| 1987 | 1985 |
try {
|
| 1988 | 1986 |
char c; |
| 1989 | 1987 |
std::string section, caption; |
| 1990 | 1988 |
line >> c; |
| 1991 | 1989 |
_reader_bits::readToken(line, section); |
| 1992 | 1990 |
_reader_bits::readToken(line, caption); |
| 1993 | 1991 |
|
| 1994 | 1992 |
if (line >> c) |
| 1995 | 1993 |
throw DataFormatError("Extra character on the end of line");
|
| 1996 | 1994 |
|
| 1997 | 1995 |
if (section == "nodes" && !nodes_done) {
|
| 1998 | 1996 |
if (_nodes_caption.empty() || _nodes_caption == caption) {
|
| ... | ... |
@@ -2011,29 +2009,27 @@ |
| 2011 | 2009 |
attributes_done = true; |
| 2012 | 2010 |
} |
| 2013 | 2011 |
} else {
|
| 2014 | 2012 |
if (extra_sections.find(section) != extra_sections.end()) {
|
| 2015 | 2013 |
std::ostringstream msg; |
| 2016 | 2014 |
msg << "Multiple occurence of section " << section; |
| 2017 | 2015 |
throw DataFormatError(msg.str().c_str()); |
| 2018 | 2016 |
} |
| 2019 | 2017 |
Sections::iterator it = _sections.find(section); |
| 2020 | 2018 |
if (it != _sections.end()) {
|
| 2021 | 2019 |
extra_sections.insert(section); |
| 2022 | 2020 |
it->second->process(*_is, line_num); |
| 2023 |
readLine(); |
|
| 2024 |
} else {
|
|
| 2025 |
readLine(); |
|
| 2026 |
skipSection(); |
|
| 2027 | 2021 |
} |
| 2022 |
readLine(); |
|
| 2023 |
skipSection(); |
|
| 2028 | 2024 |
} |
| 2029 | 2025 |
} catch (DataFormatError& error) {
|
| 2030 | 2026 |
error.line(line_num); |
| 2031 | 2027 |
throw; |
| 2032 | 2028 |
} |
| 2033 | 2029 |
} |
| 2034 | 2030 |
|
| 2035 | 2031 |
if (!nodes_done) {
|
| 2036 | 2032 |
throw DataFormatError("Section @nodes not found");
|
| 2037 | 2033 |
} |
| 2038 | 2034 |
|
| 2039 | 2035 |
if (!edges_done) {
|
0 comments (0 inline)