Changeset 1157:3996d2098090 in lemon-0.x for src
- Timestamp:
- 02/19/05 22:11:20 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1558
- Location:
- src
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/lemon/error.h
r1151 r1157 1 1 /* -*- C++ -*- 2 * 2 3 * src/lemon/error.h - Part of LEMON, a generic C++ optimization library 3 4 * 4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 5 * (Egervary Combinatorial Optimization Research Group, EGRES). 5 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi 6 * Kutatocsoport (Egervary Combinatorial Optimization Research Group, 7 * EGRES). 6 8 * 7 9 * Permission to use, modify and distribute this software is granted … … 27 29 #include <iostream> 28 30 #include <cstdlib> 29 30 #include <boost/shared_ptr.hpp> 31 #include <memory> 31 32 32 33 namespace lemon { … … 43 44 protected: 44 45 ///\e 45 boost::shared_ptr<std::ostringstream> buf; 46 ///\todo The good solution is boost:shared_ptr... 47 mutable 48 std::auto_ptr<std::ostringstream> buf; 46 49 47 50 ///\e … … 53 56 buf.reset(); 54 57 } 55 return buf ;58 return buf.get(); 56 59 } 57 60 … … 60 63 ///\e 61 64 ErrorMessage() throw() { init(); } 65 66 ErrorMessage(const ErrorMessage& em) throw() : buf(em.buf) { } 62 67 63 68 ///\e … … 76 81 template <typename T> 77 82 ErrorMessage& operator<<(const T &t) throw() { 78 if( ! buf) return *this;83 if( ! buf.get() ) return *this; 79 84 80 85 try { … … 88 93 ///\e 89 94 const char* message() throw() { 90 if( ! buf) return 0;95 if( ! buf.get() ) return 0; 91 96 92 97 const char* mes = 0; … … 188 193 const char *_message; 189 194 int _line; 190 boost::shared_ptr<std::string> _file; 191 192 public: 195 196 ///\todo Much better solution is boost::shared_ptr 197 mutable 198 std::auto_ptr<std::string> _file; 199 200 public: 201 202 DataFormatError(const DataFormatError &dfe) : 203 IOError(dfe), _message(dfe._message), _line(dfe._line), 204 _file(dfe._file) {} 205 193 206 ///\e 194 207 explicit DataFormatError(const char *the_message) … … 223 236 /// Returns \e "(unknown)" if the filename was not specified. 224 237 const char* file() const { 225 if( _file )238 if( _file.get() ) 226 239 return _file->c_str(); 227 240 else … … 235 248 std::ostringstream ostr; 236 249 ostr << _message; 237 if( _file || _line ) {250 if( _file.get() || _line ) { 238 251 ostr << " ("; 239 if( _file ) ostr << "in file '" << *_file << "'";240 if( _file && _line ) ostr << " ";252 if( _file.get() ) ostr << "in file '" << *_file << "'"; 253 if( _file.get() && _line ) ostr << " "; 241 254 if( _line ) ostr << "at line " << _line; 242 255 ostr << ")";
Note: See TracChangeset
for help on using the changeset viewer.