gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Changing parameter order in exception classes + improvements
0 4 0
default
4 files changed with 82 insertions and 85 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -43,7 +43,7 @@
43 43
  public:
44
    ///\e Constructor
45
    Exception() {}
46
    ///\e Virtual destructor
44
    ///Constructor
45
    Exception() throw() {}
46
    ///Virtual destructor
47 47
    virtual ~Exception() throw() {}
48
    ///\e A short description of the exception
48
    ///A short description of the exception
49 49
    virtual const char* what() const throw() {
... ...
@@ -66,3 +66,3 @@
66 66
    /// Copy constructor
67
    IoError(const IoError &error) {
67
    IoError(const IoError &error) throw() : Exception() {
68 68
      message(error._message);
... ...
@@ -72,3 +72,3 @@
72 72
    /// Constructor
73
    explicit IoError(const char *message) {
73
    explicit IoError(const char *message) throw() {
74 74
      IoError::message(message);
... ...
@@ -77,3 +77,3 @@
77 77
    /// Constructor
78
    explicit IoError(const std::string &message) {
78
    explicit IoError(const std::string &message) throw() {
79 79
      IoError::message(message);
... ...
@@ -82,3 +82,4 @@
82 82
    /// Constructor
83
    IoError(const std::string &file, const char *message) {
83
    explicit IoError(const char *message,
84
                     const std::string &file) throw() {
84 85
      IoError::message(message);
... ...
@@ -88,3 +89,4 @@
88 89
    /// Constructor
89
    IoError(const std::string &file, const std::string &message) {
90
    explicit IoError(const std::string &message,
91
                     const std::string &file) throw() {
90 92
      IoError::message(message);
... ...
@@ -97,3 +99,3 @@
97 99
    /// Set the error message
98
    void message(const char *message) {
100
    void message(const char *message) throw() {
99 101
      try {
... ...
@@ -104,3 +106,3 @@
104 106
    /// Set the error message
105
    void message(const std::string& message) {
107
    void message(const std::string& message) throw() {
106 108
      try {
... ...
@@ -111,3 +113,3 @@
111 113
    /// Set the file name
112
    void file(const std::string &file) {
114
    void file(const std::string &file) throw() {
113 115
      try {
... ...
@@ -118,3 +120,3 @@
118 120
    /// Returns the error message
119
    const std::string& message() const {
121
    const std::string& message() const throw() {
120 122
      return _message;
... ...
@@ -124,5 +126,4 @@
124 126
    ///
125
    /// Returns the filename or empty string if the filename was not
126
    /// specified.
127
    const std::string& file() const {
127
    /// Returns the filename or an empty string if it was not specified.
128
    const std::string& file() const throw() {
128 129
      return _file;
... ...
@@ -132,4 +133,4 @@
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() {
... ...
@@ -139,7 +140,5 @@
139 140
        oss << "lemon:IoError" << ": ";
140
        oss << message();
141
        if (!file().empty()) {
142
          oss << " (";
143
          if (!file().empty()) oss << "with file '" << file() << "'";
144
          oss << ")";
141
        oss << _message;
142
        if (!_file.empty()) {
143
          oss << " ('" << _file << "')";
145 144
        }
... ...
@@ -156,4 +155,4 @@
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 {
... ...
@@ -168,3 +167,3 @@
168 167
    /// Copy constructor
169
    FormatError(const FormatError &error) {
168
    FormatError(const FormatError &error) throw() : Exception() {
170 169
      message(error._message);
... ...
@@ -175,3 +174,3 @@
175 174
    /// Constructor
176
    explicit FormatError(const char *message) {
175
    explicit FormatError(const char *message) throw() {
177 176
      FormatError::message(message);
... ...
@@ -181,3 +180,3 @@
181 180
    /// Constructor
182
    explicit FormatError(const std::string &message) {
181
    explicit FormatError(const std::string &message) throw() {
183 182
      FormatError::message(message);
... ...
@@ -187,3 +186,4 @@
187 186
    /// Constructor
188
    FormatError(const std::string &file, int line, const char *message) {
187
    explicit FormatError(const char *message,
188
                         const std::string &file, int line = 0) throw() {
189 189
      FormatError::message(message);
... ...
@@ -194,3 +194,4 @@
194 194
    /// Constructor
195
    FormatError(const std::string &file, int line, const std::string &message) {
195
    explicit FormatError(const std::string &message,
196
                         const std::string &file, int line = 0) throw() {
196 197
      FormatError::message(message);
... ...
@@ -204,6 +205,6 @@
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 {
... ...
@@ -214,3 +215,3 @@
214 215
    /// Set the error message
215
    void message(const std::string& message) {
216
    void message(const std::string& message) throw() {
216 217
      try {
... ...
@@ -221,3 +222,3 @@
221 222
    /// Set the file name
222
    void file(const std::string &file) {
223
    void file(const std::string &file) throw() {
223 224
      try {
... ...
@@ -230,6 +231,6 @@
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;
... ...
@@ -239,5 +240,4 @@
239 240
    ///
240
    /// Returns the filename or empty string if the filename was not
241
    /// specified.
242
    const std::string& file() const {
241
    /// Returns the filename or an empty string if it was not specified.
242
    const std::string& file() const throw() {
243 243
      return _file;
... ...
@@ -254,8 +254,8 @@
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 (line() != 0) oss << "at line " << line();
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 << ")";
Ignore white space 6 line context
... ...
@@ -1172,3 +1172,3 @@
1172 1172
    delete os;
1173
    throw IoError(file_name, "Cannot write file");
1173
    throw IoError("Cannot write file", file_name);
1174 1174
  }
... ...
@@ -1193,3 +1193,3 @@
1193 1193
    delete os;
1194
    throw IoError(file_name, "Cannot write file");
1194
    throw IoError("Cannot write file", file_name);
1195 1195
  }
Show white space 6 line context
... ...
@@ -518,3 +518,3 @@
518 518
        _skip_nodes(false), _skip_arcs(false) {
519
      if (!(*_is)) throw IoError(fn, "Cannot open file");
519
      if (!(*_is)) throw IoError("Cannot open file", fn);
520 520
    }
... ...
@@ -530,3 +530,3 @@
530 530
        _skip_nodes(false), _skip_arcs(false) {
531
      if (!(*_is)) throw IoError(fn, "Cannot open file");
531
      if (!(*_is)) throw IoError("Cannot open file", fn);
532 532
    }
... ...
@@ -881,3 +881,3 @@
881 881
            std::ostringstream msg;
882
            msg << "Map not found in file: " << _node_maps[i].first;
882
            msg << "Map not found: " << _node_maps[i].first;
883 883
            throw FormatError(msg.str());
... ...
@@ -910,3 +910,3 @@
910 910
        if (line >> std::ws >> c)
911
          throw FormatError("Extra character on the end of line");
911
          throw FormatError("Extra character at the end of line");
912 912

	
... ...
@@ -919,3 +919,3 @@
919 919
          if (label_index == -1)
920
            throw FormatError("Label map not found in file");
920
            throw FormatError("Label map not found");
921 921
          typename std::map<std::string, Node>::iterator it =
... ...
@@ -974,3 +974,3 @@
974 974
            std::ostringstream msg;
975
            msg << "Map not found in file: " << _arc_maps[i].first;
975
            msg << "Map not found: " << _arc_maps[i].first;
976 976
            throw FormatError(msg.str());
... ...
@@ -1012,3 +1012,3 @@
1012 1012
        if (line >> std::ws >> c)
1013
          throw FormatError("Extra character on the end of line");
1013
          throw FormatError("Extra character at the end of line");
1014 1014

	
... ...
@@ -1040,3 +1040,3 @@
1040 1040
          if (label_index == -1)
1041
            throw FormatError("Label map not found in file");
1041
            throw FormatError("Label map not found");
1042 1042
          typename std::map<std::string, Arc>::iterator it =
... ...
@@ -1075,3 +1075,3 @@
1075 1075
        if (line >> c)
1076
          throw FormatError("Extra character on the end of line");
1076
          throw FormatError("Extra character at the end of line");
1077 1077

	
... ...
@@ -1081,3 +1081,3 @@
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());
... ...
@@ -1103,3 +1103,3 @@
1103 1103
          std::ostringstream msg;
1104
          msg << "Attribute not found in file: " << it->first;
1104
          msg << "Attribute not found: " << it->first;
1105 1105
          throw FormatError(msg.str());
... ...
@@ -1119,5 +1119,2 @@
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

	
... ...
@@ -1140,3 +1137,3 @@
1140 1137
          if (line >> c)
1141
            throw FormatError("Extra character on the end of line");
1138
            throw FormatError("Extra character at the end of line");
1142 1139

	
... ...
@@ -1310,3 +1307,3 @@
1310 1307
        _skip_nodes(false), _skip_edges(false) {
1311
      if (!(*_is)) throw IoError(fn, "Cannot open file");
1308
      if (!(*_is)) throw IoError("Cannot open file", fn);
1312 1309
    }
... ...
@@ -1322,3 +1319,3 @@
1322 1319
        _skip_nodes(false), _skip_edges(false) {
1323
      if (!(*_is)) throw IoError(fn, "Cannot open file");
1320
      if (!(*_is)) throw IoError("Cannot open file", fn);
1324 1321
    }
... ...
@@ -1717,3 +1714,3 @@
1717 1714
            std::ostringstream msg;
1718
            msg << "Map not found in file: " << _node_maps[i].first;
1715
            msg << "Map not found: " << _node_maps[i].first;
1719 1716
            throw FormatError(msg.str());
... ...
@@ -1746,3 +1743,3 @@
1746 1743
        if (line >> std::ws >> c)
1747
          throw FormatError("Extra character on the end of line");
1744
          throw FormatError("Extra character at the end of line");
1748 1745

	
... ...
@@ -1755,3 +1752,3 @@
1755 1752
          if (label_index == -1)
1756
            throw FormatError("Label map not found in file");
1753
            throw FormatError("Label map not found");
1757 1754
          typename std::map<std::string, Node>::iterator it =
... ...
@@ -1810,3 +1807,3 @@
1810 1807
            std::ostringstream msg;
1811
            msg << "Map not found in file: " << _edge_maps[i].first;
1808
            msg << "Map not found: " << _edge_maps[i].first;
1812 1809
            throw FormatError(msg.str());
... ...
@@ -1848,3 +1845,3 @@
1848 1845
        if (line >> std::ws >> c)
1849
          throw FormatError("Extra character on the end of line");
1846
          throw FormatError("Extra character at the end of line");
1850 1847

	
... ...
@@ -1876,3 +1873,3 @@
1876 1873
          if (label_index == -1)
1877
            throw FormatError("Label map not found in file");
1874
            throw FormatError("Label map not found");
1878 1875
          typename std::map<std::string, Edge>::iterator it =
... ...
@@ -1911,3 +1908,3 @@
1911 1908
        if (line >> c)
1912
          throw FormatError("Extra character on the end of line");
1909
          throw FormatError("Extra character at the end of line");
1913 1910

	
... ...
@@ -1917,3 +1914,3 @@
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());
... ...
@@ -1939,3 +1936,3 @@
1939 1936
          std::ostringstream msg;
1940
          msg << "Attribute not found in file: " << it->first;
1937
          msg << "Attribute not found: " << it->first;
1941 1938
          throw FormatError(msg.str());
... ...
@@ -1974,3 +1971,3 @@
1974 1971
          if (line >> c)
1975
            throw FormatError("Extra character on the end of line");
1972
            throw FormatError("Extra character at the end of line");
1976 1973

	
... ...
@@ -2097,3 +2094,3 @@
2097 2094
        _filename(fn) {
2098
      if (!(*_is)) throw IoError(fn, "Cannot open file");
2095
      if (!(*_is)) throw IoError("Cannot open file", fn);
2099 2096
    }
... ...
@@ -2106,3 +2103,3 @@
2106 2103
        _filename(fn) {
2107
      if (!(*_is)) throw IoError(fn, "Cannot open file");
2104
      if (!(*_is)) throw IoError("Cannot open file", fn);
2108 2105
    }
... ...
@@ -2263,3 +2260,3 @@
2263 2260
          if (line >> c)
2264
            throw FormatError("Extra character on the end of line");
2261
            throw FormatError("Extra character at the end of line");
2265 2262

	
... ...
@@ -2267,3 +2264,3 @@
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());
... ...
@@ -2389,3 +2386,3 @@
2389 2386
      : _is(new std::ifstream(fn.c_str())), local_is(true) {
2390
      if (!(*_is)) throw IoError(fn, "Cannot open file");
2387
      if (!(*_is)) throw IoError("Cannot open file", fn);
2391 2388
    }
... ...
@@ -2398,3 +2395,3 @@
2398 2395
      : _is(new std::ifstream(fn)), local_is(true) {
2399
      if (!(*_is)) throw IoError(fn, "Cannot open file");
2396
      if (!(*_is)) throw IoError("Cannot open file", fn);
2400 2397
    }
Ignore white space 6 line context
... ...
@@ -465,3 +465,3 @@
465 465
        _skip_nodes(false), _skip_arcs(false) {
466
      if (!(*_os)) throw IoError(fn, "Cannot write file");
466
      if (!(*_os)) throw IoError("Cannot write file", fn);
467 467
    }
... ...
@@ -475,3 +475,3 @@
475 475
        _skip_nodes(false), _skip_arcs(false) {
476
      if (!(*_os)) throw IoError(fn, "Cannot write file");
476
      if (!(*_os)) throw IoError("Cannot write file", fn);
477 477
    }
... ...
@@ -1025,3 +1025,3 @@
1025 1025
        _skip_nodes(false), _skip_edges(false) {
1026
      if (!(*_os)) throw IoError(fn, "Cannot write file");
1026
      if (!(*_os)) throw IoError("Cannot write file", fn);
1027 1027
    }
... ...
@@ -1035,3 +1035,3 @@
1035 1035
        _skip_nodes(false), _skip_edges(false) {
1036
      if (!(*_os)) throw IoError(fn, "Cannot write file");
1036
      if (!(*_os)) throw IoError("Cannot write file", fn);
1037 1037
    }
... ...
@@ -1587,3 +1587,3 @@
1587 1587
      : _os(new std::ofstream(fn.c_str())), local_os(true) {
1588
      if (!(*_os)) throw IoError(fn, "Cannot write file");
1588
      if (!(*_os)) throw IoError("Cannot write file", fn);
1589 1589
    }
... ...
@@ -1595,3 +1595,3 @@
1595 1595
      : _os(new std::ofstream(fn)), local_os(true) {
1596
      if (!(*_os)) throw IoError(fn, "Cannot write file");
1596
      if (!(*_os)) throw IoError("Cannot write file", fn);
1597 1597
    }
0 comments (0 inline)