Changes in / [294:cbe3ec2d59d2:293:47fbc814aa31] in lemon-main
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/lgf_demo.cc
r294 r293 50 50 node("target", t). // read 'target' node to t 51 51 run(); 52 } catch ( Exception& error) { // check if there was any error52 } catch (DataFormatError& error) { // check if there was any error 53 53 std::cerr << "Error: " << error.what() << std::endl; 54 54 return -1; -
lemon/arg_parser.h
r290 r261 311 311 ///This is the type of the return value of ArgParser::operator[](). 312 312 ///It automatically converts to \c int, \c double, \c bool or 313 ///\c std::string if the type of the option matches, which is checked 314 ///with an \ref LEMON_ASSERT "assertion" (i.e. it performs runtime 315 ///type checking). 313 ///\c std::string if the type of the option matches, otherwise it 314 ///throws an exception (i.e. it performs runtime type checking). 316 315 class RefType 317 316 { -
lemon/assert.h
r290 r277 109 109 /// \brief Macro for assertion with customizable message 110 110 /// 111 /// Macro for assertion with customizable message. 111 /// Macro for assertion with customizable message. 112 112 /// \param exp An expression that must be convertible to \c bool. If it is \c 113 113 /// false, then an assertion is raised. The concrete behaviour depends on the -
lemon/bfs.h
r292 r288 136 136 class Bfs { 137 137 public: 138 ///\ref Exception for uninitialized parameters. 139 140 ///This error represents problems in the initialization of the 141 ///parameters of the algorithm. 142 class UninitializedParameter : public lemon::UninitializedParameter { 143 public: 144 virtual const char* what() const throw() { 145 return "lemon::Bfs::UninitializedParameter"; 146 } 147 }; 138 148 139 149 ///The type of the digraph the algorithm runs on. … … 223 233 static PredMap *createPredMap(const Digraph &) 224 234 { 225 LEMON_ASSERT(false, "PredMap is not initialized"); 226 return 0; // ignore warnings 235 throw UninitializedParameter(); 227 236 } 228 237 }; … … 242 251 static DistMap *createDistMap(const Digraph &) 243 252 { 244 LEMON_ASSERT(false, "DistMap is not initialized"); 245 return 0; // ignore warnings 253 throw UninitializedParameter(); 246 254 } 247 255 }; … … 261 269 static ReachedMap *createReachedMap(const Digraph &) 262 270 { 263 LEMON_ASSERT(false, "ReachedMap is not initialized"); 264 return 0; // ignore warnings 271 throw UninitializedParameter(); 265 272 } 266 273 }; … … 280 287 static ProcessedMap *createProcessedMap(const Digraph &) 281 288 { 282 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 283 return 0; // ignore warnings 289 throw UninitializedParameter(); 284 290 } 285 291 }; … … 299 305 { 300 306 return new ProcessedMap(g); 301 return 0; // ignore warnings302 307 } 303 308 }; … … 1036 1041 bool run(Node s, Node t) 1037 1042 { 1043 if (s==INVALID || t==INVALID) throw UninitializedParameter(); 1038 1044 Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g)); 1039 1045 if (Base::_pred) … … 1318 1324 public: 1319 1325 1326 /// \brief \ref Exception for uninitialized parameters. 1327 /// 1328 /// This error represents problems in the initialization 1329 /// of the parameters of the algorithm. 1330 class UninitializedParameter : public lemon::UninitializedParameter { 1331 public: 1332 virtual const char* what() const throw() 1333 { 1334 return "lemon::BfsVisit::UninitializedParameter"; 1335 } 1336 }; 1337 1320 1338 ///The traits class. 1321 1339 typedef _Traits Traits; … … 1372 1390 typedef T ReachedMap; 1373 1391 static ReachedMap *createReachedMap(const Digraph &digraph) { 1374 LEMON_ASSERT(false, "ReachedMap is not initialized"); 1375 return 0; // ignore warnings 1392 throw UninitializedParameter(); 1376 1393 } 1377 1394 }; -
lemon/concepts/heap.h
r290 r220 130 130 /// Otherwise it inserts the given item with the given priority. 131 131 /// 132 /// It may throw an \ref UnderflowPriorityException. 132 133 /// \param i The item. 133 134 /// \param p The priority. -
lemon/dfs.h
r292 r288 137 137 class Dfs { 138 138 public: 139 ///\ref Exception for uninitialized parameters. 140 141 ///This error represents problems in the initialization of the 142 ///parameters of the algorithm. 143 class UninitializedParameter : public lemon::UninitializedParameter { 144 public: 145 virtual const char* what() const throw() { 146 return "lemon::Dfs::UninitializedParameter"; 147 } 148 }; 139 149 140 150 ///The type of the digraph the algorithm runs on. … … 223 233 static PredMap *createPredMap(const Digraph &) 224 234 { 225 LEMON_ASSERT(false, "PredMap is not initialized"); 226 return 0; // ignore warnings 235 throw UninitializedParameter(); 227 236 } 228 237 }; … … 242 251 static DistMap *createDistMap(const Digraph &) 243 252 { 244 LEMON_ASSERT(false, "DistMap is not initialized"); 245 return 0; // ignore warnings 253 throw UninitializedParameter(); 246 254 } 247 255 }; … … 261 269 static ReachedMap *createReachedMap(const Digraph &) 262 270 { 263 LEMON_ASSERT(false, "ReachedMap is not initialized"); 264 return 0; // ignore warnings 271 throw UninitializedParameter(); 265 272 } 266 273 }; … … 280 287 static ProcessedMap *createProcessedMap(const Digraph &) 281 288 { 282 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 283 return 0; // ignore warnings 289 throw UninitializedParameter(); 284 290 } 285 291 }; … … 969 975 bool run(Node s, Node t) 970 976 { 977 if (s==INVALID || t==INVALID) throw UninitializedParameter(); 971 978 Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g)); 972 979 if (Base::_pred) … … 1264 1271 public: 1265 1272 1273 /// \brief \ref Exception for uninitialized parameters. 1274 /// 1275 /// This error represents problems in the initialization 1276 /// of the parameters of the algorithm. 1277 class UninitializedParameter : public lemon::UninitializedParameter { 1278 public: 1279 virtual const char* what() const throw() 1280 { 1281 return "lemon::DfsVisit::UninitializedParameter"; 1282 } 1283 }; 1284 1266 1285 ///The traits class. 1267 1286 typedef _Traits Traits; … … 1318 1337 typedef T ReachedMap; 1319 1338 static ReachedMap *createReachedMap(const Digraph &digraph) { 1320 LEMON_ASSERT(false, "ReachedMap is not initialized"); 1321 return 0; // ignore warnings 1339 throw UninitializedParameter(); 1322 1340 } 1323 1341 }; -
lemon/dijkstra.h
r290 r287 226 226 class Dijkstra { 227 227 public: 228 ///\ref Exception for uninitialized parameters. 229 230 ///This error represents problems in the initialization of the 231 ///parameters of the algorithm. 232 class UninitializedParameter : public lemon::UninitializedParameter { 233 public: 234 virtual const char* what() const throw() { 235 return "lemon::Dijkstra::UninitializedParameter"; 236 } 237 }; 228 238 229 239 ///The type of the digraph the algorithm runs on. … … 323 333 static PredMap *createPredMap(const Digraph &) 324 334 { 325 LEMON_ASSERT(false, "PredMap is not initialized"); 326 return 0; // ignore warnings 335 throw UninitializedParameter(); 327 336 } 328 337 }; … … 343 352 static DistMap *createDistMap(const Digraph &) 344 353 { 345 LEMON_ASSERT(false, "DistMap is not initialized"); 346 return 0; // ignore warnings 354 throw UninitializedParameter(); 347 355 } 348 356 }; … … 363 371 static ProcessedMap *createProcessedMap(const Digraph &) 364 372 { 365 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 366 return 0; // ignore warnings 373 throw UninitializedParameter(); 367 374 } 368 375 }; … … 402 409 typedef H Heap; 403 410 static HeapCrossRef *createHeapCrossRef(const Digraph &) { 404 LEMON_ASSERT(false, "HeapCrossRef is not initialized"); 405 return 0; // ignore warnings 411 throw UninitializedParameter(); 406 412 } 407 413 static Heap *createHeap(HeapCrossRef &) 408 414 { 409 LEMON_ASSERT(false, "Heap is not initialized"); 410 return 0; // ignore warnings 415 throw UninitializedParameter(); 411 416 } 412 417 }; … … 1154 1159 void run(Node s) 1155 1160 { 1161 if (s==INVALID) throw UninitializedParameter(); 1156 1162 Dijkstra<Digraph,LengthMap,TR> 1157 1163 dijk(*reinterpret_cast<const Digraph*>(Base::_g), … … 1175 1181 bool run(Node s, Node t) 1176 1182 { 1183 if (s==INVALID || t==INVALID) throw UninitializedParameter(); 1177 1184 Dijkstra<Digraph,LengthMap,TR> 1178 1185 dijk(*reinterpret_cast<const Digraph*>(Base::_g), -
lemon/error.h
r291 r280 36 36 /// @{ 37 37 38 /// \brief Generic exceptionclass.38 /// \brief Exception safe wrapper class. 39 39 /// 40 /// Exception safe wrapper class to implement the members of exceptions. 41 template <typename _Type> 42 class ExceptionMember { 43 public: 44 typedef _Type Type; 45 46 ExceptionMember() throw() { 47 try { 48 ptr.reset(new Type()); 49 } catch (...) {} 50 } 51 52 ExceptionMember(const Type& type) throw() { 53 try { 54 ptr.reset(new Type()); 55 if (ptr.get() == 0) return; 56 *ptr = type; 57 } catch (...) {} 58 } 59 60 ExceptionMember(const ExceptionMember& copy) throw() { 61 try { 62 if (!copy.valid()) return; 63 ptr.reset(new Type()); 64 if (ptr.get() == 0) return; 65 *ptr = copy.get(); 66 } catch (...) {} 67 } 68 69 ExceptionMember& operator=(const ExceptionMember& copy) throw() { 70 if (ptr.get() == 0) return; 71 try { 72 if (!copy.valid()) return; 73 *ptr = copy.get(); 74 } catch (...) {} 75 } 76 77 void set(const Type& type) throw() { 78 if (ptr.get() == 0) return; 79 try { 80 *ptr = type; 81 } catch (...) {} 82 } 83 84 const Type& get() const { 85 return *ptr; 86 } 87 88 bool valid() const throw() { 89 return ptr.get() != 0; 90 } 91 92 private: 93 std::auto_ptr<_Type> ptr; 94 }; 95 96 /// Exception-safe convenient error message builder class. 97 98 /// Helper class which provides a convenient ostream-like (operator << 99 /// based) interface to create a string message. Mostly useful in 100 /// exception classes (therefore the name). 101 class ErrorMessage { 102 protected: 103 ///\e 104 105 mutable std::auto_ptr<std::ostringstream> buf; 106 107 ///\e 108 bool init() throw() { 109 try { 110 buf.reset(new std::ostringstream); 111 } 112 catch(...) { 113 buf.reset(); 114 } 115 return buf.get(); 116 } 117 118 public: 119 120 ///\e 121 ErrorMessage() throw() { init(); } 122 123 ErrorMessage(const ErrorMessage& em) throw() : buf(em.buf) { } 124 125 ///\e 126 ErrorMessage(const char *msg) throw() { 127 init(); 128 *this << msg; 129 } 130 131 ///\e 132 ErrorMessage(const std::string &msg) throw() { 133 init(); 134 *this << msg; 135 } 136 137 ///\e 138 template <typename T> 139 ErrorMessage& operator<<(const T &t) throw() { 140 if( ! buf.get() ) return *this; 141 142 try { 143 *buf << t; 144 } 145 catch(...) { 146 buf.reset(); 147 } 148 return *this; 149 } 150 151 ///\e 152 const char* message() throw() { 153 if( ! buf.get() ) return 0; 154 155 const char* mes = 0; 156 try { 157 mes = buf->str().c_str(); 158 } 159 catch(...) {} 160 return mes; 161 } 162 163 }; 164 165 /// Generic exception class. 166 40 167 /// Base class for exceptions used in LEMON. 41 168 /// 42 169 class Exception : public std::exception { 43 170 public: 44 /// Constructor45 Exception() throw(){}46 /// Virtual destructor171 ///\e 172 Exception() {} 173 ///\e 47 174 virtual ~Exception() throw() {} 48 /// A short description of the exception175 ///\e 49 176 virtual const char* what() const throw() { 50 177 return "lemon::Exception"; … … 52 179 }; 53 180 54 /// \brief Input-Output error 181 /// One of the two main subclasses of \ref Exception. 182 183 /// Logic errors represent problems in the internal logic of a program; 184 /// in theory, these are preventable, and even detectable before the 185 /// program runs (e.g. violations of class invariants). 55 186 /// 56 /// This exception is thrown when a file operation cannot be 57 /// succeeded. 58 class IoError : public Exception { 187 /// A typical example for this is \ref UninitializedParameter. 188 class LogicError : public Exception { 189 public: 190 virtual const char* what() const throw() { 191 return "lemon::LogicError"; 192 } 193 }; 194 195 /// \ref Exception for uninitialized parameters. 196 197 /// This error represents problems in the initialization 198 /// of the parameters of the algorithms. 199 class UninitializedParameter : public LogicError { 200 public: 201 virtual const char* what() const throw() { 202 return "lemon::UninitializedParameter"; 203 } 204 }; 205 206 207 /// One of the two main subclasses of \ref Exception. 208 209 /// Runtime errors represent problems outside the scope of a program; 210 /// they cannot be easily predicted and can generally only be caught 211 /// as the program executes. 212 class RuntimeError : public Exception { 213 public: 214 virtual const char* what() const throw() { 215 return "lemon::RuntimeError"; 216 } 217 }; 218 219 ///\e 220 class RangeError : public RuntimeError { 221 public: 222 virtual const char* what() const throw() { 223 return "lemon::RangeError"; 224 } 225 }; 226 227 ///\e 228 class IoError : public RuntimeError { 229 public: 230 virtual const char* what() const throw() { 231 return "lemon::IoError"; 232 } 233 }; 234 235 ///\e 236 class DataFormatError : public IoError { 59 237 protected: 60 std::string _message; 61 std::string _file; 62 63 mutable std::string _what; 64 public: 65 66 /// Copy constructor 67 IoError(const IoError &error) throw() : Exception() { 68 message(error._message); 69 file(error._file); 70 } 71 72 /// Constructor 73 explicit IoError(const char *message) throw() { 74 IoError::message(message); 75 } 76 77 /// Constructor 78 explicit IoError(const std::string &message) throw() { 79 IoError::message(message); 80 } 81 82 /// Constructor 83 explicit IoError(const char *message, 84 const std::string &file) throw() { 85 IoError::message(message); 86 IoError::file(file); 87 } 88 89 /// Constructor 90 explicit IoError(const std::string &message, 91 const std::string &file) throw() { 92 IoError::message(message); 93 IoError::file(file); 94 } 95 96 /// Virtual destructor 97 virtual ~IoError() throw() {} 98 99 /// Set the error message 100 void message(const char *message) throw() { 101 try { 102 _message = message; 103 } catch (...) {} 104 } 105 106 /// Set the error message 107 void message(const std::string& message) throw() { 108 try { 109 _message = message; 110 } catch (...) {} 111 } 112 113 /// Set the file name 114 void file(const std::string &file) throw() { 115 try { 116 _file = file; 117 } catch (...) {} 118 } 119 120 /// Returns the error message 121 const std::string& message() const throw() { 122 return _message; 123 } 124 125 /// \brief Returns the filename 238 ExceptionMember<std::string> _message; 239 ExceptionMember<std::string> _file; 240 int _line; 241 242 mutable ExceptionMember<std::string> _message_holder; 243 public: 244 245 DataFormatError(const DataFormatError &dfe) : 246 IoError(dfe), _message(dfe._message), _file(dfe._file), 247 _line(dfe._line) {} 248 249 ///\e 250 explicit DataFormatError(const char *the_message) 251 : _message(the_message), _line(0) {} 252 253 ///\e 254 DataFormatError(const std::string &file_name, int line_num, 255 const char *the_message) 256 : _message(the_message), _line(line_num) { file(file_name); } 257 258 ///\e 259 void line(int ln) { _line = ln; } 260 ///\e 261 void message(const std::string& msg) { _message.set(msg); } 262 ///\e 263 void file(const std::string &fl) { _file.set(fl); } 264 265 ///\e 266 int line() const { return _line; } 267 ///\e 268 const char* message() const { 269 if (_message.valid() && !_message.get().empty()) { 270 return _message.get().c_str(); 271 } else { 272 return 0; 273 } 274 } 275 276 /// \brief Returns the filename. 126 277 /// 127 /// Returns the filename or an empty string if it was not specified. 128 const std::string& file() const throw() { 129 return _file; 130 } 131 132 /// \brief Returns a short error message 278 /// Returns \e null if the filename was not specified. 279 const char* file() const { 280 if (_file.valid() && !_file.get().empty()) { 281 return _file.get().c_str(); 282 } else { 283 return 0; 284 } 285 } 286 287 ///\e 288 virtual const char* what() const throw() { 289 try { 290 std::ostringstream ostr; 291 ostr << "lemon:DataFormatError" << ": "; 292 if (message()) ostr << message(); 293 if( file() || line() != 0 ) { 294 ostr << " ("; 295 if( file() ) ostr << "in file '" << file() << "'"; 296 if( file() && line() != 0 ) ostr << " "; 297 if( line() != 0 ) ostr << "at line " << line(); 298 ostr << ")"; 299 } 300 _message_holder.set(ostr.str()); 301 } 302 catch (...) {} 303 if( _message_holder.valid()) return _message_holder.get().c_str(); 304 return "lemon:DataFormatError"; 305 } 306 307 virtual ~DataFormatError() throw() {} 308 }; 309 310 ///\e 311 class FileOpenError : public IoError { 312 protected: 313 ExceptionMember<std::string> _file; 314 315 mutable ExceptionMember<std::string> _message_holder; 316 public: 317 318 FileOpenError(const FileOpenError &foe) : 319 IoError(foe), _file(foe._file) {} 320 321 ///\e 322 explicit FileOpenError(const std::string& fl) 323 : _file(fl) {} 324 325 326 ///\e 327 void file(const std::string &fl) { _file.set(fl); } 328 329 /// \brief Returns the filename. 133 330 /// 134 /// Returns a short error message which contains the message and the 135 /// file name. 136 virtual const char* what() const throw() { 137 try { 138 _what.clear(); 139 std::ostringstream oss; 140 oss << "lemon:IoError" << ": "; 141 oss << _message; 142 if (!_file.empty()) { 143 oss << " ('" << _file << "')"; 144 } 145 _what = oss.str(); 331 /// Returns \e null if the filename was not specified. 332 const char* file() const { 333 if (_file.valid() && !_file.get().empty()) { 334 return _file.get().c_str(); 335 } else { 336 return 0; 337 } 338 } 339 340 ///\e 341 virtual const char* what() const throw() { 342 try { 343 std::ostringstream ostr; 344 ostr << "lemon::FileOpenError" << ": "; 345 ostr << "Cannot open file - " << file(); 346 _message_holder.set(ostr.str()); 146 347 } 147 348 catch (...) {} 148 if (!_what.empty()) return _what.c_str(); 149 else return "lemon:IoError"; 150 } 151 152 }; 153 154 /// \brief Format error 155 /// 156 /// This exception is thrown when an input file has wrong 157 /// format or a data representation is not legal. 158 class FormatError : public Exception { 349 if( _message_holder.valid()) return _message_holder.get().c_str(); 350 return "lemon::FileOpenError"; 351 } 352 virtual ~FileOpenError() throw() {} 353 }; 354 355 class IoParameterError : public IoError { 159 356 protected: 160 std::string _message; 161 std::string _file; 162 int _line; 163 164 mutable std::string _what; 165 public: 166 167 /// Copy constructor 168 FormatError(const FormatError &error) throw() : Exception() { 169 message(error._message); 170 file(error._file); 171 line(error._line); 172 } 173 174 /// Constructor 175 explicit FormatError(const char *message) throw() { 176 FormatError::message(message); 177 _line = 0; 178 } 179 180 /// Constructor 181 explicit FormatError(const std::string &message) throw() { 182 FormatError::message(message); 183 _line = 0; 184 } 185 186 /// Constructor 187 explicit FormatError(const char *message, 188 const std::string &file, int line = 0) throw() { 189 FormatError::message(message); 190 FormatError::file(file); 191 FormatError::line(line); 192 } 193 194 /// Constructor 195 explicit FormatError(const std::string &message, 196 const std::string &file, int line = 0) throw() { 197 FormatError::message(message); 198 FormatError::file(file); 199 FormatError::line(line); 200 } 201 202 /// Virtual destructor 203 virtual ~FormatError() throw() {} 204 205 /// Set the line number 206 void line(int line) throw() { _line = line; } 207 208 /// Set the error message 209 void message(const char *message) throw() { 210 try { 211 _message = message; 212 } catch (...) {} 213 } 214 215 /// Set the error message 216 void message(const std::string& message) throw() { 217 try { 218 _message = message; 219 } catch (...) {} 220 } 221 222 /// Set the file name 223 void file(const std::string &file) throw() { 224 try { 225 _file = file; 226 } catch (...) {} 227 } 228 229 /// \brief Returns the line number 357 ExceptionMember<std::string> _message; 358 ExceptionMember<std::string> _file; 359 360 mutable ExceptionMember<std::string> _message_holder; 361 public: 362 363 IoParameterError(const IoParameterError &ile) : 364 IoError(ile), _message(ile._message), _file(ile._file) {} 365 366 ///\e 367 explicit IoParameterError(const char *the_message) 368 : _message(the_message) {} 369 370 ///\e 371 IoParameterError(const char *file_name, const char *the_message) 372 : _message(the_message), _file(file_name) {} 373 374 ///\e 375 void message(const std::string& msg) { _message.set(msg); } 376 ///\e 377 void file(const std::string &fl) { _file.set(fl); } 378 379 ///\e 380 const char* message() const { 381 if (_message.valid()) { 382 return _message.get().c_str(); 383 } else { 384 return 0; 385 } 386 } 387 388 /// \brief Returns the filename. 230 389 /// 231 /// Returns the line number or zero if it was not specified. 232 int line() const throw() { return _line; } 233 234 /// Returns the error message 235 const std::string& message() const throw() { 236 return _message; 237 } 238 239 /// \brief Returns the filename 240 /// 241 /// Returns the filename or an empty string if it was not specified. 242 const std::string& file() const throw() { 243 return _file; 244 } 245 246 /// \brief Returns a short error message 247 /// 248 /// Returns a short error message which contains the message, the 249 /// file name and the line number. 250 virtual const char* what() const throw() { 251 try { 252 _what.clear(); 253 std::ostringstream oss; 254 oss << "lemon:FormatError" << ": "; 255 oss << _message; 256 if (!_file.empty() || _line != 0) { 257 oss << " ("; 258 if (!_file.empty()) oss << "in file '" << _file << "'"; 259 if (!_file.empty() && _line != 0) oss << " "; 260 if (_line != 0) oss << "at line " << _line; 261 oss << ")"; 262 } 263 _what = oss.str(); 390 /// Returns \c 0 if the filename was not specified. 391 const char* file() const { 392 if (_file.valid()) { 393 return _file.get().c_str(); 394 } else { 395 return 0; 396 } 397 } 398 399 ///\e 400 virtual const char* what() const throw() { 401 try { 402 std::ostringstream ostr; 403 if (message()) ostr << message(); 404 if (file()) ostr << "(when reading file '" << file() << "')"; 405 _message_holder.set(ostr.str()); 264 406 } 265 407 catch (...) {} 266 if (!_what.empty()) return _what.c_str();267 else return "lemon:FormatError";268 } 269 408 if( _message_holder.valid() ) return _message_holder.get().c_str(); 409 return "lemon:IoParameterError"; 410 } 411 virtual ~IoParameterError() throw() {} 270 412 }; 271 413 -
lemon/graph_to_eps.h
r291 r280 41 41 #include<lemon/color.h> 42 42 #include<lemon/bits/bezier.h> 43 #include<lemon/error.h>44 43 45 44 … … 1168 1167 graphToEps(G &g,const char *file_name) 1169 1168 { 1170 std::ostream* os = new std::ofstream(file_name);1171 if (!(*os)) {1172 delete os;1173 throw IoError("Cannot write file", file_name);1174 }1175 1169 return GraphToEps<DefaultGraphToEpsTraits<G> > 1176 (DefaultGraphToEpsTraits<G>(g,* os,true));1170 (DefaultGraphToEpsTraits<G>(g,*new std::ofstream(file_name),true)); 1177 1171 } 1178 1172 … … 1189 1183 graphToEps(G &g,const std::string& file_name) 1190 1184 { 1191 std::ostream* os = new std::ofstream(file_name.c_str());1192 if (!(*os)) {1193 delete os;1194 throw IoError("Cannot write file", file_name);1195 }1196 1185 return GraphToEps<DefaultGraphToEpsTraits<G> > 1197 (DefaultGraphToEpsTraits<G>(g,* os,true));1186 (DefaultGraphToEpsTraits<G>(g,*new std::ofstream(file_name.c_str()),true)); 1198 1187 } 1199 1188 -
lemon/lgf_reader.h
r294 r293 49 49 std::istringstream is(str); 50 50 Value value; 51 if (!(is >> value)) { 52 throw FormatError("Cannot read token"); 53 } 51 is >> value; 54 52 55 53 char c; 56 54 if (is >> std::ws >> c) { 57 throw FormatError("Remaining characters in token");55 throw DataFormatError("Remaining characters in token"); 58 56 } 59 57 return value; … … 169 167 std::ostringstream msg; 170 168 msg << "Item not found: " << str; 171 throw FormatError(msg.str());169 throw DataFormatError(msg.str().c_str()); 172 170 } 173 171 return it->second; … … 187 185 typename Graph::Arc operator()(const std::string& str) { 188 186 if (str.empty() || (str[0] != '+' && str[0] != '-')) { 189 throw FormatError("Item must start with '+' or '-'");187 throw DataFormatError("Item must start with '+' or '-'"); 190 188 } 191 189 typename std::map<std::string, typename Graph::Edge> 192 190 ::const_iterator it = _map.find(str.substr(1)); 193 191 if (it == _map.end()) { 194 throw FormatError("Item not found");192 throw DataFormatError("Item not found"); 195 193 } 196 194 return _graph.direct(it->second, str[0] == '+'); … … 238 236 char c; 239 237 if (!is.get(c)) 240 throw FormatError("Escape format error");238 throw DataFormatError("Escape format error"); 241 239 242 240 switch (c) { … … 267 265 int code; 268 266 if (!is.get(c) || !isHex(c)) 269 throw FormatError("Escape format error");267 throw DataFormatError("Escape format error"); 270 268 else if (code = valueHex(c), !is.get(c) || !isHex(c)) is.putback(c); 271 269 else code = code * 16 + valueHex(c); … … 276 274 int code; 277 275 if (!isOct(c)) 278 throw FormatError("Escape format error");276 throw DataFormatError("Escape format error"); 279 277 else if (code = valueOct(c), !is.get(c) || !isOct(c)) 280 278 is.putback(c); … … 303 301 } 304 302 if (!is) 305 throw FormatError("Quoted format error");303 throw DataFormatError("Quoted format error"); 306 304 } else { 307 305 is.putback(c); … … 464 462 std::istream* _is; 465 463 bool local_is; 466 std::string _filename;467 464 468 465 Digraph& _digraph; … … 514 511 /// file. 515 512 DigraphReader(Digraph& digraph, const std::string& fn) 516 : _is(new std::ifstream(fn.c_str())), local_is(true), 517 _filename(fn), _digraph(digraph), 513 : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph), 518 514 _use_nodes(false), _use_arcs(false), 519 _skip_nodes(false), _skip_arcs(false) { 520 if (!(*_is)) throw IoError("Cannot open file", fn); 521 } 515 _skip_nodes(false), _skip_arcs(false) {} 522 516 523 517 /// \brief Constructor … … 526 520 /// file. 527 521 DigraphReader(Digraph& digraph, const char* fn) 528 : _is(new std::ifstream(fn)), local_is(true), 529 _filename(fn), _digraph(digraph), 522 : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph), 530 523 _use_nodes(false), _use_arcs(false), 531 _skip_nodes(false), _skip_arcs(false) { 532 if (!(*_is)) throw IoError("Cannot open file", fn); 533 } 524 _skip_nodes(false), _skip_arcs(false) {} 534 525 535 526 /// \brief Destructor … … 856 847 if (readSuccess() && line) line.putback(c); 857 848 if (!_node_maps.empty()) 858 throw FormatError("Cannot find map names");849 throw DataFormatError("Cannot find map names"); 859 850 return; 860 851 } … … 870 861 std::ostringstream msg; 871 862 msg << "Multiple occurence of node map: " << map; 872 throw FormatError(msg.str());863 throw DataFormatError(msg.str().c_str()); 873 864 } 874 865 maps.insert(std::make_pair(map, index)); … … 881 872 if (jt == maps.end()) { 882 873 std::ostringstream msg; 883 msg << "Map not found : " << _node_maps[i].first;884 throw FormatError(msg.str());874 msg << "Map not found in file: " << _node_maps[i].first; 875 throw DataFormatError(msg.str().c_str()); 885 876 } 886 877 map_index[i] = jt->second; … … 906 897 std::ostringstream msg; 907 898 msg << "Column not found (" << i + 1 << ")"; 908 throw FormatError(msg.str());899 throw DataFormatError(msg.str().c_str()); 909 900 } 910 901 } 911 902 if (line >> std::ws >> c) 912 throw FormatError("Extra character atthe end of line");903 throw DataFormatError("Extra character on the end of line"); 913 904 914 905 Node n; … … 919 910 } else { 920 911 if (label_index == -1) 921 throw FormatError("Label map not found");912 throw DataFormatError("Label map not found in file"); 922 913 typename std::map<std::string, Node>::iterator it = 923 914 _node_index.find(tokens[label_index]); … … 925 916 std::ostringstream msg; 926 917 msg << "Node with label not found: " << tokens[label_index]; 927 throw FormatError(msg.str());918 throw DataFormatError(msg.str().c_str()); 928 919 } 929 920 n = it->second; … … 949 940 if (readSuccess() && line) line.putback(c); 950 941 if (!_arc_maps.empty()) 951 throw FormatError("Cannot find map names");942 throw DataFormatError("Cannot find map names"); 952 943 return; 953 944 } … … 963 954 std::ostringstream msg; 964 955 msg << "Multiple occurence of arc map: " << map; 965 throw FormatError(msg.str());956 throw DataFormatError(msg.str().c_str()); 966 957 } 967 958 maps.insert(std::make_pair(map, index)); … … 974 965 if (jt == maps.end()) { 975 966 std::ostringstream msg; 976 msg << "Map not found : " << _arc_maps[i].first;977 throw FormatError(msg.str());967 msg << "Map not found in file: " << _arc_maps[i].first; 968 throw DataFormatError(msg.str().c_str()); 978 969 } 979 970 map_index[i] = jt->second; … … 998 989 999 990 if (!_reader_bits::readToken(line, source_token)) 1000 throw FormatError("Source not found");991 throw DataFormatError("Source not found"); 1001 992 1002 993 if (!_reader_bits::readToken(line, target_token)) 1003 throw FormatError("Target not found");994 throw DataFormatError("Target not found"); 1004 995 1005 996 std::vector<std::string> tokens(map_num); … … 1008 999 std::ostringstream msg; 1009 1000 msg << "Column not found (" << i + 1 << ")"; 1010 throw FormatError(msg.str());1001 throw DataFormatError(msg.str().c_str()); 1011 1002 } 1012 1003 } 1013 1004 if (line >> std::ws >> c) 1014 throw FormatError("Extra character atthe end of line");1005 throw DataFormatError("Extra character on the end of line"); 1015 1006 1016 1007 Arc a; … … 1023 1014 std::ostringstream msg; 1024 1015 msg << "Item not found: " << source_token; 1025 throw FormatError(msg.str());1016 throw DataFormatError(msg.str().c_str()); 1026 1017 } 1027 1018 Node source = it->second; … … 1031 1022 std::ostringstream msg; 1032 1023 msg << "Item not found: " << target_token; 1033 throw FormatError(msg.str());1024 throw DataFormatError(msg.str().c_str()); 1034 1025 } 1035 1026 Node target = it->second; … … 1040 1031 } else { 1041 1032 if (label_index == -1) 1042 throw FormatError("Label map not found");1033 throw DataFormatError("Label map not found in file"); 1043 1034 typename std::map<std::string, Arc>::iterator it = 1044 1035 _arc_index.find(tokens[label_index]); … … 1046 1037 std::ostringstream msg; 1047 1038 msg << "Arc with label not found: " << tokens[label_index]; 1048 throw FormatError(msg.str());1039 throw DataFormatError(msg.str().c_str()); 1049 1040 } 1050 1041 a = it->second; … … 1071 1062 std::string attr, token; 1072 1063 if (!_reader_bits::readToken(line, attr)) 1073 throw FormatError("Attribute name not found");1064 throw DataFormatError("Attribute name not found"); 1074 1065 if (!_reader_bits::readToken(line, token)) 1075 throw FormatError("Attribute value not found");1066 throw DataFormatError("Attribute value not found"); 1076 1067 if (line >> c) 1077 throw FormatError("Extra character atthe end of line");1068 throw DataFormatError("Extra character on the end of line"); 1078 1069 1079 1070 { … … 1081 1072 if (it != read_attr.end()) { 1082 1073 std::ostringstream msg; 1083 msg << "Multiple occurence of attribute :" << attr;1084 throw FormatError(msg.str());1074 msg << "Multiple occurence of attribute " << attr; 1075 throw DataFormatError(msg.str().c_str()); 1085 1076 } 1086 1077 read_attr.insert(attr); … … 1103 1094 if (read_attr.find(it->first) == read_attr.end()) { 1104 1095 std::ostringstream msg; 1105 msg << "Attribute not found : " << it->first;1106 throw FormatError(msg.str());1096 msg << "Attribute not found in file: " << it->first; 1097 throw DataFormatError(msg.str().c_str()); 1107 1098 } 1108 1099 } … … 1119 1110 void run() { 1120 1111 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); 1112 if (!*_is) { 1113 throw DataFormatError("Cannot find file"); 1114 } 1121 1115 1122 1116 bool nodes_done = _skip_nodes; … … 1137 1131 1138 1132 if (line >> c) 1139 throw FormatError("Extra character atthe end of line");1133 throw DataFormatError("Extra character on the end of line"); 1140 1134 1141 1135 if (section == "nodes" && !nodes_done) { … … 1159 1153 skipSection(); 1160 1154 } 1161 } catch ( FormatError& error) {1155 } catch (DataFormatError& error) { 1162 1156 error.line(line_num); 1163 error.file(_filename);1164 1157 throw; 1165 1158 } … … 1167 1160 1168 1161 if (!nodes_done) { 1169 throw FormatError("Section @nodes not found");1162 throw DataFormatError("Section @nodes not found"); 1170 1163 } 1171 1164 1172 1165 if (!arcs_done) { 1173 throw FormatError("Section @arcs not found");1166 throw DataFormatError("Section @arcs not found"); 1174 1167 } 1175 1168 1176 1169 if (!attributes_done && !_attributes.empty()) { 1177 throw FormatError("Section @attributes not found");1170 throw DataFormatError("Section @attributes not found"); 1178 1171 } 1179 1172 … … 1255 1248 std::istream* _is; 1256 1249 bool local_is; 1257 std::string _filename;1258 1250 1259 1251 Graph& _graph; … … 1305 1297 /// file. 1306 1298 GraphReader(Graph& graph, const std::string& fn) 1307 : _is(new std::ifstream(fn.c_str())), local_is(true), 1308 _filename(fn), _graph(graph), 1299 : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph), 1309 1300 _use_nodes(false), _use_edges(false), 1310 _skip_nodes(false), _skip_edges(false) { 1311 if (!(*_is)) throw IoError("Cannot open file", fn); 1312 } 1301 _skip_nodes(false), _skip_edges(false) {} 1313 1302 1314 1303 /// \brief Constructor … … 1317 1306 /// file. 1318 1307 GraphReader(Graph& graph, const char* fn) 1319 : _is(new std::ifstream(fn)), local_is(true), 1320 _filename(fn), _graph(graph), 1308 : _is(new std::ifstream(fn)), local_is(true), _graph(graph), 1321 1309 _use_nodes(false), _use_edges(false), 1322 _skip_nodes(false), _skip_edges(false) { 1323 if (!(*_is)) throw IoError("Cannot open file", fn); 1324 } 1310 _skip_nodes(false), _skip_edges(false) {} 1325 1311 1326 1312 /// \brief Destructor … … 1691 1677 if (readSuccess() && line) line.putback(c); 1692 1678 if (!_node_maps.empty()) 1693 throw FormatError("Cannot find map names");1679 throw DataFormatError("Cannot find map names"); 1694 1680 return; 1695 1681 } … … 1705 1691 std::ostringstream msg; 1706 1692 msg << "Multiple occurence of node map: " << map; 1707 throw FormatError(msg.str());1693 throw DataFormatError(msg.str().c_str()); 1708 1694 } 1709 1695 maps.insert(std::make_pair(map, index)); … … 1716 1702 if (jt == maps.end()) { 1717 1703 std::ostringstream msg; 1718 msg << "Map not found : " << _node_maps[i].first;1719 throw FormatError(msg.str());1704 msg << "Map not found in file: " << _node_maps[i].first; 1705 throw DataFormatError(msg.str().c_str()); 1720 1706 } 1721 1707 map_index[i] = jt->second; … … 1741 1727 std::ostringstream msg; 1742 1728 msg << "Column not found (" << i + 1 << ")"; 1743 throw FormatError(msg.str());1729 throw DataFormatError(msg.str().c_str()); 1744 1730 } 1745 1731 } 1746 1732 if (line >> std::ws >> c) 1747 throw FormatError("Extra character atthe end of line");1733 throw DataFormatError("Extra character on the end of line"); 1748 1734 1749 1735 Node n; … … 1754 1740 } else { 1755 1741 if (label_index == -1) 1756 throw FormatError("Label map not found");1742 throw DataFormatError("Label map not found in file"); 1757 1743 typename std::map<std::string, Node>::iterator it = 1758 1744 _node_index.find(tokens[label_index]); … … 1760 1746 std::ostringstream msg; 1761 1747 msg << "Node with label not found: " << tokens[label_index]; 1762 throw FormatError(msg.str());1748 throw DataFormatError(msg.str().c_str()); 1763 1749 } 1764 1750 n = it->second; … … 1784 1770 if (readSuccess() && line) line.putback(c); 1785 1771 if (!_edge_maps.empty()) 1786 throw FormatError("Cannot find map names");1772 throw DataFormatError("Cannot find map names"); 1787 1773 return; 1788 1774 } … … 1798 1784 std::ostringstream msg; 1799 1785 msg << "Multiple occurence of edge map: " << map; 1800 throw FormatError(msg.str());1786 throw DataFormatError(msg.str().c_str()); 1801 1787 } 1802 1788 maps.insert(std::make_pair(map, index)); … … 1809 1795 if (jt == maps.end()) { 1810 1796 std::ostringstream msg; 1811 msg << "Map not found : " << _edge_maps[i].first;1812 throw FormatError(msg.str());1797 msg << "Map not found in file: " << _edge_maps[i].first; 1798 throw DataFormatError(msg.str().c_str()); 1813 1799 } 1814 1800 map_index[i] = jt->second; … … 1833 1819 1834 1820 if (!_reader_bits::readToken(line, source_token)) 1835 throw FormatError("Node u not found");1821 throw DataFormatError("Node u not found"); 1836 1822 1837 1823 if (!_reader_bits::readToken(line, target_token)) 1838 throw FormatError("Node v not found");1824 throw DataFormatError("Node v not found"); 1839 1825 1840 1826 std::vector<std::string> tokens(map_num); … … 1843 1829 std::ostringstream msg; 1844 1830 msg << "Column not found (" << i + 1 << ")"; 1845 throw FormatError(msg.str());1831 throw DataFormatError(msg.str().c_str()); 1846 1832 } 1847 1833 } 1848 1834 if (line >> std::ws >> c) 1849 throw FormatError("Extra character atthe end of line");1835 throw DataFormatError("Extra character on the end of line"); 1850 1836 1851 1837 Edge e; … … 1858 1844 std::ostringstream msg; 1859 1845 msg << "Item not found: " << source_token; 1860 throw FormatError(msg.str());1846 throw DataFormatError(msg.str().c_str()); 1861 1847 } 1862 1848 Node source = it->second; … … 1866 1852 std::ostringstream msg; 1867 1853 msg << "Item not found: " << target_token; 1868 throw FormatError(msg.str());1854 throw DataFormatError(msg.str().c_str()); 1869 1855 } 1870 1856 Node target = it->second; … … 1875 1861 } else { 1876 1862 if (label_index == -1) 1877 throw FormatError("Label map not found");1863 throw DataFormatError("Label map not found in file"); 1878 1864 typename std::map<std::string, Edge>::iterator it = 1879 1865 _edge_index.find(tokens[label_index]); … … 1881 1867 std::ostringstream msg; 1882 1868 msg << "Edge with label not found: " << tokens[label_index]; 1883 throw FormatError(msg.str());1869 throw DataFormatError(msg.str().c_str()); 1884 1870 } 1885 1871 e = it->second; … … 1906 1892 std::string attr, token; 1907 1893 if (!_reader_bits::readToken(line, attr)) 1908 throw FormatError("Attribute name not found");1894 throw DataFormatError("Attribute name not found"); 1909 1895 if (!_reader_bits::readToken(line, token)) 1910 throw FormatError("Attribute value not found");1896 throw DataFormatError("Attribute value not found"); 1911 1897 if (line >> c) 1912 throw FormatError("Extra character atthe end of line");1898 throw DataFormatError("Extra character on the end of line"); 1913 1899 1914 1900 { … … 1916 1902 if (it != read_attr.end()) { 1917 1903 std::ostringstream msg; 1918 msg << "Multiple occurence of attribute :" << attr;1919 throw FormatError(msg.str());1904 msg << "Multiple occurence of attribute " << attr; 1905 throw DataFormatError(msg.str().c_str()); 1920 1906 } 1921 1907 read_attr.insert(attr); … … 1938 1924 if (read_attr.find(it->first) == read_attr.end()) { 1939 1925 std::ostringstream msg; 1940 msg << "Attribute not found : " << it->first;1941 throw FormatError(msg.str());1926 msg << "Attribute not found in file: " << it->first; 1927 throw DataFormatError(msg.str().c_str()); 1942 1928 } 1943 1929 } … … 1973 1959 1974 1960 if (line >> c) 1975 throw FormatError("Extra character atthe end of line");1961 throw DataFormatError("Extra character on the end of line"); 1976 1962 1977 1963 if (section == "nodes" && !nodes_done) { … … 1995 1981 skipSection(); 1996 1982 } 1997 } catch ( FormatError& error) {1983 } catch (DataFormatError& error) { 1998 1984 error.line(line_num); 1999 error.file(_filename);2000 1985 throw; 2001 1986 } … … 2003 1988 2004 1989 if (!nodes_done) { 2005 throw FormatError("Section @nodes not found");1990 throw DataFormatError("Section @nodes not found"); 2006 1991 } 2007 1992 2008 1993 if (!edges_done) { 2009 throw FormatError("Section @edges not found");1994 throw DataFormatError("Section @edges not found"); 2010 1995 } 2011 1996 2012 1997 if (!attributes_done && !_attributes.empty()) { 2013 throw FormatError("Section @attributes not found");1998 throw DataFormatError("Section @attributes not found"); 2014 1999 } 2015 2000 … … 2072 2057 std::istream* _is; 2073 2058 bool local_is; 2074 std::string _filename;2075 2059 2076 2060 typedef std::map<std::string, _reader_bits::Section*> Sections; … … 2093 2077 /// Construct a section reader, which reads from the given file. 2094 2078 SectionReader(const std::string& fn) 2095 : _is(new std::ifstream(fn.c_str())), local_is(true), 2096 _filename(fn) { 2097 if (!(*_is)) throw IoError("Cannot open file", fn); 2098 } 2079 : _is(new std::ifstream(fn.c_str())), local_is(true) {} 2099 2080 2100 2081 /// \brief Constructor … … 2102 2083 /// Construct a section reader, which reads from the given file. 2103 2084 SectionReader(const char* fn) 2104 : _is(new std::ifstream(fn)), local_is(true), 2105 _filename(fn) { 2106 if (!(*_is)) throw IoError("Cannot open file", fn); 2107 } 2085 : _is(new std::ifstream(fn)), local_is(true) {} 2108 2086 2109 2087 /// \brief Destructor … … 2261 2239 2262 2240 if (line >> c) 2263 throw FormatError("Extra character atthe end of line");2241 throw DataFormatError("Extra character on the end of line"); 2264 2242 2265 2243 if (extra_sections.find(section) != extra_sections.end()) { 2266 2244 std::ostringstream msg; 2267 msg << "Multiple occurence of section :" << section;2268 throw FormatError(msg.str());2245 msg << "Multiple occurence of section " << section; 2246 throw DataFormatError(msg.str().c_str()); 2269 2247 } 2270 2248 Sections::iterator it = _sections.find(section); … … 2275 2253 readLine(); 2276 2254 skipSection(); 2277 } catch ( FormatError& error) {2255 } catch (DataFormatError& error) { 2278 2256 error.line(line_num); 2279 error.file(_filename);2280 2257 throw; 2281 2258 } … … 2286 2263 std::ostringstream os; 2287 2264 os << "Cannot find section: " << it->first; 2288 throw FormatError(os.str());2265 throw DataFormatError(os.str().c_str()); 2289 2266 } 2290 2267 } … … 2386 2363 /// file. 2387 2364 LgfContents(const std::string& fn) 2388 : _is(new std::ifstream(fn.c_str())), local_is(true) { 2389 if (!(*_is)) throw IoError("Cannot open file", fn); 2390 } 2365 : _is(new std::ifstream(fn.c_str())), local_is(true) {} 2391 2366 2392 2367 /// \brief Constructor … … 2395 2370 /// file. 2396 2371 LgfContents(const char* fn) 2397 : _is(new std::ifstream(fn)), local_is(true) { 2398 if (!(*_is)) throw IoError("Cannot open file", fn); 2399 } 2372 : _is(new std::ifstream(fn)), local_is(true) {} 2400 2373 2401 2374 /// \brief Destructor -
lemon/lgf_writer.h
r294 r293 56 56 template <typename T> 57 57 bool operator<(const T&, const T&) { 58 throw FormatError("Label map is not comparable");58 throw DataFormatError("Label map is not comparable"); 59 59 } 60 60 … … 204 204 _map.find(str); 205 205 if (it == _map.end()) { 206 throw FormatError("Item not found");206 throw DataFormatError("Item not found"); 207 207 } 208 208 return it->second; … … 224 224 ::const_iterator it = _map.find(val); 225 225 if (it == _map.end()) { 226 throw FormatError("Item not found");226 throw DataFormatError("Item not found"); 227 227 } 228 228 return (_graph.direction(val) ? '+' : '-') + it->second; … … 463 463 DigraphWriter(const Digraph& digraph, const std::string& fn) 464 464 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), 465 _skip_nodes(false), _skip_arcs(false) { 466 if (!(*_os)) throw IoError("Cannot write file", fn); 467 } 465 _skip_nodes(false), _skip_arcs(false) {} 468 466 469 467 /// \brief Constructor … … 473 471 DigraphWriter(const Digraph& digraph, const char* fn) 474 472 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), 475 _skip_nodes(false), _skip_arcs(false) { 476 if (!(*_os)) throw IoError("Cannot write file", fn); 477 } 473 _skip_nodes(false), _skip_arcs(false) {} 478 474 479 475 /// \brief Destructor … … 1024 1020 GraphWriter(const Graph& graph, const std::string& fn) 1025 1021 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), 1026 _skip_nodes(false), _skip_edges(false) { 1027 if (!(*_os)) throw IoError("Cannot write file", fn); 1028 } 1022 _skip_nodes(false), _skip_edges(false) {} 1029 1023 1030 1024 /// \brief Constructor … … 1034 1028 GraphWriter(const Graph& graph, const char* fn) 1035 1029 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), 1036 _skip_nodes(false), _skip_edges(false) { 1037 if (!(*_os)) throw IoError("Cannot write file", fn); 1038 } 1030 _skip_nodes(false), _skip_edges(false) {} 1039 1031 1040 1032 /// \brief Destructor … … 1587 1579 /// Construct a section writer, which writes into the given file. 1588 1580 SectionWriter(const std::string& fn) 1589 : _os(new std::ofstream(fn.c_str())), local_os(true) { 1590 if (!(*_os)) throw IoError("Cannot write file", fn); 1591 } 1581 : _os(new std::ofstream(fn.c_str())), local_os(true) {} 1592 1582 1593 1583 /// \brief Constructor … … 1595 1585 /// Construct a section writer, which writes into the given file. 1596 1586 SectionWriter(const char* fn) 1597 : _os(new std::ofstream(fn)), local_os(true) { 1598 if (!(*_os)) throw IoError("Cannot write file", fn); 1599 } 1587 : _os(new std::ofstream(fn)), local_os(true) {} 1600 1588 1601 1589 /// \brief Destructor
Note: See TracChangeset
for help on using the changeset viewer.