source: trunk/lib/Parser.cc @ 103

Last change on this file since 103 was 103, checked in by Peter Johansson, 15 years ago

added class for parsing files for empty lines, comment lines, and code lines

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1// $Id: Parser.cc 103 2006-06-27 09:46:00Z peter $
2
3/*
4  Copyright (C) 2006 Peter Johansson
5
6  This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat
7
8  svnstat is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  svnstat is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "Parser.h"
25
26#include <algorithm>
27#include <functional>
28#include <fstream>
29#include <iostream>
30
31namespace theplu{
32namespace svnstat{
33
34
35  Parser::Parser(std::istream& is)
36  {
37    std::string str;
38    while(getline(is,str)) {
39      std::string::const_iterator where;
40      where = std::find_if(str.begin(), str.end(), std::not1(WhiteSpace()));
41      if (where==str.end())
42        type_.push_back(empty);
43      else if (*where=='/' && *(where+1)=='/')
44        type_.push_back(comment);
45      else
46        type_.push_back(code);
47    }
48  }
49
50
51}} // end of namespace svnstat and namespace theplu
Note: See TracBrowser for help on using the repository browser.