COIN-OR::LEMON - Graph Library

Changeset 1396:56f9a4ba9149 in lemon-0.x for src/lemon/graph_reader.h


Ignore:
Timestamp:
04/28/05 11:54:38 (16 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1856
Message:

GUI section handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/graph_reader.h

    r1394 r1396  
    182182  };
    183183
     184  class GUIReader {
     185  public:
     186    virtual void read(std::istream& is) = 0;
     187  };
     188
    184189  /// \brief The graph reader class.
    185190  ///
     
    264269    GraphReader(std::istream& _is, Graph& _graph,
    265270                const DefaultReader& _reader = DefaultReader())
    266       : is(_is), graph(_graph), nodeSkipper(_reader), edgeSkipper(_reader) {}
     271      : gui_reader(0), is(_is), graph(_graph),
     272        nodeSkipper(_reader), edgeSkipper(_reader) {}
    267273
    268274    /// \brief Destruct the graph reader.
     
    412418          line = readEdges(line_num, edgeInverter);
    413419        }
     420        if (line.find("@gui") == 0) {
     421          line = readGUI(line_num);
     422        }
    414423        if (line.find("@end") != 0) {
    415424          throw DataFormatError("Invalid control sequence error");
     
    419428        throw e;
    420429      }
     430    }
     431
     432    GraphReader& readGUI(GUIReader& reader) {
     433      gui_reader = &reader;
     434      return *this;
    421435    }
    422436
     
    545559    }
    546560
     561    std::string readGUI(int& line_num) {
     562      std::stringstream section;
     563      std::string line;
     564      while (line = readNotEmptyLine(is, line_num), line[0] != '@') {
     565        section << line << std::endl;
     566      }
     567      if (gui_reader != 0) {
     568        gui_reader->read(section);
     569      }
     570      return line;
     571    }
     572
    547573    std::string readNotEmptyLine(std::istream& is, int& line_num) {
    548574      std::string line;
     
    732758    typedef std::map<std::string, Edge*> EdgeReaders;
    733759    EdgeReaders edge_readers;
     760
     761    GUIReader* gui_reader;
    734762
    735763    std::istream& is;
Note: See TracChangeset for help on using the changeset viewer.