lemon/lgf_reader.h
changeset 301 9db8964f0cf6
parent 294 cbe3ec2d59d2
child 303 a3a69f5bba62
equal deleted inserted replaced
30:3194d204de78 31:6065c702c94a
   515     DigraphReader(Digraph& digraph, const std::string& fn)
   515     DigraphReader(Digraph& digraph, const std::string& fn)
   516       : _is(new std::ifstream(fn.c_str())), local_is(true),
   516       : _is(new std::ifstream(fn.c_str())), local_is(true),
   517         _filename(fn), _digraph(digraph),
   517         _filename(fn), _digraph(digraph),
   518         _use_nodes(false), _use_arcs(false),
   518         _use_nodes(false), _use_arcs(false),
   519         _skip_nodes(false), _skip_arcs(false) {
   519         _skip_nodes(false), _skip_arcs(false) {
   520       if (!(*_is)) throw IoError("Cannot open file", fn);
   520       if (!(*_is)) {
       
   521         delete _is;
       
   522         throw IoError("Cannot open file", fn);
       
   523       }
   521     }
   524     }
   522 
   525 
   523     /// \brief Constructor
   526     /// \brief Constructor
   524     ///
   527     ///
   525     /// Construct a directed graph reader, which reads from the given
   528     /// Construct a directed graph reader, which reads from the given
   527     DigraphReader(Digraph& digraph, const char* fn)
   530     DigraphReader(Digraph& digraph, const char* fn)
   528       : _is(new std::ifstream(fn)), local_is(true),
   531       : _is(new std::ifstream(fn)), local_is(true),
   529         _filename(fn), _digraph(digraph),
   532         _filename(fn), _digraph(digraph),
   530         _use_nodes(false), _use_arcs(false),
   533         _use_nodes(false), _use_arcs(false),
   531         _skip_nodes(false), _skip_arcs(false) {
   534         _skip_nodes(false), _skip_arcs(false) {
   532       if (!(*_is)) throw IoError("Cannot open file", fn);
   535       if (!(*_is)) {
       
   536         delete _is;
       
   537         throw IoError("Cannot open file", fn);
       
   538       }
   533     }
   539     }
   534 
   540 
   535     /// \brief Destructor
   541     /// \brief Destructor
   536     ~DigraphReader() {
   542     ~DigraphReader() {
   537       for (typename NodeMaps::iterator it = _node_maps.begin();
   543       for (typename NodeMaps::iterator it = _node_maps.begin();
  1306     GraphReader(Graph& graph, const std::string& fn)
  1312     GraphReader(Graph& graph, const std::string& fn)
  1307       : _is(new std::ifstream(fn.c_str())), local_is(true),
  1313       : _is(new std::ifstream(fn.c_str())), local_is(true),
  1308         _filename(fn), _graph(graph),
  1314         _filename(fn), _graph(graph),
  1309         _use_nodes(false), _use_edges(false),
  1315         _use_nodes(false), _use_edges(false),
  1310         _skip_nodes(false), _skip_edges(false) {
  1316         _skip_nodes(false), _skip_edges(false) {
  1311       if (!(*_is)) throw IoError("Cannot open file", fn);
  1317       if (!(*_is)) {
       
  1318         delete _is;
       
  1319         throw IoError("Cannot open file", fn);
       
  1320       }
  1312     }
  1321     }
  1313 
  1322 
  1314     /// \brief Constructor
  1323     /// \brief Constructor
  1315     ///
  1324     ///
  1316     /// Construct an undirected graph reader, which reads from the given
  1325     /// Construct an undirected graph reader, which reads from the given
  1318     GraphReader(Graph& graph, const char* fn)
  1327     GraphReader(Graph& graph, const char* fn)
  1319       : _is(new std::ifstream(fn)), local_is(true),
  1328       : _is(new std::ifstream(fn)), local_is(true),
  1320         _filename(fn), _graph(graph),
  1329         _filename(fn), _graph(graph),
  1321         _use_nodes(false), _use_edges(false),
  1330         _use_nodes(false), _use_edges(false),
  1322         _skip_nodes(false), _skip_edges(false) {
  1331         _skip_nodes(false), _skip_edges(false) {
  1323       if (!(*_is)) throw IoError("Cannot open file", fn);
  1332       if (!(*_is)) {
       
  1333         delete _is;
       
  1334         throw IoError("Cannot open file", fn);
       
  1335       }
  1324     }
  1336     }
  1325 
  1337 
  1326     /// \brief Destructor
  1338     /// \brief Destructor
  1327     ~GraphReader() {
  1339     ~GraphReader() {
  1328       for (typename NodeMaps::iterator it = _node_maps.begin();
  1340       for (typename NodeMaps::iterator it = _node_maps.begin();
  2092     ///
  2104     ///
  2093     /// Construct a section reader, which reads from the given file.
  2105     /// Construct a section reader, which reads from the given file.
  2094     SectionReader(const std::string& fn)
  2106     SectionReader(const std::string& fn)
  2095       : _is(new std::ifstream(fn.c_str())), local_is(true),
  2107       : _is(new std::ifstream(fn.c_str())), local_is(true),
  2096         _filename(fn) {
  2108         _filename(fn) {
  2097       if (!(*_is)) throw IoError("Cannot open file", fn);
  2109       if (!(*_is)) {
       
  2110         delete _is;
       
  2111         throw IoError("Cannot open file", fn);
       
  2112       }
  2098     }
  2113     }
  2099 
  2114 
  2100     /// \brief Constructor
  2115     /// \brief Constructor
  2101     ///
  2116     ///
  2102     /// Construct a section reader, which reads from the given file.
  2117     /// Construct a section reader, which reads from the given file.
  2103     SectionReader(const char* fn)
  2118     SectionReader(const char* fn)
  2104       : _is(new std::ifstream(fn)), local_is(true),
  2119       : _is(new std::ifstream(fn)), local_is(true),
  2105         _filename(fn) {
  2120         _filename(fn) {
  2106       if (!(*_is)) throw IoError("Cannot open file", fn);
  2121       if (!(*_is)) {
       
  2122         delete _is;
       
  2123         throw IoError("Cannot open file", fn);
       
  2124       }
  2107     }
  2125     }
  2108 
  2126 
  2109     /// \brief Destructor
  2127     /// \brief Destructor
  2110     ~SectionReader() {
  2128     ~SectionReader() {
  2111       for (Sections::iterator it = _sections.begin();
  2129       for (Sections::iterator it = _sections.begin();
  2384     ///
  2402     ///
  2385     /// Construct an \e LGF contents reader, which reads from the given
  2403     /// Construct an \e LGF contents reader, which reads from the given
  2386     /// file.
  2404     /// file.
  2387     LgfContents(const std::string& fn)
  2405     LgfContents(const std::string& fn)
  2388       : _is(new std::ifstream(fn.c_str())), local_is(true) {
  2406       : _is(new std::ifstream(fn.c_str())), local_is(true) {
  2389       if (!(*_is)) throw IoError("Cannot open file", fn);
  2407       if (!(*_is)) {
       
  2408         delete _is;
       
  2409         throw IoError("Cannot open file", fn);
       
  2410       }
  2390     }
  2411     }
  2391 
  2412 
  2392     /// \brief Constructor
  2413     /// \brief Constructor
  2393     ///
  2414     ///
  2394     /// Construct an \e LGF contents reader, which reads from the given
  2415     /// Construct an \e LGF contents reader, which reads from the given
  2395     /// file.
  2416     /// file.
  2396     LgfContents(const char* fn)
  2417     LgfContents(const char* fn)
  2397       : _is(new std::ifstream(fn)), local_is(true) {
  2418       : _is(new std::ifstream(fn)), local_is(true) {
  2398       if (!(*_is)) throw IoError("Cannot open file", fn);
  2419       if (!(*_is)) {
       
  2420         delete _is;
       
  2421         throw IoError("Cannot open file", fn);
       
  2422       }
  2399     }
  2423     }
  2400 
  2424 
  2401     /// \brief Destructor
  2425     /// \brief Destructor
  2402     ~LgfContents() {
  2426     ~LgfContents() {
  2403       if (local_is) delete _is;
  2427       if (local_is) delete _is;