lemon/lgf_reader.h
changeset 291 d901321d6555
parent 290 f6899946c1ac
child 294 cbe3ec2d59d2
     1.1 --- a/lemon/lgf_reader.h	Tue Sep 30 20:53:18 2008 +0200
     1.2 +++ b/lemon/lgf_reader.h	Wed Oct 01 11:58:03 2008 +0200
     1.3 @@ -516,7 +516,7 @@
     1.4          _filename(fn), _digraph(digraph),
     1.5          _use_nodes(false), _use_arcs(false),
     1.6          _skip_nodes(false), _skip_arcs(false) {
     1.7 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
     1.8 +      if (!(*_is)) throw IoError("Cannot open file", fn);
     1.9      }
    1.10  
    1.11      /// \brief Constructor
    1.12 @@ -528,7 +528,7 @@
    1.13          _filename(fn), _digraph(digraph),
    1.14          _use_nodes(false), _use_arcs(false),
    1.15          _skip_nodes(false), _skip_arcs(false) {
    1.16 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
    1.17 +      if (!(*_is)) throw IoError("Cannot open file", fn);
    1.18      }
    1.19  
    1.20      /// \brief Destructor
    1.21 @@ -879,7 +879,7 @@
    1.22              maps.find(_node_maps[i].first);
    1.23            if (jt == maps.end()) {
    1.24              std::ostringstream msg;
    1.25 -            msg << "Map not found in file: " << _node_maps[i].first;
    1.26 +            msg << "Map not found: " << _node_maps[i].first;
    1.27              throw FormatError(msg.str());
    1.28            }
    1.29            map_index[i] = jt->second;
    1.30 @@ -908,7 +908,7 @@
    1.31            }
    1.32          }
    1.33          if (line >> std::ws >> c)
    1.34 -          throw FormatError("Extra character on the end of line");
    1.35 +          throw FormatError("Extra character at the end of line");
    1.36  
    1.37          Node n;
    1.38          if (!_use_nodes) {
    1.39 @@ -917,7 +917,7 @@
    1.40              _node_index.insert(std::make_pair(tokens[label_index], n));
    1.41          } else {
    1.42            if (label_index == -1)
    1.43 -            throw FormatError("Label map not found in file");
    1.44 +            throw FormatError("Label map not found");
    1.45            typename std::map<std::string, Node>::iterator it =
    1.46              _node_index.find(tokens[label_index]);
    1.47            if (it == _node_index.end()) {
    1.48 @@ -972,7 +972,7 @@
    1.49              maps.find(_arc_maps[i].first);
    1.50            if (jt == maps.end()) {
    1.51              std::ostringstream msg;
    1.52 -            msg << "Map not found in file: " << _arc_maps[i].first;
    1.53 +            msg << "Map not found: " << _arc_maps[i].first;
    1.54              throw FormatError(msg.str());
    1.55            }
    1.56            map_index[i] = jt->second;
    1.57 @@ -1010,7 +1010,7 @@
    1.58            }
    1.59          }
    1.60          if (line >> std::ws >> c)
    1.61 -          throw FormatError("Extra character on the end of line");
    1.62 +          throw FormatError("Extra character at the end of line");
    1.63  
    1.64          Arc a;
    1.65          if (!_use_arcs) {
    1.66 @@ -1038,7 +1038,7 @@
    1.67              _arc_index.insert(std::make_pair(tokens[label_index], a));
    1.68          } else {
    1.69            if (label_index == -1)
    1.70 -            throw FormatError("Label map not found in file");
    1.71 +            throw FormatError("Label map not found");
    1.72            typename std::map<std::string, Arc>::iterator it =
    1.73              _arc_index.find(tokens[label_index]);
    1.74            if (it == _arc_index.end()) {
    1.75 @@ -1073,13 +1073,13 @@
    1.76          if (!_reader_bits::readToken(line, token))
    1.77            throw FormatError("Attribute value not found");
    1.78          if (line >> c)
    1.79 -          throw FormatError("Extra character on the end of line");
    1.80 +          throw FormatError("Extra character at the end of line");
    1.81  
    1.82          {
    1.83            std::set<std::string>::iterator it = read_attr.find(attr);
    1.84            if (it != read_attr.end()) {
    1.85              std::ostringstream msg;
    1.86 -            msg << "Multiple occurence of attribute " << attr;
    1.87 +            msg << "Multiple occurence of attribute: " << attr;
    1.88              throw FormatError(msg.str());
    1.89            }
    1.90            read_attr.insert(attr);
    1.91 @@ -1101,7 +1101,7 @@
    1.92             it != _attributes.end(); ++it) {
    1.93          if (read_attr.find(it->first) == read_attr.end()) {
    1.94            std::ostringstream msg;
    1.95 -          msg << "Attribute not found in file: " << it->first;
    1.96 +          msg << "Attribute not found: " << it->first;
    1.97            throw FormatError(msg.str());
    1.98          }
    1.99        }
   1.100 @@ -1117,9 +1117,6 @@
   1.101      /// This function starts the batch processing
   1.102      void run() {
   1.103        LEMON_ASSERT(_is != 0, "This reader assigned to an other reader");
   1.104 -      if (!*_is) {
   1.105 -        throw FormatError("Cannot find file");
   1.106 -      }
   1.107  
   1.108        bool nodes_done = _skip_nodes;
   1.109        bool arcs_done = _skip_arcs;
   1.110 @@ -1138,7 +1135,7 @@
   1.111            _reader_bits::readToken(line, caption);
   1.112  
   1.113            if (line >> c)
   1.114 -            throw FormatError("Extra character on the end of line");
   1.115 +            throw FormatError("Extra character at the end of line");
   1.116  
   1.117            if (section == "nodes" && !nodes_done) {
   1.118              if (_nodes_caption.empty() || _nodes_caption == caption) {
   1.119 @@ -1308,7 +1305,7 @@
   1.120          _filename(fn), _graph(graph),
   1.121          _use_nodes(false), _use_edges(false),
   1.122          _skip_nodes(false), _skip_edges(false) {
   1.123 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
   1.124 +      if (!(*_is)) throw IoError("Cannot open file", fn);
   1.125      }
   1.126  
   1.127      /// \brief Constructor
   1.128 @@ -1320,7 +1317,7 @@
   1.129          _filename(fn), _graph(graph),
   1.130          _use_nodes(false), _use_edges(false),
   1.131          _skip_nodes(false), _skip_edges(false) {
   1.132 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
   1.133 +      if (!(*_is)) throw IoError("Cannot open file", fn);
   1.134      }
   1.135  
   1.136      /// \brief Destructor
   1.137 @@ -1715,7 +1712,7 @@
   1.138              maps.find(_node_maps[i].first);
   1.139            if (jt == maps.end()) {
   1.140              std::ostringstream msg;
   1.141 -            msg << "Map not found in file: " << _node_maps[i].first;
   1.142 +            msg << "Map not found: " << _node_maps[i].first;
   1.143              throw FormatError(msg.str());
   1.144            }
   1.145            map_index[i] = jt->second;
   1.146 @@ -1744,7 +1741,7 @@
   1.147            }
   1.148          }
   1.149          if (line >> std::ws >> c)
   1.150 -          throw FormatError("Extra character on the end of line");
   1.151 +          throw FormatError("Extra character at the end of line");
   1.152  
   1.153          Node n;
   1.154          if (!_use_nodes) {
   1.155 @@ -1753,7 +1750,7 @@
   1.156              _node_index.insert(std::make_pair(tokens[label_index], n));
   1.157          } else {
   1.158            if (label_index == -1)
   1.159 -            throw FormatError("Label map not found in file");
   1.160 +            throw FormatError("Label map not found");
   1.161            typename std::map<std::string, Node>::iterator it =
   1.162              _node_index.find(tokens[label_index]);
   1.163            if (it == _node_index.end()) {
   1.164 @@ -1808,7 +1805,7 @@
   1.165              maps.find(_edge_maps[i].first);
   1.166            if (jt == maps.end()) {
   1.167              std::ostringstream msg;
   1.168 -            msg << "Map not found in file: " << _edge_maps[i].first;
   1.169 +            msg << "Map not found: " << _edge_maps[i].first;
   1.170              throw FormatError(msg.str());
   1.171            }
   1.172            map_index[i] = jt->second;
   1.173 @@ -1846,7 +1843,7 @@
   1.174            }
   1.175          }
   1.176          if (line >> std::ws >> c)
   1.177 -          throw FormatError("Extra character on the end of line");
   1.178 +          throw FormatError("Extra character at the end of line");
   1.179  
   1.180          Edge e;
   1.181          if (!_use_edges) {
   1.182 @@ -1874,7 +1871,7 @@
   1.183              _edge_index.insert(std::make_pair(tokens[label_index], e));
   1.184          } else {
   1.185            if (label_index == -1)
   1.186 -            throw FormatError("Label map not found in file");
   1.187 +            throw FormatError("Label map not found");
   1.188            typename std::map<std::string, Edge>::iterator it =
   1.189              _edge_index.find(tokens[label_index]);
   1.190            if (it == _edge_index.end()) {
   1.191 @@ -1909,13 +1906,13 @@
   1.192          if (!_reader_bits::readToken(line, token))
   1.193            throw FormatError("Attribute value not found");
   1.194          if (line >> c)
   1.195 -          throw FormatError("Extra character on the end of line");
   1.196 +          throw FormatError("Extra character at the end of line");
   1.197  
   1.198          {
   1.199            std::set<std::string>::iterator it = read_attr.find(attr);
   1.200            if (it != read_attr.end()) {
   1.201              std::ostringstream msg;
   1.202 -            msg << "Multiple occurence of attribute " << attr;
   1.203 +            msg << "Multiple occurence of attribute: " << attr;
   1.204              throw FormatError(msg.str());
   1.205            }
   1.206            read_attr.insert(attr);
   1.207 @@ -1937,7 +1934,7 @@
   1.208             it != _attributes.end(); ++it) {
   1.209          if (read_attr.find(it->first) == read_attr.end()) {
   1.210            std::ostringstream msg;
   1.211 -          msg << "Attribute not found in file: " << it->first;
   1.212 +          msg << "Attribute not found: " << it->first;
   1.213            throw FormatError(msg.str());
   1.214          }
   1.215        }
   1.216 @@ -1972,7 +1969,7 @@
   1.217            _reader_bits::readToken(line, caption);
   1.218  
   1.219            if (line >> c)
   1.220 -            throw FormatError("Extra character on the end of line");
   1.221 +            throw FormatError("Extra character at the end of line");
   1.222  
   1.223            if (section == "nodes" && !nodes_done) {
   1.224              if (_nodes_caption.empty() || _nodes_caption == caption) {
   1.225 @@ -2095,7 +2092,7 @@
   1.226      SectionReader(const std::string& fn)
   1.227        : _is(new std::ifstream(fn.c_str())), local_is(true),
   1.228          _filename(fn) {
   1.229 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
   1.230 +      if (!(*_is)) throw IoError("Cannot open file", fn);
   1.231      }
   1.232  
   1.233      /// \brief Constructor
   1.234 @@ -2104,7 +2101,7 @@
   1.235      SectionReader(const char* fn)
   1.236        : _is(new std::ifstream(fn)), local_is(true),
   1.237          _filename(fn) {
   1.238 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
   1.239 +      if (!(*_is)) throw IoError("Cannot open file", fn);
   1.240      }
   1.241  
   1.242      /// \brief Destructor
   1.243 @@ -2261,11 +2258,11 @@
   1.244            _reader_bits::readToken(line, caption);
   1.245  
   1.246            if (line >> c)
   1.247 -            throw FormatError("Extra character on the end of line");
   1.248 +            throw FormatError("Extra character at the end of line");
   1.249  
   1.250            if (extra_sections.find(section) != extra_sections.end()) {
   1.251              std::ostringstream msg;
   1.252 -            msg << "Multiple occurence of section " << section;
   1.253 +            msg << "Multiple occurence of section: " << section;
   1.254              throw FormatError(msg.str());
   1.255            }
   1.256            Sections::iterator it = _sections.find(section);
   1.257 @@ -2387,7 +2384,7 @@
   1.258      /// file.
   1.259      LgfContents(const std::string& fn)
   1.260        : _is(new std::ifstream(fn.c_str())), local_is(true) {
   1.261 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
   1.262 +      if (!(*_is)) throw IoError("Cannot open file", fn);
   1.263      }
   1.264  
   1.265      /// \brief Constructor
   1.266 @@ -2396,7 +2393,7 @@
   1.267      /// file.
   1.268      LgfContents(const char* fn)
   1.269        : _is(new std::ifstream(fn)), local_is(true) {
   1.270 -      if (!(*_is)) throw IoError(fn, "Cannot open file");
   1.271 +      if (!(*_is)) throw IoError("Cannot open file", fn);
   1.272      }
   1.273  
   1.274      /// \brief Destructor