... | ... |
@@ -849,49 +849,51 @@ |
849 | 849 |
private: |
850 | 850 |
|
851 | 851 |
bool readLine() { |
852 | 852 |
std::string str; |
853 | 853 |
while(++line_num, std::getline(*_is, str)) { |
854 | 854 |
line.clear(); line.str(str); |
855 | 855 |
char c; |
856 | 856 |
if (line >> std::ws >> c && c != '#') { |
857 | 857 |
line.putback(c); |
858 | 858 |
return true; |
859 | 859 |
} |
860 | 860 |
} |
861 | 861 |
return false; |
862 | 862 |
} |
863 | 863 |
|
864 | 864 |
bool readSuccess() { |
865 | 865 |
return static_cast<bool>(*_is); |
866 | 866 |
} |
867 | 867 |
|
868 | 868 |
void skipSection() { |
869 | 869 |
char c; |
870 | 870 |
while (readSuccess() && line >> c && c != '@') { |
871 | 871 |
readLine(); |
872 | 872 |
} |
873 |
|
|
873 |
if (readSuccess()) { |
|
874 |
line.putback(c); |
|
875 |
} |
|
874 | 876 |
} |
875 | 877 |
|
876 | 878 |
void readNodes() { |
877 | 879 |
|
878 | 880 |
std::vector<int> map_index(_node_maps.size()); |
879 | 881 |
int map_num, label_index; |
880 | 882 |
|
881 | 883 |
char c; |
882 | 884 |
if (!readLine() || !(line >> c) || c == '@') { |
883 | 885 |
if (readSuccess() && line) line.putback(c); |
884 | 886 |
if (!_node_maps.empty()) |
885 | 887 |
throw FormatError("Cannot find map names"); |
886 | 888 |
return; |
887 | 889 |
} |
888 | 890 |
line.putback(c); |
889 | 891 |
|
890 | 892 |
{ |
891 | 893 |
std::map<std::string, int> maps; |
892 | 894 |
|
893 | 895 |
std::string map; |
894 | 896 |
int index = 0; |
895 | 897 |
while (_reader_bits::readToken(line, map)) { |
896 | 898 |
if (maps.find(map) != maps.end()) { |
897 | 899 |
std::ostringstream msg; |
... | ... |
@@ -1678,49 +1680,51 @@ |
1678 | 1680 |
private: |
1679 | 1681 |
|
1680 | 1682 |
bool readLine() { |
1681 | 1683 |
std::string str; |
1682 | 1684 |
while(++line_num, std::getline(*_is, str)) { |
1683 | 1685 |
line.clear(); line.str(str); |
1684 | 1686 |
char c; |
1685 | 1687 |
if (line >> std::ws >> c && c != '#') { |
1686 | 1688 |
line.putback(c); |
1687 | 1689 |
return true; |
1688 | 1690 |
} |
1689 | 1691 |
} |
1690 | 1692 |
return false; |
1691 | 1693 |
} |
1692 | 1694 |
|
1693 | 1695 |
bool readSuccess() { |
1694 | 1696 |
return static_cast<bool>(*_is); |
1695 | 1697 |
} |
1696 | 1698 |
|
1697 | 1699 |
void skipSection() { |
1698 | 1700 |
char c; |
1699 | 1701 |
while (readSuccess() && line >> c && c != '@') { |
1700 | 1702 |
readLine(); |
1701 | 1703 |
} |
1702 |
|
|
1704 |
if (readSuccess()) { |
|
1705 |
line.putback(c); |
|
1706 |
} |
|
1703 | 1707 |
} |
1704 | 1708 |
|
1705 | 1709 |
void readNodes() { |
1706 | 1710 |
|
1707 | 1711 |
std::vector<int> map_index(_node_maps.size()); |
1708 | 1712 |
int map_num, label_index; |
1709 | 1713 |
|
1710 | 1714 |
char c; |
1711 | 1715 |
if (!readLine() || !(line >> c) || c == '@') { |
1712 | 1716 |
if (readSuccess() && line) line.putback(c); |
1713 | 1717 |
if (!_node_maps.empty()) |
1714 | 1718 |
throw FormatError("Cannot find map names"); |
1715 | 1719 |
return; |
1716 | 1720 |
} |
1717 | 1721 |
line.putback(c); |
1718 | 1722 |
|
1719 | 1723 |
{ |
1720 | 1724 |
std::map<std::string, int> maps; |
1721 | 1725 |
|
1722 | 1726 |
std::string map; |
1723 | 1727 |
int index = 0; |
1724 | 1728 |
while (_reader_bits::readToken(line, map)) { |
1725 | 1729 |
if (maps.find(map) != maps.end()) { |
1726 | 1730 |
std::ostringstream msg; |
... | ... |
@@ -2205,49 +2209,51 @@ |
2205 | 2209 |
private: |
2206 | 2210 |
|
2207 | 2211 |
bool readLine() { |
2208 | 2212 |
std::string str; |
2209 | 2213 |
while(++line_num, std::getline(*_is, str)) { |
2210 | 2214 |
line.clear(); line.str(str); |
2211 | 2215 |
char c; |
2212 | 2216 |
if (line >> std::ws >> c && c != '#') { |
2213 | 2217 |
line.putback(c); |
2214 | 2218 |
return true; |
2215 | 2219 |
} |
2216 | 2220 |
} |
2217 | 2221 |
return false; |
2218 | 2222 |
} |
2219 | 2223 |
|
2220 | 2224 |
bool readSuccess() { |
2221 | 2225 |
return static_cast<bool>(*_is); |
2222 | 2226 |
} |
2223 | 2227 |
|
2224 | 2228 |
void skipSection() { |
2225 | 2229 |
char c; |
2226 | 2230 |
while (readSuccess() && line >> c && c != '@') { |
2227 | 2231 |
readLine(); |
2228 | 2232 |
} |
2229 |
|
|
2233 |
if (readSuccess()) { |
|
2234 |
line.putback(c); |
|
2235 |
} |
|
2230 | 2236 |
} |
2231 | 2237 |
|
2232 | 2238 |
public: |
2233 | 2239 |
|
2234 | 2240 |
|
2235 | 2241 |
/// \name Execution of the reader |
2236 | 2242 |
/// @{ |
2237 | 2243 |
|
2238 | 2244 |
/// \brief Start the batch processing |
2239 | 2245 |
/// |
2240 | 2246 |
/// This function starts the batch processing. |
2241 | 2247 |
void run() { |
2242 | 2248 |
|
2243 | 2249 |
LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); |
2244 | 2250 |
|
2245 | 2251 |
std::set<std::string> extra_sections; |
2246 | 2252 |
|
2247 | 2253 |
line_num = 0; |
2248 | 2254 |
readLine(); |
2249 | 2255 |
skipSection(); |
2250 | 2256 |
|
2251 | 2257 |
while (readSuccess()) { |
2252 | 2258 |
try { |
2253 | 2259 |
char c; |
... | ... |
@@ -2546,49 +2552,51 @@ |
2546 | 2552 |
private: |
2547 | 2553 |
|
2548 | 2554 |
bool readLine() { |
2549 | 2555 |
std::string str; |
2550 | 2556 |
while(++line_num, std::getline(*_is, str)) { |
2551 | 2557 |
line.clear(); line.str(str); |
2552 | 2558 |
char c; |
2553 | 2559 |
if (line >> std::ws >> c && c != '#') { |
2554 | 2560 |
line.putback(c); |
2555 | 2561 |
return true; |
2556 | 2562 |
} |
2557 | 2563 |
} |
2558 | 2564 |
return false; |
2559 | 2565 |
} |
2560 | 2566 |
|
2561 | 2567 |
bool readSuccess() { |
2562 | 2568 |
return static_cast<bool>(*_is); |
2563 | 2569 |
} |
2564 | 2570 |
|
2565 | 2571 |
void skipSection() { |
2566 | 2572 |
char c; |
2567 | 2573 |
while (readSuccess() && line >> c && c != '@') { |
2568 | 2574 |
readLine(); |
2569 | 2575 |
} |
2570 |
|
|
2576 |
if (readSuccess()) { |
|
2577 |
line.putback(c); |
|
2578 |
} |
|
2571 | 2579 |
} |
2572 | 2580 |
|
2573 | 2581 |
void readMaps(std::vector<std::string>& maps) { |
2574 | 2582 |
char c; |
2575 | 2583 |
if (!readLine() || !(line >> c) || c == '@') { |
2576 | 2584 |
if (readSuccess() && line) line.putback(c); |
2577 | 2585 |
return; |
2578 | 2586 |
} |
2579 | 2587 |
line.putback(c); |
2580 | 2588 |
std::string map; |
2581 | 2589 |
while (_reader_bits::readToken(line, map)) { |
2582 | 2590 |
maps.push_back(map); |
2583 | 2591 |
} |
2584 | 2592 |
} |
2585 | 2593 |
|
2586 | 2594 |
void readAttributes(std::vector<std::string>& attrs) { |
2587 | 2595 |
readLine(); |
2588 | 2596 |
char c; |
2589 | 2597 |
while (readSuccess() && line >> c && c != '@') { |
2590 | 2598 |
line.putback(c); |
2591 | 2599 |
std::string attr; |
2592 | 2600 |
_reader_bits::readToken(line, attr); |
2593 | 2601 |
attrs.push_back(attr); |
2594 | 2602 |
readLine(); |
0 comments (0 inline)