source: trunk/lib/Parser.cc @ 118

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

fixes #46 #45 #26 #40

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: Parser.cc 118 2006-07-03 07:44:49Z 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#include "utility.h"
26
27#include <algorithm>
28#include <functional>
29#include <fstream>
30#include <iostream>
31#include <string>
32
33namespace theplu{
34namespace svnstat{
35
36
37  Parser::Parser(const std::string& path)
38  {
39    std::ifstream is(path.c_str());
40    cc_mode(is);
41    is.close();
42  }
43
44
45  void Parser::cc_mode(std::istream& is)
46  {
47    std::string str;
48    while(getline(is,str)) {
49      std::string::iterator where;
50      where = std::find_if(str.begin(), str.end(), std::not1(WhiteSpace()));
51      if (where==str.end())
52        type_.push_back(empty);
53      else if (match_begin(where, str.end(), "//")) {
54        where = std::find_if(where, str.end(), AlphaNum());
55        if (where==str.end())
56          type_.push_back(empty);
57        else
58          type_.push_back(comment);
59      }
60      else {
61        type_.push_back(code);
62      }
63    }
64  }
65
66
67}} // end of namespace svnstat and namespace theplu
Note: See TracBrowser for help on using the repository browser.