Ticket #17: 8bed1c3a6080.patch
File 8bed1c3a6080.patch, 31.0 KB (added by , 16 years ago) |
---|
-
lemon/arg_parser.h
# HG changeset patch # User Balazs Dezso <deba@inf.elte.hu> # Date 1222674159 -7200 # Node ID 8bed1c3a6080206eb1bc9b32fd70783db5c71358 # Parent bb40b6db0a587e98535e84eb2b9c92f3df972b6a Simplifying exceptions - Using asserts instead of exceptions for unitialized parameters - Only the IO exceptions are used in the lemon - DataFormatError is renamed to IoError - The IoError is simplified diff --git a/lemon/arg_parser.h b/lemon/arg_parser.h
a b 310 310 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, otherwise it 314 ///throws an exception (i.e. it performs runtime type checking). 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). 315 316 class RefType 316 317 { 317 318 const ArgParser &_parser; -
lemon/bfs.h
diff --git a/lemon/bfs.h b/lemon/bfs.h
a b 135 135 #endif 136 136 class Bfs { 137 137 public: 138 ///\ref Exception for uninitialized parameters.139 140 ///This error represents problems in the initialization of the141 ///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 };148 138 149 139 ///The type of the digraph the algorithm runs on. 150 140 typedef typename TR::Digraph Digraph; … … 232 222 typedef T PredMap; 233 223 static PredMap *createPredMap(const Digraph &) 234 224 { 235 throw UninitializedParameter();225 LEMON_ASSERT(false, "PredMap is not initialized"); 236 226 } 237 227 }; 238 228 ///\brief \ref named-templ-param "Named parameter" for setting … … 250 240 typedef T DistMap; 251 241 static DistMap *createDistMap(const Digraph &) 252 242 { 253 throw UninitializedParameter();243 LEMON_ASSERT(false, "DistMap is not initialized"); 254 244 } 255 245 }; 256 246 ///\brief \ref named-templ-param "Named parameter" for setting … … 268 258 typedef T ReachedMap; 269 259 static ReachedMap *createReachedMap(const Digraph &) 270 260 { 271 throw UninitializedParameter();261 LEMON_ASSERT(false, "ReachedMap is not initialized"); 272 262 } 273 263 }; 274 264 ///\brief \ref named-templ-param "Named parameter" for setting … … 286 276 typedef T ProcessedMap; 287 277 static ProcessedMap *createProcessedMap(const Digraph &) 288 278 { 289 throw UninitializedParameter();279 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 290 280 } 291 281 }; 292 282 ///\brief \ref named-templ-param "Named parameter" for setting … … 1040 1030 ///\return \c true if \c t is reachable form \c s. 1041 1031 bool run(Node s, Node t) 1042 1032 { 1043 if (s==INVALID || t==INVALID) throw UninitializedParameter();1044 1033 Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g)); 1045 1034 if (Base::_pred) 1046 1035 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); … … 1323 1312 class BfsVisit { 1324 1313 public: 1325 1314 1326 /// \brief \ref Exception for uninitialized parameters.1327 ///1328 /// This error represents problems in the initialization1329 /// 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 1338 1315 ///The traits class. 1339 1316 typedef _Traits Traits; 1340 1317 … … 1389 1366 struct SetReachedMapTraits : public Traits { 1390 1367 typedef T ReachedMap; 1391 1368 static ReachedMap *createReachedMap(const Digraph &digraph) { 1392 throw UninitializedParameter();1369 LEMON_ASSERT(false, "ReachedMap is not initialized"); 1393 1370 } 1394 1371 }; 1395 1372 /// \brief \ref named-templ-param "Named parameter" for setting -
lemon/concepts/heap.h
diff --git a/lemon/concepts/heap.h b/lemon/concepts/heap.h
a b 129 129 /// already stored in the heap. 130 130 /// Otherwise it inserts the given item with the given priority. 131 131 /// 132 /// It may throw an \ref UnderflowPriorityException.133 132 /// \param i The item. 134 133 /// \param p The priority. 135 134 void set(const Item &i, const Prio &p) {} -
lemon/dfs.h
diff --git a/lemon/dfs.h b/lemon/dfs.h
a b 136 136 #endif 137 137 class Dfs { 138 138 public: 139 ///\ref Exception for uninitialized parameters.140 141 ///This error represents problems in the initialization of the142 ///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 };149 139 150 140 ///The type of the digraph the algorithm runs on. 151 141 typedef typename TR::Digraph Digraph; … … 232 222 typedef T PredMap; 233 223 static PredMap *createPredMap(const Digraph &) 234 224 { 235 throw UninitializedParameter();225 LEMON_ASSERT(false, "PredMap is not initialized"); 236 226 } 237 227 }; 238 228 ///\brief \ref named-templ-param "Named parameter" for setting … … 250 240 typedef T DistMap; 251 241 static DistMap *createDistMap(const Digraph &) 252 242 { 253 throw UninitializedParameter();243 LEMON_ASSERT(false, "DistMap is not initialized"); 254 244 } 255 245 }; 256 246 ///\brief \ref named-templ-param "Named parameter" for setting … … 268 258 typedef T ReachedMap; 269 259 static ReachedMap *createReachedMap(const Digraph &) 270 260 { 271 throw UninitializedParameter();261 LEMON_ASSERT(false, "ReachedMap is not initialized"); 272 262 } 273 263 }; 274 264 ///\brief \ref named-templ-param "Named parameter" for setting … … 286 276 typedef T ProcessedMap; 287 277 static ProcessedMap *createProcessedMap(const Digraph &) 288 278 { 289 throw UninitializedParameter();279 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 290 280 } 291 281 }; 292 282 ///\brief \ref named-templ-param "Named parameter" for setting … … 974 964 ///\return \c true if \c t is reachable form \c s. 975 965 bool run(Node s, Node t) 976 966 { 977 if (s==INVALID || t==INVALID) throw UninitializedParameter();978 967 Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g)); 979 968 if (Base::_pred) 980 969 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); … … 1270 1259 class DfsVisit { 1271 1260 public: 1272 1261 1273 /// \brief \ref Exception for uninitialized parameters.1274 ///1275 /// This error represents problems in the initialization1276 /// 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 1285 1262 ///The traits class. 1286 1263 typedef _Traits Traits; 1287 1264 … … 1336 1313 struct SetReachedMapTraits : public Traits { 1337 1314 typedef T ReachedMap; 1338 1315 static ReachedMap *createReachedMap(const Digraph &digraph) { 1339 throw UninitializedParameter();1316 LEMON_ASSERT(false, "ReachedMap is not initialized"); 1340 1317 } 1341 1318 }; 1342 1319 /// \brief \ref named-templ-param "Named parameter" for setting -
lemon/dijkstra.h
diff --git a/lemon/dijkstra.h b/lemon/dijkstra.h
a b 225 225 #endif 226 226 class Dijkstra { 227 227 public: 228 ///\ref Exception for uninitialized parameters.229 230 ///This error represents problems in the initialization of the231 ///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 };238 228 239 229 ///The type of the digraph the algorithm runs on. 240 230 typedef typename TR::Digraph Digraph; … … 332 322 typedef T PredMap; 333 323 static PredMap *createPredMap(const Digraph &) 334 324 { 335 throw UninitializedParameter();325 LEMON_ASSERT(false, "PredMap is not initialized"); 336 326 } 337 327 }; 338 328 ///\brief \ref named-templ-param "Named parameter" for setting … … 351 341 typedef T DistMap; 352 342 static DistMap *createDistMap(const Digraph &) 353 343 { 354 throw UninitializedParameter();344 LEMON_ASSERT(false, "DistMap is not initialized"); 355 345 } 356 346 }; 357 347 ///\brief \ref named-templ-param "Named parameter" for setting … … 370 360 typedef T ProcessedMap; 371 361 static ProcessedMap *createProcessedMap(const Digraph &) 372 362 { 373 throw UninitializedParameter();363 LEMON_ASSERT(false, "ProcessedMap is not initialized"); 374 364 } 375 365 }; 376 366 ///\brief \ref named-templ-param "Named parameter" for setting … … 408 398 typedef CR HeapCrossRef; 409 399 typedef H Heap; 410 400 static HeapCrossRef *createHeapCrossRef(const Digraph &) { 411 throw UninitializedParameter();401 LEMON_ASSERT(false, "HeapCrossRef is not initialized"); 412 402 } 413 403 static Heap *createHeap(HeapCrossRef &) 414 404 { 415 throw UninitializedParameter();405 LEMON_ASSERT(false, "Heap is not initialized"); 416 406 } 417 407 }; 418 408 ///\brief \ref named-templ-param "Named parameter" for setting … … 1158 1148 ///in order to compute the shortest path to each node. 1159 1149 void run(Node s) 1160 1150 { 1161 if (s==INVALID) throw UninitializedParameter();1162 1151 Dijkstra<Digraph,LengthMap,TR> 1163 1152 dijk(*reinterpret_cast<const Digraph*>(Base::_g), 1164 1153 *reinterpret_cast<const LengthMap*>(Base::_length)); … … 1180 1169 ///\return \c true if \c t is reachable form \c s. 1181 1170 bool run(Node s, Node t) 1182 1171 { 1183 if (s==INVALID || t==INVALID) throw UninitializedParameter();1184 1172 Dijkstra<Digraph,LengthMap,TR> 1185 1173 dijk(*reinterpret_cast<const Digraph*>(Base::_g), 1186 1174 *reinterpret_cast<const LengthMap*>(Base::_length)); -
lemon/error.h
diff --git a/lemon/error.h b/lemon/error.h
a b 35 35 /// \addtogroup exceptions 36 36 /// @{ 37 37 38 /// \brief Exception safe wrapperclass.38 /// \brief Generic exception 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 in100 /// exception classes (therefore the name).101 class ErrorMessage {102 protected:103 ///\e104 105 mutable std::auto_ptr<std::ostringstream> buf;106 107 ///\e108 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 ///\e121 ErrorMessage() throw() { init(); }122 123 ErrorMessage(const ErrorMessage& em) throw() : buf(em.buf) { }124 125 ///\e126 ErrorMessage(const char *msg) throw() {127 init();128 *this << msg;129 }130 131 ///\e132 ErrorMessage(const std::string &msg) throw() {133 init();134 *this << msg;135 }136 137 ///\e138 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 ///\e152 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 167 40 /// Base class for exceptions used in LEMON. 168 41 /// 169 42 class Exception : public std::exception { 170 43 public: 171 ///\e 44 ///\e Constructor 172 45 Exception() {} 173 ///\e 46 ///\e Virtual destructor 174 47 virtual ~Exception() throw() {} 175 ///\e 48 ///\e A short description of the exception 176 49 virtual const char* what() const throw() { 177 50 return "lemon::Exception"; 178 51 } 179 52 }; 180 53 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 the185 /// program runs (e.g. violations of class invariants).186 ///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 initialization198 /// 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 caught211 /// 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 54 ///\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 { 55 class DataFormatError : Exception { 237 56 protected: 238 ExceptionMember<std::string>_message;239 ExceptionMember<std::string>_file;57 std::string _message; 58 std::string _file; 240 59 int _line; 241 60 242 mutable ExceptionMember<std::string> _message_holder;61 mutable std::string _what; 243 62 public: 244 63 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 } 64 /// Copy constructor 65 DataFormatError(const DataFormatError &error) { 66 message(error._message); 67 file(error._file); 68 line(error._line); 274 69 } 275 70 276 /// \brief Returns the filename. 277 /// 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 } 71 /// Constructor 72 explicit DataFormatError(const char *message) { 73 DataFormatError::message(message); 74 _line = 0; 285 75 } 286 76 287 ///\e 77 /// Constructor 78 explicit DataFormatError(const std::string &message) { 79 DataFormatError::message(message); 80 _line = 0; 81 } 82 83 /// Constructor 84 DataFormatError(const std::string &file, int line, const char *message) { 85 DataFormatError::message(message); 86 DataFormatError::file(file); 87 DataFormatError::line(line); 88 } 89 90 /// Constructor 91 DataFormatError(const std::string &file, int line, 92 const std::string &message) { 93 DataFormatError::message(message); 94 DataFormatError::file(file); 95 DataFormatError::line(line); 96 } 97 98 /// Virtual destructor 99 virtual ~DataFormatError() throw() {} 100 101 /// Set the line number 102 void line(int line) { _line = line; } 103 104 /// Set the error message 105 void message(const char *message) { 106 try { 107 _message = message; 108 } catch (...) {} 109 } 110 111 /// Set the error message 112 void message(const std::string& message) { 113 try { 114 _message = message; 115 } catch (...) {} 116 } 117 118 /// Set the file name 119 void file(const std::string &file) { 120 try { 121 _file = file; 122 } catch (...) {} 123 } 124 125 /// \brief Returns the line number 126 /// 127 /// Returns the line number or zero if it was not specified. 128 int line() const { return _line; } 129 130 /// Returns the error message 131 const std::string& message() const { 132 return _message; 133 } 134 135 /// \brief Returns the filename 136 /// 137 /// Returns the filename or empty string if the filename was not 138 /// specified. 139 const std::string& file() const { 140 return _file; 141 } 142 143 /// \brief Returns a short error message 144 /// 145 /// Returns a short error message which contains the message, the 146 /// file name and the line number. 288 147 virtual const char* what() const throw() { 289 148 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 << ")"; 149 _what.clear(); 150 std::ostringstream oss; 151 oss << "lemon:DataFormatError" << ": "; 152 oss << message(); 153 if (!file().empty() || line() != 0) { 154 oss << " ("; 155 if (!file().empty()) oss << "in file '" << file() << "'"; 156 if (!file().empty() && line() != 0) oss << " "; 157 if (line() != 0) oss << "at line " << line(); 158 oss << ")"; 299 159 } 300 _ message_holder.set(ostr.str());160 _what = oss.str(); 301 161 } 302 162 catch (...) {} 303 if ( _message_holder.valid()) return _message_holder.get().c_str();304 return "lemon:DataFormatError";163 if (!_what.empty()) return _what.c_str(); 164 else return "lemon:DataFormatError"; 305 165 } 306 166 307 virtual ~DataFormatError() throw() {}308 };309 310 ///\e311 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 ///\e322 explicit FileOpenError(const std::string& fl)323 : _file(fl) {}324 325 326 ///\e327 void file(const std::string &fl) { _file.set(fl); }328 329 /// \brief Returns the filename.330 ///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 ///\e341 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());347 }348 catch (...) {}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 {356 protected: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 ///\e367 explicit IoParameterError(const char *the_message)368 : _message(the_message) {}369 370 ///\e371 IoParameterError(const char *file_name, const char *the_message)372 : _message(the_message), _file(file_name) {}373 374 ///\e375 void message(const std::string& msg) { _message.set(msg); }376 ///\e377 void file(const std::string &fl) { _file.set(fl); }378 379 ///\e380 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.389 ///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 ///\e400 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());406 }407 catch (...) {}408 if( _message_holder.valid() ) return _message_holder.get().c_str();409 return "lemon:IoParameterError";410 }411 virtual ~IoParameterError() throw() {}412 167 }; 413 168 414 169 /// @} -
lemon/lgf_reader.h
diff --git a/lemon/lgf_reader.h b/lemon/lgf_reader.h
a b 166 166 if (it == _map.end()) { 167 167 std::ostringstream msg; 168 168 msg << "Item not found: " << str; 169 throw DataFormatError(msg.str() .c_str());169 throw DataFormatError(msg.str()); 170 170 } 171 171 return it->second; 172 172 } … … 859 859 if (maps.find(map) != maps.end()) { 860 860 std::ostringstream msg; 861 861 msg << "Multiple occurence of node map: " << map; 862 throw DataFormatError(msg.str() .c_str());862 throw DataFormatError(msg.str()); 863 863 } 864 864 maps.insert(std::make_pair(map, index)); 865 865 ++index; … … 871 871 if (jt == maps.end()) { 872 872 std::ostringstream msg; 873 873 msg << "Map not found in file: " << _node_maps[i].first; 874 throw DataFormatError(msg.str() .c_str());874 throw DataFormatError(msg.str()); 875 875 } 876 876 map_index[i] = jt->second; 877 877 } … … 895 895 if (!_reader_bits::readToken(line, tokens[i])) { 896 896 std::ostringstream msg; 897 897 msg << "Column not found (" << i + 1 << ")"; 898 throw DataFormatError(msg.str() .c_str());898 throw DataFormatError(msg.str()); 899 899 } 900 900 } 901 901 if (line >> std::ws >> c) … … 914 914 if (it == _node_index.end()) { 915 915 std::ostringstream msg; 916 916 msg << "Node with label not found: " << tokens[label_index]; 917 throw DataFormatError(msg.str() .c_str());917 throw DataFormatError(msg.str()); 918 918 } 919 919 n = it->second; 920 920 } … … 952 952 if (maps.find(map) != maps.end()) { 953 953 std::ostringstream msg; 954 954 msg << "Multiple occurence of arc map: " << map; 955 throw DataFormatError(msg.str() .c_str());955 throw DataFormatError(msg.str()); 956 956 } 957 957 maps.insert(std::make_pair(map, index)); 958 958 ++index; … … 964 964 if (jt == maps.end()) { 965 965 std::ostringstream msg; 966 966 msg << "Map not found in file: " << _arc_maps[i].first; 967 throw DataFormatError(msg.str() .c_str());967 throw DataFormatError(msg.str()); 968 968 } 969 969 map_index[i] = jt->second; 970 970 } … … 997 997 if (!_reader_bits::readToken(line, tokens[i])) { 998 998 std::ostringstream msg; 999 999 msg << "Column not found (" << i + 1 << ")"; 1000 throw DataFormatError(msg.str() .c_str());1000 throw DataFormatError(msg.str()); 1001 1001 } 1002 1002 } 1003 1003 if (line >> std::ws >> c) … … 1012 1012 if (it == _node_index.end()) { 1013 1013 std::ostringstream msg; 1014 1014 msg << "Item not found: " << source_token; 1015 throw DataFormatError(msg.str() .c_str());1015 throw DataFormatError(msg.str()); 1016 1016 } 1017 1017 Node source = it->second; 1018 1018 … … 1020 1020 if (it == _node_index.end()) { 1021 1021 std::ostringstream msg; 1022 1022 msg << "Item not found: " << target_token; 1023 throw DataFormatError(msg.str() .c_str());1023 throw DataFormatError(msg.str()); 1024 1024 } 1025 1025 Node target = it->second; 1026 1026 … … 1035 1035 if (it == _arc_index.end()) { 1036 1036 std::ostringstream msg; 1037 1037 msg << "Arc with label not found: " << tokens[label_index]; 1038 throw DataFormatError(msg.str() .c_str());1038 throw DataFormatError(msg.str()); 1039 1039 } 1040 1040 a = it->second; 1041 1041 } … … 1071 1071 if (it != read_attr.end()) { 1072 1072 std::ostringstream msg; 1073 1073 msg << "Multiple occurence of attribute " << attr; 1074 throw DataFormatError(msg.str() .c_str());1074 throw DataFormatError(msg.str()); 1075 1075 } 1076 1076 read_attr.insert(attr); 1077 1077 } … … 1093 1093 if (read_attr.find(it->first) == read_attr.end()) { 1094 1094 std::ostringstream msg; 1095 1095 msg << "Attribute not found in file: " << it->first; 1096 throw DataFormatError(msg.str() .c_str());1096 throw DataFormatError(msg.str()); 1097 1097 } 1098 1098 } 1099 1099 } … … 1687 1687 if (maps.find(map) != maps.end()) { 1688 1688 std::ostringstream msg; 1689 1689 msg << "Multiple occurence of node map: " << map; 1690 throw DataFormatError(msg.str() .c_str());1690 throw DataFormatError(msg.str()); 1691 1691 } 1692 1692 maps.insert(std::make_pair(map, index)); 1693 1693 ++index; … … 1699 1699 if (jt == maps.end()) { 1700 1700 std::ostringstream msg; 1701 1701 msg << "Map not found in file: " << _node_maps[i].first; 1702 throw DataFormatError(msg.str() .c_str());1702 throw DataFormatError(msg.str()); 1703 1703 } 1704 1704 map_index[i] = jt->second; 1705 1705 } … … 1723 1723 if (!_reader_bits::readToken(line, tokens[i])) { 1724 1724 std::ostringstream msg; 1725 1725 msg << "Column not found (" << i + 1 << ")"; 1726 throw DataFormatError(msg.str() .c_str());1726 throw DataFormatError(msg.str()); 1727 1727 } 1728 1728 } 1729 1729 if (line >> std::ws >> c) … … 1742 1742 if (it == _node_index.end()) { 1743 1743 std::ostringstream msg; 1744 1744 msg << "Node with label not found: " << tokens[label_index]; 1745 throw DataFormatError(msg.str() .c_str());1745 throw DataFormatError(msg.str()); 1746 1746 } 1747 1747 n = it->second; 1748 1748 } … … 1780 1780 if (maps.find(map) != maps.end()) { 1781 1781 std::ostringstream msg; 1782 1782 msg << "Multiple occurence of edge map: " << map; 1783 throw DataFormatError(msg.str() .c_str());1783 throw DataFormatError(msg.str()); 1784 1784 } 1785 1785 maps.insert(std::make_pair(map, index)); 1786 1786 ++index; … … 1792 1792 if (jt == maps.end()) { 1793 1793 std::ostringstream msg; 1794 1794 msg << "Map not found in file: " << _edge_maps[i].first; 1795 throw DataFormatError(msg.str() .c_str());1795 throw DataFormatError(msg.str()); 1796 1796 } 1797 1797 map_index[i] = jt->second; 1798 1798 } … … 1825 1825 if (!_reader_bits::readToken(line, tokens[i])) { 1826 1826 std::ostringstream msg; 1827 1827 msg << "Column not found (" << i + 1 << ")"; 1828 throw DataFormatError(msg.str() .c_str());1828 throw DataFormatError(msg.str()); 1829 1829 } 1830 1830 } 1831 1831 if (line >> std::ws >> c) … … 1840 1840 if (it == _node_index.end()) { 1841 1841 std::ostringstream msg; 1842 1842 msg << "Item not found: " << source_token; 1843 throw DataFormatError(msg.str() .c_str());1843 throw DataFormatError(msg.str()); 1844 1844 } 1845 1845 Node source = it->second; 1846 1846 … … 1848 1848 if (it == _node_index.end()) { 1849 1849 std::ostringstream msg; 1850 1850 msg << "Item not found: " << target_token; 1851 throw DataFormatError(msg.str() .c_str());1851 throw DataFormatError(msg.str()); 1852 1852 } 1853 1853 Node target = it->second; 1854 1854 … … 1863 1863 if (it == _edge_index.end()) { 1864 1864 std::ostringstream msg; 1865 1865 msg << "Edge with label not found: " << tokens[label_index]; 1866 throw DataFormatError(msg.str() .c_str());1866 throw DataFormatError(msg.str()); 1867 1867 } 1868 1868 e = it->second; 1869 1869 } … … 1899 1899 if (it != read_attr.end()) { 1900 1900 std::ostringstream msg; 1901 1901 msg << "Multiple occurence of attribute " << attr; 1902 throw DataFormatError(msg.str() .c_str());1902 throw DataFormatError(msg.str()); 1903 1903 } 1904 1904 read_attr.insert(attr); 1905 1905 } … … 1921 1921 if (read_attr.find(it->first) == read_attr.end()) { 1922 1922 std::ostringstream msg; 1923 1923 msg << "Attribute not found in file: " << it->first; 1924 throw DataFormatError(msg.str() .c_str());1924 throw DataFormatError(msg.str()); 1925 1925 } 1926 1926 } 1927 1927 } … … 2241 2241 if (extra_sections.find(section) != extra_sections.end()) { 2242 2242 std::ostringstream msg; 2243 2243 msg << "Multiple occurence of section " << section; 2244 throw DataFormatError(msg.str() .c_str());2244 throw DataFormatError(msg.str()); 2245 2245 } 2246 2246 Sections::iterator it = _sections.find(section); 2247 2247 if (it != _sections.end()) { … … 2260 2260 if (extra_sections.find(it->first) == extra_sections.end()) { 2261 2261 std::ostringstream os; 2262 2262 os << "Cannot find section: " << it->first; 2263 throw DataFormatError(os.str() .c_str());2263 throw DataFormatError(os.str()); 2264 2264 } 2265 2265 } 2266 2266 }