lemon/graph_reader.h
changeset 1903 f3d24016dad5
parent 1875 98698b69a902
child 1909 2d806130e700
equal deleted inserted replaced
6:f2084a873db2 7:c2dc12d5f62b
    65   /// parameters.
    65   /// parameters.
    66   ///
    66   ///
    67   /// \code
    67   /// \code
    68   /// reader.readNodeMap("coords", coords);
    68   /// reader.readNodeMap("coords", coords);
    69   ///
    69   ///
    70   /// reader.readNodeMap<QuotedStringReader>("label", labelMap);
    70   /// reader.skipNodeMap("description", desc);
    71   /// reader.skipNodeMap<QuotedStringReader>("description");
       
    72   ///
    71   ///
    73   /// reader.readNodeMap("color", colorMap);
    72   /// reader.readNodeMap("color", colorMap);
    74   /// \endcode
    73   /// \endcode
    75   ///
    74   ///
    76   /// With the \c readEdgeMap() member function you can give an edge map
    75   /// With the \c readEdgeMap() member function you can give an edge map
   304     /// Executes the reading commands.
   303     /// Executes the reading commands.
   305     void run() {
   304     void run() {
   306       reader->run();
   305       reader->run();
   307     }
   306     }
   308 
   307 
   309     /// \brief Gives back the node by its id.
   308 
   310     ///
   309     /// \brief Returns true if the reader can give back the items by its label.
   311     /// It reads an id from the stream and gives back which node belongs to
   310     ///
   312     /// it. It is possible only if there was read an "id" named node map.
   311     /// \brief Returns true if the reader can give back the items by its label.
   313     Node readId(std::istream& is, Node) const {
   312     bool isLabelReader() const {
   314       return nodeset_reader.readId(is, Node());
   313       return nodeset_reader.isLabelReader() && edgeset_reader.isLabelReader();
       
   314     }
       
   315 
       
   316     /// \brief Gives back the node by its label.
       
   317     ///
       
   318     /// It reads an label from the stream and gives back which node belongs to
       
   319     /// it. It is possible only if there was read an "label" named node map.
       
   320     void readLabel(std::istream& is, Node& node) const {
       
   321       nodeset_reader.readLabel(is, node);
   315     } 
   322     } 
   316 
   323 
   317     /// \brief Gives back the edge by its id.
   324     /// \brief Gives back the edge by its label.
   318     ///
   325     ///
   319     /// It reads an id from the stream and gives back which edge belongs to
   326     /// It reads an label from the stream and gives back which edge belongs to
   320     /// it. It is possible only if there was read an "id" named edge map.
   327     /// it. It is possible only if there was read an "label" named edge map.
   321     Edge readId(std::istream& is, Edge) const {
   328     void readLabel(std::istream& is, Edge& edge) const {
   322       return edgeset_reader.readId(is, Edge());
   329       return edgeset_reader.readLabel(is, edge);
   323     } 
   330     } 
   324 
   331 
   325   private:
   332   private:
   326 
   333 
   327     LemonReader* reader;
   334     LemonReader* reader;
   402   /// parameters.
   409   /// parameters.
   403   ///
   410   ///
   404   /// \code
   411   /// \code
   405   /// reader.readNodeMap("coords", coords);
   412   /// reader.readNodeMap("coords", coords);
   406   ///
   413   ///
   407   /// reader.readNodeMap<QuotedStringReader>("label", labelMap);
   414   /// reader.skipNodeMap("description", desc);
   408   /// reader.skipNodeMap<QuotedStringReader>("description");
       
   409   ///
   415   ///
   410   /// reader.readNodeMap("color", colorMap);
   416   /// reader.readNodeMap("color", colorMap);
   411   /// \endcode
   417   /// \endcode
   412   ///
   418   ///
   413   /// With the \c readUndirEdgeMap() member function you can give an 
   419   /// With the \c readUndirEdgeMap() member function you can give an 
   702     /// Executes the reading commands.
   708     /// Executes the reading commands.
   703     void run() {
   709     void run() {
   704       reader->run();
   710       reader->run();
   705     }
   711     }
   706 
   712 
   707     /// \brief Gives back the node by its id.
   713 
   708     ///
   714     /// \brief Returns true if the reader can give back the items by its label.
   709     /// It reads an id from the stream and gives back which node belongs to
   715     ///
   710     /// it. It is possible only if there was read an "id" named node map.
   716     /// \brief Returns true if the reader can give back the items by its label.
   711     Node readId(std::istream& is, Node) const {
   717     bool isLabelReader() const {
   712       return nodeset_reader.readId(is, Node());
   718       return nodeset_reader.isLabelReader() && 
       
   719         undir_edgeset_reader.isLabelReader();
       
   720     }
       
   721 
       
   722     /// \brief Gives back the node by its label.
       
   723     ///
       
   724     /// It reads an label from the stream and gives back which node belongs to
       
   725     /// it. It is possible only if there was read an "label" named node map.
       
   726     void readLabel(std::istream& is, Node& node) const {
       
   727       return nodeset_reader.readLabel(is, node);
   713     } 
   728     } 
   714 
   729 
   715     /// \brief Gives back the edge by its id.
   730     /// \brief Gives back the edge by its label.
   716     ///
   731     ///
   717     /// It reads an id from the stream and gives back which edge belongs to
   732     /// It reads an label from the stream and gives back which edge belongs to
   718     /// it. It is possible only if there was read an "id" named edge map.
   733     /// it. It is possible only if there was read an "label" named edge map.
   719     Edge readId(std::istream& is, Edge) const {
   734     void readLabel(std::istream& is, Edge& edge) const {
   720       return undir_edgeset_reader.readId(is, Edge());
   735       return undir_edgeset_reader.readLabel(is, edge);
   721     } 
   736     } 
   722 
   737 
   723     /// \brief Gives back the undirected edge by its id.
   738     /// \brief Gives back the undirected edge by its label.
   724     ///
   739     ///
   725     /// It reads an id from the stream and gives back which undirected edge 
   740     /// It reads an label from the stream and gives back which undirected edge 
   726     /// belongs to it. It is possible only if there was read an "id" named 
   741     /// belongs to it. It is possible only if there was read an "label" named 
   727     /// edge map.
   742     /// edge map.
   728     UndirEdge readId(std::istream& is, UndirEdge) const {
   743     void readLabel(std::istream& is, UndirEdge& uedge) const {
   729       return undir_edgeset_reader.readId(is, UndirEdge());
   744       return undir_edgeset_reader.readLabel(is, uedge);
   730     } 
   745     } 
   731     
   746     
   732 
   747 
   733   private:
   748   private:
   734 
   749