1 | // $Id: File.cc 84 2006-03-13 22:04:34Z jari $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2005, 2006 Jari Häkkinen, 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 "File.h" |
---|
25 | #include "Node.h" |
---|
26 | #include "Stats.h" |
---|
27 | #include "utility.h" |
---|
28 | |
---|
29 | #include <fstream> |
---|
30 | #include <iostream> |
---|
31 | #include <map> |
---|
32 | #include <sstream> |
---|
33 | #include <string> |
---|
34 | |
---|
35 | namespace theplu{ |
---|
36 | namespace svnstat{ |
---|
37 | |
---|
38 | const Stats& File::parse(const bool verbose) |
---|
39 | { |
---|
40 | if (verbose) |
---|
41 | std::cout << "Parsing " << path_ << std::endl; |
---|
42 | stats_.reset(); |
---|
43 | |
---|
44 | std::map<std::string,std::string> svn_info = info(path_); |
---|
45 | author_ = svn_info["Last Changed Author"]; |
---|
46 | std::stringstream ss(svn_info["Last Changed Rev"]); |
---|
47 | ss >> revision_; |
---|
48 | |
---|
49 | binary_ = stats_.parse(path_); |
---|
50 | return stats_; |
---|
51 | } |
---|
52 | |
---|
53 | void File::print(const bool verbose) const |
---|
54 | { |
---|
55 | std::string output(output_name() + ".html"); |
---|
56 | if (verbose) |
---|
57 | std::cout << "Printing output for " << path_ << std::endl; |
---|
58 | std::ofstream os(output.c_str()); |
---|
59 | print_header(os); |
---|
60 | os << "<p align=center>\n<img src='" << stats_.plot(output_name()+".png") |
---|
61 | << "' alt='[plot]' border=0>\n</p>"; |
---|
62 | print_footer(os); |
---|
63 | os.close(); |
---|
64 | |
---|
65 | } |
---|
66 | |
---|
67 | }} // end of namespace svnstat and namespace theplu |
---|