1.1 --- a/lemon/lgf_reader.h Fri Jul 04 15:21:48 2008 +0200
1.2 +++ b/lemon/lgf_reader.h Fri Jul 04 16:12:31 2008 +0200
1.3 @@ -386,6 +386,18 @@
1.4
1.5 }
1.6
1.7 + template <typename Digraph>
1.8 + class DigraphReader;
1.9 +
1.10 + template <typename Digraph>
1.11 + DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph);
1.12 +
1.13 + template <typename Digraph>
1.14 + DigraphReader<Digraph> digraphReader(const std::string& fn, Digraph& digraph);
1.15 +
1.16 + template <typename Digraph>
1.17 + DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph);
1.18 +
1.19 /// \ingroup lemon_io
1.20 ///
1.21 /// \brief LGF reader for directed graphs
1.22 @@ -509,31 +521,6 @@
1.23 _use_nodes(false), _use_arcs(false),
1.24 _skip_nodes(false), _skip_arcs(false) {}
1.25
1.26 - /// \brief Copy constructor
1.27 - ///
1.28 - /// The copy constructor transfers all data from the other reader,
1.29 - /// therefore the copied reader will not be usable more.
1.30 - DigraphReader(DigraphReader& other)
1.31 - : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
1.32 - _use_nodes(other._use_nodes), _use_arcs(other._use_arcs),
1.33 - _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
1.34 -
1.35 - other._is = 0;
1.36 - other.local_is = false;
1.37 -
1.38 - _node_index.swap(other._node_index);
1.39 - _arc_index.swap(other._arc_index);
1.40 -
1.41 - _node_maps.swap(other._node_maps);
1.42 - _arc_maps.swap(other._arc_maps);
1.43 - _attributes.swap(other._attributes);
1.44 -
1.45 - _nodes_caption = other._nodes_caption;
1.46 - _arcs_caption = other._arcs_caption;
1.47 - _attributes_caption = other._attributes_caption;
1.48 -
1.49 - }
1.50 -
1.51 /// \brief Destructor
1.52 ~DigraphReader() {
1.53 for (typename NodeMaps::iterator it = _node_maps.begin();
1.54 @@ -558,7 +545,35 @@
1.55 }
1.56
1.57 private:
1.58 -
1.59 +
1.60 + friend DigraphReader<Digraph> digraphReader<>(std::istream& is,
1.61 + Digraph& digraph);
1.62 + friend DigraphReader<Digraph> digraphReader<>(const std::string& fn,
1.63 + Digraph& digraph);
1.64 + friend DigraphReader<Digraph> digraphReader<>(const char *fn,
1.65 + Digraph& digraph);
1.66 +
1.67 + DigraphReader(DigraphReader& other)
1.68 + : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
1.69 + _use_nodes(other._use_nodes), _use_arcs(other._use_arcs),
1.70 + _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
1.71 +
1.72 + other._is = 0;
1.73 + other.local_is = false;
1.74 +
1.75 + _node_index.swap(other._node_index);
1.76 + _arc_index.swap(other._arc_index);
1.77 +
1.78 + _node_maps.swap(other._node_maps);
1.79 + _arc_maps.swap(other._arc_maps);
1.80 + _attributes.swap(other._attributes);
1.81 +
1.82 + _nodes_caption = other._nodes_caption;
1.83 + _arcs_caption = other._arcs_caption;
1.84 + _attributes_caption = other._attributes_caption;
1.85 +
1.86 + }
1.87 +
1.88 DigraphReader& operator=(const DigraphReader&);
1.89
1.90 public:
1.91 @@ -1182,6 +1197,18 @@
1.92 return tmp;
1.93 }
1.94
1.95 + template <typename Graph>
1.96 + class GraphReader;
1.97 +
1.98 + template <typename Graph>
1.99 + GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
1.100 +
1.101 + template <typename Graph>
1.102 + GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
1.103 +
1.104 + template <typename Graph>
1.105 + GraphReader<Graph> graphReader(const char *fn, Graph& graph);
1.106 +
1.107 /// \ingroup lemon_io
1.108 ///
1.109 /// \brief LGF reader for undirected graphs
1.110 @@ -1260,31 +1287,6 @@
1.111 _use_nodes(false), _use_edges(false),
1.112 _skip_nodes(false), _skip_edges(false) {}
1.113
1.114 - /// \brief Copy constructor
1.115 - ///
1.116 - /// The copy constructor transfers all data from the other reader,
1.117 - /// therefore the copied reader will not be usable more.
1.118 - GraphReader(GraphReader& other)
1.119 - : _is(other._is), local_is(other.local_is), _graph(other._graph),
1.120 - _use_nodes(other._use_nodes), _use_edges(other._use_edges),
1.121 - _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
1.122 -
1.123 - other._is = 0;
1.124 - other.local_is = false;
1.125 -
1.126 - _node_index.swap(other._node_index);
1.127 - _edge_index.swap(other._edge_index);
1.128 -
1.129 - _node_maps.swap(other._node_maps);
1.130 - _edge_maps.swap(other._edge_maps);
1.131 - _attributes.swap(other._attributes);
1.132 -
1.133 - _nodes_caption = other._nodes_caption;
1.134 - _edges_caption = other._edges_caption;
1.135 - _attributes_caption = other._attributes_caption;
1.136 -
1.137 - }
1.138 -
1.139 /// \brief Destructor
1.140 ~GraphReader() {
1.141 for (typename NodeMaps::iterator it = _node_maps.begin();
1.142 @@ -1309,7 +1311,32 @@
1.143 }
1.144
1.145 private:
1.146 -
1.147 + friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph);
1.148 + friend GraphReader<Graph> graphReader<>(const std::string& fn,
1.149 + Graph& graph);
1.150 + friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph);
1.151 +
1.152 + GraphReader(GraphReader& other)
1.153 + : _is(other._is), local_is(other.local_is), _graph(other._graph),
1.154 + _use_nodes(other._use_nodes), _use_edges(other._use_edges),
1.155 + _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
1.156 +
1.157 + other._is = 0;
1.158 + other.local_is = false;
1.159 +
1.160 + _node_index.swap(other._node_index);
1.161 + _edge_index.swap(other._edge_index);
1.162 +
1.163 + _node_maps.swap(other._node_maps);
1.164 + _edge_maps.swap(other._edge_maps);
1.165 + _attributes.swap(other._attributes);
1.166 +
1.167 + _nodes_caption = other._nodes_caption;
1.168 + _edges_caption = other._edges_caption;
1.169 + _attributes_caption = other._attributes_caption;
1.170 +
1.171 + }
1.172 +
1.173 GraphReader& operator=(const GraphReader&);
1.174
1.175 public:
1.176 @@ -1977,6 +2004,12 @@
1.177 return tmp;
1.178 }
1.179
1.180 + class SectionReader;
1.181 +
1.182 + SectionReader sectionReader(std::istream& is);
1.183 + SectionReader sectionReader(const std::string& fn);
1.184 + SectionReader sectionReader(const char* fn);
1.185 +
1.186 /// \brief Section reader class
1.187 ///
1.188 /// In the \e LGF file extra sections can be placed, which contain
1.189 @@ -2019,19 +2052,6 @@
1.190 SectionReader(const char* fn)
1.191 : _is(new std::ifstream(fn)), local_is(true) {}
1.192
1.193 - /// \brief Copy constructor
1.194 - ///
1.195 - /// The copy constructor transfers all data from the other reader,
1.196 - /// therefore the copied reader will not be usable more.
1.197 - SectionReader(SectionReader& other)
1.198 - : _is(other._is), local_is(other.local_is) {
1.199 -
1.200 - other._is = 0;
1.201 - other.local_is = false;
1.202 -
1.203 - _sections.swap(other._sections);
1.204 - }
1.205 -
1.206 /// \brief Destructor
1.207 ~SectionReader() {
1.208 for (Sections::iterator it = _sections.begin();
1.209 @@ -2046,6 +2066,19 @@
1.210 }
1.211
1.212 private:
1.213 +
1.214 + friend SectionReader sectionReader(std::istream& is);
1.215 + friend SectionReader sectionReader(const std::string& fn);
1.216 + friend SectionReader sectionReader(const char* fn);
1.217 +
1.218 + SectionReader(SectionReader& other)
1.219 + : _is(other._is), local_is(other.local_is) {
1.220 +
1.221 + other._is = 0;
1.222 + other.local_is = false;
1.223 +
1.224 + _sections.swap(other._sections);
1.225 + }
1.226
1.227 SectionReader& operator=(const SectionReader&);
1.228
1.229 @@ -2295,34 +2328,19 @@
1.230 /// file.
1.231 LgfContents(const char* fn)
1.232 : _is(new std::ifstream(fn)), local_is(true) {}
1.233 -
1.234 - /// \brief Copy constructor
1.235 - ///
1.236 - /// The copy constructor transfers all data from the other reader,
1.237 - /// therefore the copied reader will not be usable more.
1.238 - LgfContents(LgfContents& other)
1.239 - : _is(other._is), local_is(other.local_is) {
1.240 -
1.241 - other._is = 0;
1.242 - other.local_is = false;
1.243 -
1.244 - _node_sections.swap(other._node_sections);
1.245 - _edge_sections.swap(other._edge_sections);
1.246 - _attribute_sections.swap(other._attribute_sections);
1.247 - _extra_sections.swap(other._extra_sections);
1.248 -
1.249 - _arc_sections.swap(other._arc_sections);
1.250 -
1.251 - _node_maps.swap(other._node_maps);
1.252 - _edge_maps.swap(other._edge_maps);
1.253 - _attributes.swap(other._attributes);
1.254 - }
1.255
1.256 /// \brief Destructor
1.257 ~LgfContents() {
1.258 if (local_is) delete _is;
1.259 }
1.260
1.261 + private:
1.262 +
1.263 + LgfContents(const LgfContents&);
1.264 + LgfContents& operator=(const LgfContents&);
1.265 +
1.266 + public:
1.267 +
1.268
1.269 /// \name Node sections
1.270 /// @{