0
4
0
... | ... |
@@ -42,9 +42,9 @@ |
42 | 42 |
class Exception : public std::exception { |
43 | 43 |
public: |
44 |
///\e Constructor |
|
45 |
Exception() {} |
|
46 |
/// |
|
44 |
///Constructor |
|
45 |
Exception() throw() {} |
|
46 |
///Virtual destructor |
|
47 | 47 |
virtual ~Exception() throw() {} |
48 |
/// |
|
48 |
///A short description of the exception |
|
49 | 49 |
virtual const char* what() const throw() { |
50 | 50 |
return "lemon::Exception"; |
... | ... |
@@ -65,5 +65,5 @@ |
65 | 65 |
|
66 | 66 |
/// Copy constructor |
67 |
IoError(const IoError &error) { |
|
67 |
IoError(const IoError &error) throw() : Exception() { |
|
68 | 68 |
message(error._message); |
69 | 69 |
file(error._file); |
... | ... |
@@ -71,15 +71,16 @@ |
71 | 71 |
|
72 | 72 |
/// Constructor |
73 |
explicit IoError(const char *message) { |
|
73 |
explicit IoError(const char *message) throw() { |
|
74 | 74 |
IoError::message(message); |
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
/// Constructor |
78 |
explicit IoError(const std::string &message) { |
|
78 |
explicit IoError(const std::string &message) throw() { |
|
79 | 79 |
IoError::message(message); |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
/// Constructor |
83 |
IoError( |
|
83 |
explicit IoError(const char *message, |
|
84 |
const std::string &file) throw() { |
|
84 | 85 |
IoError::message(message); |
85 | 86 |
IoError::file(file); |
... | ... |
@@ -87,5 +88,6 @@ |
87 | 88 |
|
88 | 89 |
/// Constructor |
89 |
IoError(const std::string & |
|
90 |
explicit IoError(const std::string &message, |
|
91 |
const std::string &file) throw() { |
|
90 | 92 |
IoError::message(message); |
91 | 93 |
IoError::file(file); |
... | ... |
@@ -96,5 +98,5 @@ |
96 | 98 |
|
97 | 99 |
/// Set the error message |
98 |
void message(const char *message) { |
|
100 |
void message(const char *message) throw() { |
|
99 | 101 |
try { |
100 | 102 |
_message = message; |
... | ... |
@@ -103,5 +105,5 @@ |
103 | 105 |
|
104 | 106 |
/// Set the error message |
105 |
void message(const std::string& message) { |
|
107 |
void message(const std::string& message) throw() { |
|
106 | 108 |
try { |
107 | 109 |
_message = message; |
... | ... |
@@ -110,5 +112,5 @@ |
110 | 112 |
|
111 | 113 |
/// Set the file name |
112 |
void file(const std::string &file) { |
|
114 |
void file(const std::string &file) throw() { |
|
113 | 115 |
try { |
114 | 116 |
_file = file; |
... | ... |
@@ -117,5 +119,5 @@ |
117 | 119 |
|
118 | 120 |
/// Returns the error message |
119 |
const std::string& message() const { |
|
121 |
const std::string& message() const throw() { |
|
120 | 122 |
return _message; |
121 | 123 |
} |
... | ... |
@@ -123,7 +125,6 @@ |
123 | 125 |
/// \brief Returns the filename |
124 | 126 |
/// |
125 |
/// Returns the filename or empty string if the filename was not |
|
126 |
/// specified. |
|
127 |
|
|
127 |
/// Returns the filename or an empty string if it was not specified. |
|
128 |
const std::string& file() const throw() { |
|
128 | 129 |
return _file; |
129 | 130 |
} |
... | ... |
@@ -131,6 +132,6 @@ |
131 | 132 |
/// \brief Returns a short error message |
132 | 133 |
/// |
133 |
/// Returns a short error message which contains the message, the |
|
134 |
/// file name and the line number. |
|
134 |
/// Returns a short error message which contains the message and the |
|
135 |
/// file name. |
|
135 | 136 |
virtual const char* what() const throw() { |
136 | 137 |
try { |
... | ... |
@@ -138,9 +139,7 @@ |
138 | 139 |
std::ostringstream oss; |
139 | 140 |
oss << "lemon:IoError" << ": "; |
140 |
oss << message(); |
|
141 |
if (!file().empty()) { |
|
142 |
oss << " ("; |
|
143 |
if (!file().empty()) oss << "with file '" << file() << "'"; |
|
144 |
|
|
141 |
oss << _message; |
|
142 |
if (!_file.empty()) { |
|
143 |
oss << " ('" << _file << "')"; |
|
145 | 144 |
} |
146 | 145 |
_what = oss.str(); |
... | ... |
@@ -155,6 +154,6 @@ |
155 | 154 |
/// \brief Format error |
156 | 155 |
/// |
157 |
/// This class is used to indicate if an input file has wrong |
|
158 |
/// formatting, or a data representation is not legal. |
|
156 |
/// This exception is thrown when an input file has wrong |
|
157 |
/// format or a data representation is not legal. |
|
159 | 158 |
class FormatError : public Exception { |
160 | 159 |
protected: |
... | ... |
@@ -167,5 +166,5 @@ |
167 | 166 |
|
168 | 167 |
/// Copy constructor |
169 |
FormatError(const FormatError &error) { |
|
168 |
FormatError(const FormatError &error) throw() : Exception() { |
|
170 | 169 |
message(error._message); |
171 | 170 |
file(error._file); |
... | ... |
@@ -174,5 +173,5 @@ |
174 | 173 |
|
175 | 174 |
/// Constructor |
176 |
explicit FormatError(const char *message) { |
|
175 |
explicit FormatError(const char *message) throw() { |
|
177 | 176 |
FormatError::message(message); |
178 | 177 |
_line = 0; |
... | ... |
@@ -180,5 +179,5 @@ |
180 | 179 |
|
181 | 180 |
/// Constructor |
182 |
explicit FormatError(const std::string &message) { |
|
181 |
explicit FormatError(const std::string &message) throw() { |
|
183 | 182 |
FormatError::message(message); |
184 | 183 |
_line = 0; |
... | ... |
@@ -186,5 +185,6 @@ |
186 | 185 |
|
187 | 186 |
/// Constructor |
188 |
FormatError( |
|
187 |
explicit FormatError(const char *message, |
|
188 |
const std::string &file, int line = 0) throw() { |
|
189 | 189 |
FormatError::message(message); |
190 | 190 |
FormatError::file(file); |
... | ... |
@@ -193,5 +193,6 @@ |
193 | 193 |
|
194 | 194 |
/// Constructor |
195 |
FormatError(const std::string & |
|
195 |
explicit FormatError(const std::string &message, |
|
196 |
const std::string &file, int line = 0) throw() { |
|
196 | 197 |
FormatError::message(message); |
197 | 198 |
FormatError::file(file); |
... | ... |
@@ -203,8 +204,8 @@ |
203 | 204 |
|
204 | 205 |
/// Set the line number |
205 |
void line(int line) { _line = line; } |
|
206 |
void line(int line) throw() { _line = line; } |
|
206 | 207 |
|
207 | 208 |
/// Set the error message |
208 |
void message(const char *message) { |
|
209 |
void message(const char *message) throw() { |
|
209 | 210 |
try { |
210 | 211 |
_message = message; |
... | ... |
@@ -213,5 +214,5 @@ |
213 | 214 |
|
214 | 215 |
/// Set the error message |
215 |
void message(const std::string& message) { |
|
216 |
void message(const std::string& message) throw() { |
|
216 | 217 |
try { |
217 | 218 |
_message = message; |
... | ... |
@@ -220,5 +221,5 @@ |
220 | 221 |
|
221 | 222 |
/// Set the file name |
222 |
void file(const std::string &file) { |
|
223 |
void file(const std::string &file) throw() { |
|
223 | 224 |
try { |
224 | 225 |
_file = file; |
... | ... |
@@ -229,8 +230,8 @@ |
229 | 230 |
/// |
230 | 231 |
/// Returns the line number or zero if it was not specified. |
231 |
int line() const { return _line; } |
|
232 |
int line() const throw() { return _line; } |
|
232 | 233 |
|
233 | 234 |
/// Returns the error message |
234 |
const std::string& message() const { |
|
235 |
const std::string& message() const throw() { |
|
235 | 236 |
return _message; |
236 | 237 |
} |
... | ... |
@@ -238,7 +239,6 @@ |
238 | 239 |
/// \brief Returns the filename |
239 | 240 |
/// |
240 |
/// Returns the filename or empty string if the filename was not |
|
241 |
/// specified. |
|
242 |
|
|
241 |
/// Returns the filename or an empty string if it was not specified. |
|
242 |
const std::string& file() const throw() { |
|
243 | 243 |
return _file; |
244 | 244 |
} |
... | ... |
@@ -253,10 +253,10 @@ |
253 | 253 |
std::ostringstream oss; |
254 | 254 |
oss << "lemon:FormatError" << ": "; |
255 |
oss << message(); |
|
256 |
if (!file().empty() || line() != 0) { |
|
255 |
oss << _message; |
|
256 |
if (!_file.empty() || _line != 0) { |
|
257 | 257 |
oss << " ("; |
258 |
if (!file().empty()) oss << "in file '" << file() << "'"; |
|
259 |
if (!file().empty() && line() != 0) oss << " "; |
|
260 |
if ( |
|
258 |
if (!_file.empty()) oss << "in file '" << _file << "'"; |
|
259 |
if (!_file.empty() && _line != 0) oss << " "; |
|
260 |
if (_line != 0) oss << "at line " << _line; |
|
261 | 261 |
oss << ")"; |
262 | 262 |
} |
... | ... |
@@ -1171,5 +1171,5 @@ |
1171 | 1171 |
if (!(*os)) { |
1172 | 1172 |
delete os; |
1173 |
throw IoError( |
|
1173 |
throw IoError("Cannot write file", file_name); |
|
1174 | 1174 |
} |
1175 | 1175 |
return GraphToEps<DefaultGraphToEpsTraits<G> > |
... | ... |
@@ -1192,5 +1192,5 @@ |
1192 | 1192 |
if (!(*os)) { |
1193 | 1193 |
delete os; |
1194 |
throw IoError( |
|
1194 |
throw IoError("Cannot write file", file_name); |
|
1195 | 1195 |
} |
1196 | 1196 |
return GraphToEps<DefaultGraphToEpsTraits<G> > |
... | ... |
@@ -517,5 +517,5 @@ |
517 | 517 |
_use_nodes(false), _use_arcs(false), |
518 | 518 |
_skip_nodes(false), _skip_arcs(false) { |
519 |
if (!(*_is)) throw IoError( |
|
519 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
520 | 520 |
} |
521 | 521 |
|
... | ... |
@@ -529,5 +529,5 @@ |
529 | 529 |
_use_nodes(false), _use_arcs(false), |
530 | 530 |
_skip_nodes(false), _skip_arcs(false) { |
531 |
if (!(*_is)) throw IoError( |
|
531 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
532 | 532 |
} |
533 | 533 |
|
... | ... |
@@ -880,5 +880,5 @@ |
880 | 880 |
if (jt == maps.end()) { |
881 | 881 |
std::ostringstream msg; |
882 |
msg << "Map not found |
|
882 |
msg << "Map not found: " << _node_maps[i].first; |
|
883 | 883 |
throw FormatError(msg.str()); |
884 | 884 |
} |
... | ... |
@@ -909,5 +909,5 @@ |
909 | 909 |
} |
910 | 910 |
if (line >> std::ws >> c) |
911 |
throw FormatError("Extra character |
|
911 |
throw FormatError("Extra character at the end of line"); |
|
912 | 912 |
|
913 | 913 |
Node n; |
... | ... |
@@ -918,5 +918,5 @@ |
918 | 918 |
} else { |
919 | 919 |
if (label_index == -1) |
920 |
throw FormatError("Label map not found |
|
920 |
throw FormatError("Label map not found"); |
|
921 | 921 |
typename std::map<std::string, Node>::iterator it = |
922 | 922 |
_node_index.find(tokens[label_index]); |
... | ... |
@@ -973,5 +973,5 @@ |
973 | 973 |
if (jt == maps.end()) { |
974 | 974 |
std::ostringstream msg; |
975 |
msg << "Map not found |
|
975 |
msg << "Map not found: " << _arc_maps[i].first; |
|
976 | 976 |
throw FormatError(msg.str()); |
977 | 977 |
} |
... | ... |
@@ -1011,5 +1011,5 @@ |
1011 | 1011 |
} |
1012 | 1012 |
if (line >> std::ws >> c) |
1013 |
throw FormatError("Extra character |
|
1013 |
throw FormatError("Extra character at the end of line"); |
|
1014 | 1014 |
|
1015 | 1015 |
Arc a; |
... | ... |
@@ -1039,5 +1039,5 @@ |
1039 | 1039 |
} else { |
1040 | 1040 |
if (label_index == -1) |
1041 |
throw FormatError("Label map not found |
|
1041 |
throw FormatError("Label map not found"); |
|
1042 | 1042 |
typename std::map<std::string, Arc>::iterator it = |
1043 | 1043 |
_arc_index.find(tokens[label_index]); |
... | ... |
@@ -1074,5 +1074,5 @@ |
1074 | 1074 |
throw FormatError("Attribute value not found"); |
1075 | 1075 |
if (line >> c) |
1076 |
throw FormatError("Extra character |
|
1076 |
throw FormatError("Extra character at the end of line"); |
|
1077 | 1077 |
|
1078 | 1078 |
{ |
... | ... |
@@ -1080,5 +1080,5 @@ |
1080 | 1080 |
if (it != read_attr.end()) { |
1081 | 1081 |
std::ostringstream msg; |
1082 |
msg << "Multiple occurence of attribute " << attr; |
|
1082 |
msg << "Multiple occurence of attribute: " << attr; |
|
1083 | 1083 |
throw FormatError(msg.str()); |
1084 | 1084 |
} |
... | ... |
@@ -1102,5 +1102,5 @@ |
1102 | 1102 |
if (read_attr.find(it->first) == read_attr.end()) { |
1103 | 1103 |
std::ostringstream msg; |
1104 |
msg << "Attribute not found |
|
1104 |
msg << "Attribute not found: " << it->first; |
|
1105 | 1105 |
throw FormatError(msg.str()); |
1106 | 1106 |
} |
... | ... |
@@ -1118,7 +1118,4 @@ |
1118 | 1118 |
void run() { |
1119 | 1119 |
LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); |
1120 |
if (!*_is) { |
|
1121 |
throw FormatError("Cannot find file"); |
|
1122 |
} |
|
1123 | 1120 |
|
1124 | 1121 |
bool nodes_done = _skip_nodes; |
... | ... |
@@ -1139,5 +1136,5 @@ |
1139 | 1136 |
|
1140 | 1137 |
if (line >> c) |
1141 |
throw FormatError("Extra character |
|
1138 |
throw FormatError("Extra character at the end of line"); |
|
1142 | 1139 |
|
1143 | 1140 |
if (section == "nodes" && !nodes_done) { |
... | ... |
@@ -1309,5 +1306,5 @@ |
1309 | 1306 |
_use_nodes(false), _use_edges(false), |
1310 | 1307 |
_skip_nodes(false), _skip_edges(false) { |
1311 |
if (!(*_is)) throw IoError( |
|
1308 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
1312 | 1309 |
} |
1313 | 1310 |
|
... | ... |
@@ -1321,5 +1318,5 @@ |
1321 | 1318 |
_use_nodes(false), _use_edges(false), |
1322 | 1319 |
_skip_nodes(false), _skip_edges(false) { |
1323 |
if (!(*_is)) throw IoError( |
|
1320 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
1324 | 1321 |
} |
1325 | 1322 |
|
... | ... |
@@ -1716,5 +1713,5 @@ |
1716 | 1713 |
if (jt == maps.end()) { |
1717 | 1714 |
std::ostringstream msg; |
1718 |
msg << "Map not found |
|
1715 |
msg << "Map not found: " << _node_maps[i].first; |
|
1719 | 1716 |
throw FormatError(msg.str()); |
1720 | 1717 |
} |
... | ... |
@@ -1745,5 +1742,5 @@ |
1745 | 1742 |
} |
1746 | 1743 |
if (line >> std::ws >> c) |
1747 |
throw FormatError("Extra character |
|
1744 |
throw FormatError("Extra character at the end of line"); |
|
1748 | 1745 |
|
1749 | 1746 |
Node n; |
... | ... |
@@ -1754,5 +1751,5 @@ |
1754 | 1751 |
} else { |
1755 | 1752 |
if (label_index == -1) |
1756 |
throw FormatError("Label map not found |
|
1753 |
throw FormatError("Label map not found"); |
|
1757 | 1754 |
typename std::map<std::string, Node>::iterator it = |
1758 | 1755 |
_node_index.find(tokens[label_index]); |
... | ... |
@@ -1809,5 +1806,5 @@ |
1809 | 1806 |
if (jt == maps.end()) { |
1810 | 1807 |
std::ostringstream msg; |
1811 |
msg << "Map not found |
|
1808 |
msg << "Map not found: " << _edge_maps[i].first; |
|
1812 | 1809 |
throw FormatError(msg.str()); |
1813 | 1810 |
} |
... | ... |
@@ -1847,5 +1844,5 @@ |
1847 | 1844 |
} |
1848 | 1845 |
if (line >> std::ws >> c) |
1849 |
throw FormatError("Extra character |
|
1846 |
throw FormatError("Extra character at the end of line"); |
|
1850 | 1847 |
|
1851 | 1848 |
Edge e; |
... | ... |
@@ -1875,5 +1872,5 @@ |
1875 | 1872 |
} else { |
1876 | 1873 |
if (label_index == -1) |
1877 |
throw FormatError("Label map not found |
|
1874 |
throw FormatError("Label map not found"); |
|
1878 | 1875 |
typename std::map<std::string, Edge>::iterator it = |
1879 | 1876 |
_edge_index.find(tokens[label_index]); |
... | ... |
@@ -1910,5 +1907,5 @@ |
1910 | 1907 |
throw FormatError("Attribute value not found"); |
1911 | 1908 |
if (line >> c) |
1912 |
throw FormatError("Extra character |
|
1909 |
throw FormatError("Extra character at the end of line"); |
|
1913 | 1910 |
|
1914 | 1911 |
{ |
... | ... |
@@ -1916,5 +1913,5 @@ |
1916 | 1913 |
if (it != read_attr.end()) { |
1917 | 1914 |
std::ostringstream msg; |
1918 |
msg << "Multiple occurence of attribute " << attr; |
|
1915 |
msg << "Multiple occurence of attribute: " << attr; |
|
1919 | 1916 |
throw FormatError(msg.str()); |
1920 | 1917 |
} |
... | ... |
@@ -1938,5 +1935,5 @@ |
1938 | 1935 |
if (read_attr.find(it->first) == read_attr.end()) { |
1939 | 1936 |
std::ostringstream msg; |
1940 |
msg << "Attribute not found |
|
1937 |
msg << "Attribute not found: " << it->first; |
|
1941 | 1938 |
throw FormatError(msg.str()); |
1942 | 1939 |
} |
... | ... |
@@ -1973,5 +1970,5 @@ |
1973 | 1970 |
|
1974 | 1971 |
if (line >> c) |
1975 |
throw FormatError("Extra character |
|
1972 |
throw FormatError("Extra character at the end of line"); |
|
1976 | 1973 |
|
1977 | 1974 |
if (section == "nodes" && !nodes_done) { |
... | ... |
@@ -2096,5 +2093,5 @@ |
2096 | 2093 |
: _is(new std::ifstream(fn.c_str())), local_is(true), |
2097 | 2094 |
_filename(fn) { |
2098 |
if (!(*_is)) throw IoError( |
|
2095 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
2099 | 2096 |
} |
2100 | 2097 |
|
... | ... |
@@ -2105,5 +2102,5 @@ |
2105 | 2102 |
: _is(new std::ifstream(fn)), local_is(true), |
2106 | 2103 |
_filename(fn) { |
2107 |
if (!(*_is)) throw IoError( |
|
2104 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
2108 | 2105 |
} |
2109 | 2106 |
|
... | ... |
@@ -2262,9 +2259,9 @@ |
2262 | 2259 |
|
2263 | 2260 |
if (line >> c) |
2264 |
throw FormatError("Extra character |
|
2261 |
throw FormatError("Extra character at the end of line"); |
|
2265 | 2262 |
|
2266 | 2263 |
if (extra_sections.find(section) != extra_sections.end()) { |
2267 | 2264 |
std::ostringstream msg; |
2268 |
msg << "Multiple occurence of section " << section; |
|
2265 |
msg << "Multiple occurence of section: " << section; |
|
2269 | 2266 |
throw FormatError(msg.str()); |
2270 | 2267 |
} |
... | ... |
@@ -2388,5 +2385,5 @@ |
2388 | 2385 |
LgfContents(const std::string& fn) |
2389 | 2386 |
: _is(new std::ifstream(fn.c_str())), local_is(true) { |
2390 |
if (!(*_is)) throw IoError( |
|
2387 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
2391 | 2388 |
} |
2392 | 2389 |
|
... | ... |
@@ -2397,5 +2394,5 @@ |
2397 | 2394 |
LgfContents(const char* fn) |
2398 | 2395 |
: _is(new std::ifstream(fn)), local_is(true) { |
2399 |
if (!(*_is)) throw IoError( |
|
2396 |
if (!(*_is)) throw IoError("Cannot open file", fn); |
|
2400 | 2397 |
} |
2401 | 2398 |
... | ... |
@@ -464,5 +464,5 @@ |
464 | 464 |
: _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), |
465 | 465 |
_skip_nodes(false), _skip_arcs(false) { |
466 |
if (!(*_os)) throw IoError( |
|
466 |
if (!(*_os)) throw IoError("Cannot write file", fn); |
|
467 | 467 |
} |
468 | 468 |
|
... | ... |
@@ -474,5 +474,5 @@ |
474 | 474 |
: _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), |
475 | 475 |
_skip_nodes(false), _skip_arcs(false) { |
476 |
if (!(*_os)) throw IoError( |
|
476 |
if (!(*_os)) throw IoError("Cannot write file", fn); |
|
477 | 477 |
} |
478 | 478 |
|
... | ... |
@@ -1024,5 +1024,5 @@ |
1024 | 1024 |
: _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
1025 | 1025 |
_skip_nodes(false), _skip_edges(false) { |
1026 |
if (!(*_os)) throw IoError( |
|
1026 |
if (!(*_os)) throw IoError("Cannot write file", fn); |
|
1027 | 1027 |
} |
1028 | 1028 |
|
... | ... |
@@ -1034,5 +1034,5 @@ |
1034 | 1034 |
: _os(new std::ofstream(fn)), local_os(true), _graph(graph), |
1035 | 1035 |
_skip_nodes(false), _skip_edges(false) { |
1036 |
if (!(*_os)) throw IoError( |
|
1036 |
if (!(*_os)) throw IoError("Cannot write file", fn); |
|
1037 | 1037 |
} |
1038 | 1038 |
|
... | ... |
@@ -1586,5 +1586,5 @@ |
1586 | 1586 |
SectionWriter(const std::string& fn) |
1587 | 1587 |
: _os(new std::ofstream(fn.c_str())), local_os(true) { |
1588 |
if (!(*_os)) throw IoError( |
|
1588 |
if (!(*_os)) throw IoError("Cannot write file", fn); |
|
1589 | 1589 |
} |
1590 | 1590 |
|
... | ... |
@@ -1594,5 +1594,5 @@ |
1594 | 1594 |
SectionWriter(const char* fn) |
1595 | 1595 |
: _os(new std::ofstream(fn)), local_os(true) { |
1596 |
if (!(*_os)) throw IoError( |
|
1596 |
if (!(*_os)) throw IoError("Cannot write file", fn); |
|
1597 | 1597 |
} |
1598 | 1598 |
|
0 comments (0 inline)