diff -r b16ca599472f -r 723b2b81d900 lemon/lemon_reader.h --- a/lemon/lemon_reader.h Thu Jan 19 16:56:39 2006 +0000 +++ b/lemon/lemon_reader.h Tue Jan 24 16:07:38 2006 +0000 @@ -47,7 +47,7 @@ template bool operator<(T, T) { - throw DataFormatError("Id is not comparable"); + throw DataFormatError("Label is not comparable"); } template @@ -58,22 +58,22 @@ }; template - class ItemIdReader { + class ItemLabelReader { public: - bool isIdReader() { return true; } + bool isLabelReader() { return true; } - void readId(std::istream&, Item&) {} + void readLabel(std::istream&, Item&) {} - template + template struct Constraints { void constraints() { - bool b = reader.isIdReader(); + bool b = reader.isLabelReader(); ignore_unused_variable_warning(b); Item item; - reader.readId(is, item); + reader.readLabel(is, item); } - _ItemIdReader& reader; + _ItemLabelReader& reader; std::istream& is; }; @@ -241,7 +241,7 @@ if (it == inverse.end()) { inverse.insert(std::make_pair(value, item)); } else { - throw DataFormatError("Multiple ID occurence"); + throw DataFormatError("Multiple label occurence"); } } @@ -252,7 +252,7 @@ if (it != inverse.end()) { return it->second; } else { - throw DataFormatError("Invalid ID error"); + throw DataFormatError("Invalid label error"); } } }; @@ -279,7 +279,7 @@ if (it == inverse.end()) { inverse.insert(std::make_pair(value, item)); } else { - throw DataFormatError("Multiple ID occurence error"); + throw DataFormatError("Multiple label occurence error"); } } @@ -290,7 +290,7 @@ if (it != inverse.end()) { return it->second; } else { - throw DataFormatError("Invalid ID error"); + throw DataFormatError("Invalid label error"); } } @@ -370,33 +370,33 @@ }; template - class IdReaderBase { + class LabelReaderBase { public: typedef _Item Item; - virtual ~IdReaderBase() {} + virtual ~LabelReaderBase() {} virtual Item read(std::istream& is) const = 0; - virtual bool isIdReader() const = 0; + virtual bool isLabelReader() const = 0; }; - template - class IdReader : public IdReaderBase<_Item> { + template + class LabelReader : public LabelReaderBase<_Item> { public: typedef _Item Item; - typedef _BoxedIdReader BoxedIdReader; + typedef _BoxedLabelReader BoxedLabelReader; - const BoxedIdReader& boxedIdReader; + const BoxedLabelReader& boxedLabelReader; - IdReader(const BoxedIdReader& _boxedIdReader) - : boxedIdReader(_boxedIdReader) {} + LabelReader(const BoxedLabelReader& _boxedLabelReader) + : boxedLabelReader(_boxedLabelReader) {} virtual Item read(std::istream& is) const { Item item; - boxedIdReader.readId(is, item); + boxedLabelReader.readLabel(is, item); return item; } - virtual bool isIdReader() const { - return boxedIdReader.isIdReader(); + virtual bool isLabelReader() const { + return boxedLabelReader.isLabelReader(); } }; @@ -727,16 +727,16 @@ /// \brief SectionReader for reading a graph's nodeset. /// /// The lemon format can store multiple graph nodesets with several maps. - /// The nodeset section's header line is \c \@nodeset \c nodeset_id, but the - /// \c nodeset_id may be empty. + /// The nodeset section's header line is \c \@nodeset \c nodeset_name, but the + /// \c nodeset_name may be empty. /// /// The first line of the section contains the names of the maps separated /// with white spaces. Each next lines describes a node in the nodeset, and /// contains the mapped values for each map. /// - /// If the nodeset contains an \c "id" named map then it will be regarded + /// If the nodeset contains an \c "label" named map then it will be regarded /// as id map. This map should contain only unique values and when the - /// \c readId() member will read a value from the given stream it will + /// \c readLabel() member will read a value from the given stream it will /// give back that node which is mapped to this value. /// /// \relates LemonReader @@ -755,12 +755,12 @@ /// Constructor for NodeSetReader. It creates the NodeSetReader and /// attach it into the given LemonReader. The nodeset reader will /// add the readed nodes to the given Graph. The reader will read - /// the section when the \c section_id and the \c _id are the same. + /// the section when the \c section_name and the \c _name are the same. NodeSetReader(LemonReader& _reader, Graph& _graph, - const std::string& _id = std::string(), + const std::string& _name = std::string(), const DefaultSkipper& _skipper = DefaultSkipper()) - : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {} + : Parent(_reader), graph(_graph), name(_name), skipper(_skipper) {} /// \brief Destructor. @@ -855,11 +855,11 @@ /// the section with the given header line. /// /// It gives back true when the header line starts with \c \@nodeset, - /// and the header line's id and the nodeset's id are the same. + /// and the header line's name and the nodeset's name are the same. virtual bool header(const std::string& line) { std::istringstream ls(line); std::string command; - std::string name; + std::string id; ls >> command >> name; return command == "@nodeset" && name == id; } @@ -872,7 +872,8 @@ std::string line; getline(is, line); - std::istringstream ls(line); + std::istringstream ls(line); + std::string id; while (ls >> id) { typename MapReaders::iterator it = readers.find(id); if (it != readers.end()) { @@ -881,7 +882,7 @@ } else { index.push_back(&skipper); } - if (id == "id" && inverter.get() == 0) { + if (id == "label" || (id =="id" && inverter.get() == 0)) { inverter.reset(index.back()->getInverter()); index.back() = inverter.get(); } @@ -905,19 +906,19 @@ public: - /// \brief Returns true if the nodeset can give back the node by its id. + /// \brief Returns true if the nodeset can give back the node by its label. /// - /// Returns true if the nodeset can give back the node by its id. - /// It is possible only if an "id" named map was read. - bool isIdReader() const { + /// Returns true if the nodeset can give back the node by its label. + /// It is possible only if an "label" named map was read. + bool isLabelReader() const { return inverter.get() != 0; } - /// \brief Gives back the node by its id. + /// \brief Gives back the node by its label. /// /// It reads an id from the stream and gives back which node belongs to - /// it. It is possible only if there was read an "id" named map. - void readId(std::istream& is, Node& node) const { + /// it. It is possible only if there was read an "label" named map. + void readLabel(std::istream& is, Node& node) const { node = inverter->read(is); } @@ -927,7 +928,7 @@ MapReaders readers; Graph& graph; - std::string id; + std::string name; _reader_bits::SkipReader skipper; std::auto_ptr<_reader_bits::MapInverterBase > inverter; @@ -937,21 +938,21 @@ /// \brief SectionReader for reading a graph's edgeset. /// /// The lemon format can store multiple graph edgesets with several maps. - /// The edgeset section's header line is \c \@edgeset \c edgeset_id, but the - /// \c edgeset_id may be empty. + /// The edgeset section's header line is \c \@edgeset \c edgeset_name, but the + /// \c edgeset_name may be empty. /// /// The first line of the section contains the names of the maps separated /// with white spaces. Each next lines describes an edge in the edgeset. The /// line contains the source and the target nodes' id and the mapped /// values for each map. /// - /// If the edgeset contains an \c "id" named map then it will be regarded + /// If the edgeset contains an \c "label" named map then it will be regarded /// as id map. This map should contain only unique values and when the - /// \c readId() member will read a value from the given stream it will + /// \c readLabel() member will read a value from the given stream it will /// give back that edge which is mapped to this value. /// /// The edgeset reader needs a node id reader to identify which nodes - /// have to be connected. If a NodeSetReader reads an "id" named map, + /// have to be connected. If a NodeSetReader reads an "label" named map, /// it will be able to resolve the nodes by ids. /// /// \relates LemonReader @@ -972,18 +973,18 @@ /// attach it into the given LemonReader. The edgeset reader will /// add the readed edges to the given Graph. It will use the given /// node id reader to read the source and target nodes of the edges. - /// The reader will read the section only if the \c _id and the - /// \c edgset_id are the same. - template + /// The reader will read the section only if the \c _name and the + /// \c edgset_name are the same. + template EdgeSetReader(LemonReader& _reader, Graph& _graph, - const NodeIdReader& _nodeIdReader, - const std::string& _id = std::string(), + const NodeLabelReader& _nodeLabelReader, + const std::string& _name = std::string(), const DefaultSkipper& _skipper = DefaultSkipper()) - : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) { - checkConcept<_reader_bits::ItemIdReader, NodeIdReader>(); - nodeIdReader.reset(new _reader_bits:: - IdReader(_nodeIdReader)); + : Parent(_reader), graph(_graph), name(_name), skipper(_skipper) { + checkConcept<_reader_bits::ItemLabelReader, NodeLabelReader>(); + nodeLabelReader.reset(new _reader_bits:: + LabelReader(_nodeLabelReader)); } /// \brief Destructor. /// @@ -1077,11 +1078,11 @@ /// the section with the given header line. /// /// It gives back true when the header line starts with \c \@edgeset, - /// and the header line's id and the edgeset's id are the same. + /// and the header line's name and the edgeset's name are the same. virtual bool header(const std::string& line) { std::istringstream ls(line); std::string command; - std::string name; + std::string id; ls >> command >> name; return command == "@edgeset" && name == id; } @@ -1090,14 +1091,15 @@ /// /// It reads the content of the section. virtual void read(std::istream& is) { - if (!nodeIdReader->isIdReader()) { - throw DataFormatError("Cannot find nodeset or ID map"); + if (!nodeLabelReader->isLabelReader()) { + throw DataFormatError("Cannot find nodeset or label map"); } std::vector<_reader_bits::MapReaderBase* > index; std::string line; getline(is, line); std::istringstream ls(line); + std::string id; while (ls >> id) { typename MapReaders::iterator it = readers.find(id); if (it != readers.end()) { @@ -1106,7 +1108,7 @@ } else { index.push_back(&skipper); } - if (id == "id" && inverter.get() == 0) { + if (id == "label" || (id =="id" && inverter.get() == 0)) { inverter.reset(index.back()->getInverter()); index.back() = inverter.get(); } @@ -1121,8 +1123,8 @@ } while (getline(is, line)) { std::istringstream ls(line); - Node from = nodeIdReader->read(ls); - Node to = nodeIdReader->read(ls); + Node from = nodeLabelReader->read(ls); + Node to = nodeLabelReader->read(ls); Edge edge = graph.addEdge(from, to); for (int i = 0; i < (int)index.size(); ++i) { index[i]->read(ls, edge); @@ -1132,19 +1134,19 @@ public: - /// \brief Returns true if the edgeset can give back the edge by its id. + /// \brief Returns true if the edgeset can give back the edge by its label. /// - /// Returns true if the edgeset can give back the edge by its id. - /// It is possible only if an "id" named map was read. - bool isIdReader() const { + /// Returns true if the edgeset can give back the edge by its label. + /// It is possible only if an "label" named map was read. + bool isLabelReader() const { return inverter.get() != 0; } - /// \brief Gives back the edge by its id. + /// \brief Gives back the edge by its label. /// /// It reads an id from the stream and gives back which edge belongs to - /// it. It is possible only if there was read an "id" named map. - void readId(std::istream& is, Edge& edge) const { + /// it. It is possible only if there was read an "label" named map. + void readLabel(std::istream& is, Edge& edge) const { edge = inverter->read(is); } @@ -1154,11 +1156,11 @@ MapReaders readers; Graph& graph; - std::string id; + std::string name; _reader_bits::SkipReader skipper; std::auto_ptr<_reader_bits::MapInverterBase > inverter; - std::auto_ptr<_reader_bits::IdReaderBase > nodeIdReader; + std::auto_ptr<_reader_bits::LabelReaderBase > nodeLabelReader; }; /// \ingroup io_group @@ -1166,7 +1168,7 @@ /// /// The lemon format can store multiple undirected edgesets with several /// maps. The undirected edgeset section's header line is \c \@undiredgeset - /// \c undiredgeset_id, but the \c undiredgeset_id may be empty. + /// \c undiredgeset_name, but the \c undiredgeset_name may be empty. /// /// The first line of the section contains the names of the maps separated /// with white spaces. Each next lines describes an edge in the edgeset. The @@ -1178,13 +1180,13 @@ /// is near the same just with a prefix \c '+' or \c '-' character /// difference. /// - /// If the edgeset contains an \c "id" named map then it will be regarded + /// If the edgeset contains an \c "label" named map then it will be regarded /// as id map. This map should contain only unique values and when the - /// \c readId() member will read a value from the given stream it will + /// \c readLabel() member will read a value from the given stream it will /// give back that undiricted edge which is mapped to this value. /// /// The undirected edgeset reader needs a node id reader to identify which - /// nodes have to be connected. If a NodeSetReader reads an "id" named map, + /// nodes have to be connected. If a NodeSetReader reads an "label" named map, /// it will be able to resolve the nodes by ids. /// /// \relates LemonReader @@ -1207,17 +1209,17 @@ /// reader will add the readed undirected edges to the given Graph. It /// will use the given node id reader to read the source and target /// nodes of the edges. The reader will read the section only if the - /// \c _id and the \c undiredgset_id are the same. - template + /// \c _name and the \c undiredgset_name are the same. + template UndirEdgeSetReader(LemonReader& _reader, Graph& _graph, - const NodeIdReader& _nodeIdReader, - const std::string& _id = std::string(), + const NodeLabelReader& _nodeLabelReader, + const std::string& _name = std::string(), const DefaultSkipper& _skipper = DefaultSkipper()) - : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) { - checkConcept<_reader_bits::ItemIdReader, NodeIdReader>(); - nodeIdReader.reset(new _reader_bits:: - IdReader(_nodeIdReader)); + : Parent(_reader), graph(_graph), name(_name), skipper(_skipper) { + checkConcept<_reader_bits::ItemLabelReader, NodeLabelReader>(); + nodeLabelReader.reset(new _reader_bits:: + LabelReader(_nodeLabelReader)); } /// \brief Destructor. /// @@ -1372,11 +1374,11 @@ /// the section with the given header line. /// /// It gives back true when the header line starts with \c \@undiredgeset, - /// and the header line's id and the edgeset's id are the same. + /// and the header line's name and the edgeset's name are the same. virtual bool header(const std::string& line) { std::istringstream ls(line); std::string command; - std::string name; + std::string id; ls >> command >> name; return command == "@undiredgeset" && name == id; } @@ -1385,14 +1387,15 @@ /// /// It reads the content of the section. virtual void read(std::istream& is) { - if (!nodeIdReader->isIdReader()) { - throw DataFormatError("Cannot find nodeset or ID map"); + if (!nodeLabelReader->isLabelReader()) { + throw DataFormatError("Cannot find nodeset or label map"); } std::vector<_reader_bits::MapReaderBase* > index; std::string line; getline(is, line); std::istringstream ls(line); + std::string id; while (ls >> id) { typename MapReaders::iterator it = readers.find(id); if (it != readers.end()) { @@ -1401,7 +1404,7 @@ } else { index.push_back(&skipper); } - if (id == "id" && inverter.get() == 0) { + if (id == "label" || (id =="id" && inverter.get() == 0)) { inverter.reset(index.back()->getInverter()); index.back() = inverter.get(); } @@ -1416,8 +1419,8 @@ } while (getline(is, line)) { std::istringstream ls(line); - Node from = nodeIdReader->read(ls); - Node to = nodeIdReader->read(ls); + Node from = nodeLabelReader->read(ls); + Node to = nodeLabelReader->read(ls); UndirEdge edge = graph.addEdge(from, to); for (int i = 0; i < (int)index.size(); ++i) { index[i]->read(ls, edge); @@ -1427,29 +1430,29 @@ public: - /// \brief Returns true if the edgeset can give back the edge by its id. + /// \brief Returns true if the edgeset can give back the edge by its label. /// /// Returns true if the edgeset can give back the undirected edge by its - /// id. It is possible only if an "id" named map was read. - bool isIdReader() const { + /// id. It is possible only if an "label" named map was read. + bool isLabelReader() const { return inverter.get() != 0; } - /// \brief Gives back the undirected edge by its id. + /// \brief Gives back the undirected edge by its label. /// /// It reads an id from the stream and gives back which undirected edge - /// belongs to it. It is possible only if there was read an "id" named map. - void readId(std::istream& is, UndirEdge& undirEdge) const { + /// belongs to it. It is possible only if there was read an "label" named map. + void readLabel(std::istream& is, UndirEdge& undirEdge) const { undirEdge = inverter->read(is); } - /// \brief Gives back the directed edge by its id. + /// \brief Gives back the directed edge by its label. /// /// It reads an id from the stream and gives back which directed edge /// belongs to it. The directed edge id is the \c '+' or \c '-' character /// and the undirected edge id. It is possible only if there was read - /// an "id" named map. - void readId(std::istream& is, Edge& edge) const { + /// an "label" named map. + void readLabel(std::istream& is, Edge& edge) const { char c; is >> c; UndirEdge undirEdge = inverter->read(is); @@ -1470,18 +1473,18 @@ MapReaders readers; Graph& graph; - std::string id; + std::string name; _reader_bits::SkipReader skipper; std::auto_ptr<_reader_bits::MapInverterBase > inverter; - std::auto_ptr<_reader_bits::IdReaderBase > nodeIdReader; + std::auto_ptr<_reader_bits::LabelReaderBase > nodeLabelReader; }; /// \ingroup io_group /// \brief SectionReader for reading labeled nodes. /// - /// The nodes section's header line is \c \@nodes \c nodes_id, but the - /// \c nodes_id may be empty. + /// The nodes section's header line is \c \@nodes \c nodes_name, but the + /// \c nodes_name may be empty. /// /// Each line in the section contains the name of the node /// and then the node id. @@ -1499,14 +1502,14 @@ /// Constructor for NodeReader. It creates the NodeReader and /// attach it into the given LemonReader. It will use the given /// node id reader to give back the nodes. The reader will read the - /// section only if the \c _id and the \c nodes_id are the same. - template - NodeReader(LemonReader& _reader, const _IdReader& _idReader, - const std::string& _id = std::string()) - : Parent(_reader), id(_id) { - checkConcept<_reader_bits::ItemIdReader, _IdReader>(); - nodeIdReader.reset(new _reader_bits:: - IdReader(_idReader)); + /// section only if the \c _name and the \c nodes_name are the same. + template + NodeReader(LemonReader& _reader, const _LabelReader& _labelReader, + const std::string& _name = std::string()) + : Parent(_reader), name(_name) { + checkConcept<_reader_bits::ItemLabelReader, _LabelReader>(); + nodeLabelReader.reset(new _reader_bits:: + LabelReader(_labelReader)); } /// \brief Destructor. @@ -1538,11 +1541,11 @@ /// the section with the given header line. /// /// It gives back true when the header line start with \c \@nodes, - /// and the header line's id and the reader's id are the same. + /// and the header line's name and the reader's name are the same. virtual bool header(const std::string& line) { std::istringstream ls(line); std::string command; - std::string name; + std::string id; ls >> command >> name; return command == "@nodes" && name == id; } @@ -1551,8 +1554,8 @@ /// /// It reads the content of the section. virtual void read(std::istream& is) { - if (!nodeIdReader->isIdReader()) { - throw DataFormatError("Cannot find nodeset or ID map"); + if (!nodeLabelReader->isLabelReader()) { + throw DataFormatError("Cannot find nodeset or label map"); } std::string line; while (getline(is, line)) { @@ -1561,7 +1564,7 @@ ls >> id; typename NodeReaders::iterator it = readers.find(id); if (it != readers.end()) { - it->second.read(nodeIdReader->read(ls)); + it->second.read(nodeLabelReader->read(ls)); it->second.touch(); } } @@ -1577,18 +1580,18 @@ private: - std::string id; + std::string name; typedef std::map > NodeReaders; NodeReaders readers; - std::auto_ptr<_reader_bits::IdReaderBase > nodeIdReader; + std::auto_ptr<_reader_bits::LabelReaderBase > nodeLabelReader; }; /// \ingroup io_group /// \brief SectionReader for reading labeled edges. /// - /// The edges section's header line is \c \@edges \c edges_id, but the - /// \c edges_id may be empty. + /// The edges section's header line is \c \@edges \c edges_name, but the + /// \c edges_name may be empty. /// /// Each line in the section contains the name of the edge /// and then the edge id. @@ -1606,14 +1609,14 @@ /// Constructor for EdgeReader. It creates the EdgeReader and /// attach it into the given LemonReader. It will use the given /// edge id reader to give back the edges. The reader will read the - /// section only if the \c _id and the \c edges_id are the same. - template - EdgeReader(LemonReader& _reader, const _IdReader& _idReader, - const std::string& _id = std::string()) - : Parent(_reader), id(_id) { - checkConcept<_reader_bits::ItemIdReader, _IdReader>(); - edgeIdReader.reset(new _reader_bits:: - IdReader(_idReader)); + /// section only if the \c _name and the \c edges_name are the same. + template + EdgeReader(LemonReader& _reader, const _LabelReader& _labelReader, + const std::string& _name = std::string()) + : Parent(_reader), name(_name) { + checkConcept<_reader_bits::ItemLabelReader, _LabelReader>(); + edgeLabelReader.reset(new _reader_bits:: + LabelReader(_labelReader)); } /// \brief Destructor. @@ -1644,11 +1647,11 @@ /// the section with the given header line. /// /// It gives back true when the header line start with \c \@edges, - /// and the header line's id and the reader's id are the same. + /// and the header line's name and the reader's name are the same. virtual bool header(const std::string& line) { std::istringstream ls(line); std::string command; - std::string name; + std::string id; ls >> command >> name; return command == "@edges" && name == id; } @@ -1657,8 +1660,8 @@ /// /// It reads the content of the section. virtual void read(std::istream& is) { - if (!edgeIdReader->isIdReader()) { - throw DataFormatError("Cannot find edgeset or ID map"); + if (!edgeLabelReader->isLabelReader()) { + throw DataFormatError("Cannot find edgeset or label map"); } std::string line; while (getline(is, line)) { @@ -1667,7 +1670,7 @@ ls >> id; typename EdgeReaders::iterator it = readers.find(id); if (it != readers.end()) { - it->second.read(edgeIdReader->read(ls)); + it->second.read(edgeLabelReader->read(ls)); it->second.touch(); } } @@ -1683,18 +1686,18 @@ private: - std::string id; + std::string name; typedef std::map > EdgeReaders; EdgeReaders readers; - std::auto_ptr<_reader_bits::IdReaderBase > edgeIdReader; + std::auto_ptr<_reader_bits::LabelReaderBase > edgeLabelReader; }; /// \ingroup io_group /// \brief SectionReader for reading labeled undirected edges. /// /// The undirected edges section's header line is \c \@undiredges - /// \c undiredges_id, but the \c undiredges_id may be empty. + /// \c undiredges_name, but the \c undiredges_name may be empty. /// /// Each line in the section contains the name of the undirected edge /// and then the undirected edge id. @@ -1713,18 +1716,18 @@ /// Constructor for UndirEdgeReader. It creates the UndirEdgeReader and /// attach it into the given LemonReader. It will use the given /// undirected edge id reader to give back the edges. The reader will - /// read the section only if the \c _id and the \c undiredges_id are + /// read the section only if the \c _name and the \c undiredges_name are /// the same. - template - UndirEdgeReader(LemonReader& _reader, const _IdReader& _idReader, - const std::string& _id = std::string()) - : Parent(_reader), id(_id) { - checkConcept<_reader_bits::ItemIdReader, _IdReader>(); - checkConcept<_reader_bits::ItemIdReader, _IdReader>(); - undirEdgeIdReader.reset(new _reader_bits:: - IdReader(_idReader)); - edgeIdReader.reset(new _reader_bits:: - IdReader(_idReader)); + template + UndirEdgeReader(LemonReader& _reader, const _LabelReader& _labelReader, + const std::string& _name = std::string()) + : Parent(_reader), name(_name) { + checkConcept<_reader_bits::ItemLabelReader, _LabelReader>(); + checkConcept<_reader_bits::ItemLabelReader, _LabelReader>(); + undirEdgeLabelReader.reset(new _reader_bits:: + LabelReader(_labelReader)); + edgeLabelReader.reset(new _reader_bits:: + LabelReader(_labelReader)); } /// \brief Destructor. @@ -1768,11 +1771,11 @@ /// the section with the given header line. /// /// It gives back true when the header line start with \c \@edges, - /// and the header line's id and the reader's id are the same. + /// and the header line's name and the reader's name are the same. virtual bool header(const std::string& line) { std::istringstream ls(line); std::string command; - std::string name; + std::string id; ls >> command >> name; return command == "@undiredges" && name == id; } @@ -1781,11 +1784,11 @@ /// /// It reads the content of the section. virtual void read(std::istream& is) { - if (!edgeIdReader->isIdReader()) { - throw DataFormatError("Cannot find undirected edgeset or ID map"); + if (!edgeLabelReader->isLabelReader()) { + throw DataFormatError("Cannot find undirected edgeset or label map"); } - if (!undirEdgeIdReader->isIdReader()) { - throw DataFormatError("Cannot find undirected edgeset or ID map"); + if (!undirEdgeLabelReader->isLabelReader()) { + throw DataFormatError("Cannot find undirected edgeset or label map"); } std::string line; while (getline(is, line)) { @@ -1795,14 +1798,14 @@ { typename UndirEdgeReaders::iterator it = undirEdgeReaders.find(id); if (it != undirEdgeReaders.end()) { - it->second.read(undirEdgeIdReader->read(ls)); + it->second.read(undirEdgeLabelReader->read(ls)); it->second.touch(); continue; } } { typename EdgeReaders::iterator it = edgeReaders.find(id); if (it != edgeReaders.end()) { - it->second.read(edgeIdReader->read(ls)); + it->second.read(edgeLabelReader->read(ls)); it->second.touch(); continue; } @@ -1828,24 +1831,24 @@ private: - std::string id; + std::string name; typedef std::map > UndirEdgeReaders; UndirEdgeReaders undirEdgeReaders; - std::auto_ptr<_reader_bits::IdReaderBase > undirEdgeIdReader; + std::auto_ptr<_reader_bits::LabelReaderBase > undirEdgeLabelReader; typedef std::map > EdgeReaders; EdgeReaders edgeReaders; - std::auto_ptr<_reader_bits::IdReaderBase > edgeIdReader; + std::auto_ptr<_reader_bits::LabelReaderBase > edgeLabelReader; }; /// \ingroup io_group /// \brief SectionReader for attributes. /// /// The lemon format can store multiple attribute set. Each set has - /// the header line \c \@attributes \c attributeset_id, but the - /// attributeset_id may be empty. + /// the header line \c \@attributes \c attributeset_name, but the + /// attributeset_name may be empty. /// /// The attributeset section contains several lines. Each of them starts /// with an attribute and then a the value for the id. @@ -1860,10 +1863,10 @@ /// /// Constructor for AttributeReader. It creates the AttributeReader and /// attach it into the given LemonReader. The reader process a section - /// only if the \c section_id and the \c _id are the same. + /// only if the \c section_name and the \c _name are the same. AttributeReader(LemonReader& _reader, - const std::string& _id = std::string()) - : Parent(_reader), id(_id) {} + const std::string& _name = std::string()) + : Parent(_reader), name(_name) {} /// \brief Destructor. /// @@ -1916,7 +1919,7 @@ bool header(const std::string& line) { std::istringstream ls(line); std::string command; - std::string name; + std::string id; ls >> command >> name; return command == "@attributes" && name == id; } @@ -1933,7 +1936,7 @@ typename Readers::iterator it = readers.find(id); if (it != readers.end()) { it->second->read(ls); - it->second->touch(); + it->second->touch(); } } for (typename Readers::iterator it = readers.begin(); @@ -1947,7 +1950,7 @@ } private: - std::string id; + std::string name; typedef std::map Readers; Readers readers; @@ -2203,21 +2206,21 @@ private: void readMapNames(std::istream& is, std::vector& maps) { - std::string line, id; + std::string line, name; std::getline(is, line); std::istringstream ls(line); - while (ls >> id) { - maps.push_back(id); + while (ls >> name) { + maps.push_back(name); } while (getline(is, line)); } void readItemNames(std::istream& is, std::vector& maps) { - std::string line, id; + std::string line, name; while (std::getline(is, line)) { std::istringstream ls(line); - ls >> id; - maps.push_back(id); + ls >> name; + maps.push_back(name); } }