Changeset 536 for trunk/lib/Parser.h


Ignore:
Timestamp:
Dec 27, 2007, 4:32:43 AM (14 years ago)
Author:
Peter Johansson
Message:

refs #289 - Parser now is fed with lines and does not read file during construction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Parser.h

    r528 r536  
    3333namespace svndigest{
    3434
    35   ///
    36   /// Class parsing files
    37   ///
     35  /**
     36     \brief Class parsing files
     37     
     38     Class gets parsing rules from Configuration. Which rules depends
     39     on the filename. Typical use is then to add lines using the add
     40     function, and the class builds an internal vector<line_type>,
     41     which can be accessed through function type(void).
     42  */
    3843  class Parser
    3944  {
    4045  public:
    4146    ///
    42     /// A line is considered empty if it only contains spaces and tabs.
    43     ///
    44     /// A line is considered a comment if first and second non-white
    45     /// space characters are '/'.
    46     ///
    47     /// All other lines are considered code.
     47    /// see 'doc/readmea.txt' for info on what is code, comment, and other.
    4848    ///
    4949    enum line_type {
     
    5555    ///
    5656    /// @brief Constructor
     57    /// \param filename is used to decide which parsing rules to use
    5758    ///
    58     explicit Parser(std::string);
     59    explicit Parser(std::string filename);
     60
     61    /**
     62       \brief add a line to parser
     63
     64       \return line_type of parsed line
     65
     66       The line is parsed and added to internal vector. 
     67     */
     68    line_type parse(const std::string& line);
    5969
    6070    ///
     
    6474
    6575  private:
    66     ///
    67     /// Copy constructor (not implemented)
    68     ///
     76    // no copy allowed
    6977    Parser(const Parser& other);
     78    Parser& operator=(const Parser&);
    7079
    71     void parse(std::istream& is,
    72                const std::vector<std::pair<std::string, std::string> >& codon);
     80    line_type code_mode(const std::string& line);
     81    line_type text_mode(const std::string& line);
    7382
    74     void text_mode(std::istream&);
    75 
     83    size_t mode_;
     84   
    7685    std::vector<line_type> type_;
    77 
     86    const std::vector<std::pair<std::string, std::string> >* codon_;
    7887  };
    7988
Note: See TracChangeset for help on using the changeset viewer.