1 | #ifndef _theplu_svndigest_file_ |
---|
2 | #define _theplu_svndigest_file_ |
---|
3 | |
---|
4 | // $Id: File.h 426 2007-06-29 23:48:04Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson |
---|
8 | |
---|
9 | This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest |
---|
10 | |
---|
11 | svndigest is free software; you can redistribute it and/or modify it |
---|
12 | under the terms of the GNU General Public License as published by |
---|
13 | the Free Software Foundation; either version 2 of the License, or |
---|
14 | (at your option) any later version. |
---|
15 | |
---|
16 | svndigest is distributed in the hope that it will be useful, but |
---|
17 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | General Public License for more details. |
---|
20 | |
---|
21 | You should have received a copy of the GNU General Public License |
---|
22 | along with this program; if not, write to the Free Software |
---|
23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
24 | 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | #include "Node.h" |
---|
28 | |
---|
29 | #include <map> |
---|
30 | #include <string> |
---|
31 | |
---|
32 | namespace theplu{ |
---|
33 | namespace svndigest{ |
---|
34 | |
---|
35 | class File : public Node |
---|
36 | { |
---|
37 | public: |
---|
38 | /// |
---|
39 | /// @brief Default Constructor |
---|
40 | /// |
---|
41 | File(const u_int level, const std::string& path, |
---|
42 | const std::string& output=""); |
---|
43 | |
---|
44 | /** |
---|
45 | For example 'File.h.html' |
---|
46 | |
---|
47 | @return href to this file |
---|
48 | */ |
---|
49 | std::string href(void) const; |
---|
50 | |
---|
51 | /** |
---|
52 | @return The explicit string "file", nothing else. |
---|
53 | */ |
---|
54 | std::string node_type(void) const; |
---|
55 | |
---|
56 | /** |
---|
57 | @return output path for example 'lib/File.h.html' for this file |
---|
58 | */ |
---|
59 | std::string output_path(void) const; |
---|
60 | |
---|
61 | /// |
---|
62 | /// @brief Parsing out information from svn repository |
---|
63 | /// |
---|
64 | /// @return Stats object of the file |
---|
65 | /// |
---|
66 | const Stats& parse(const bool verbose=false); |
---|
67 | |
---|
68 | void print_copyright(std::map<std::string, Alias>&, bool verbose) const; |
---|
69 | |
---|
70 | private: |
---|
71 | /// |
---|
72 | /// @brief Copy Constructor, not implemented |
---|
73 | /// |
---|
74 | File(const File&); |
---|
75 | |
---|
76 | /// |
---|
77 | /// @brief Parsing svn blame output |
---|
78 | /// |
---|
79 | /// @return true if parsing is succesful |
---|
80 | /// |
---|
81 | bool blame(void) const; |
---|
82 | |
---|
83 | /** |
---|
84 | \return copyright block |
---|
85 | */ |
---|
86 | std::string copyright_block(const std::map<int, std::set<Alias> >& map, |
---|
87 | const std::string& prefix) const; |
---|
88 | |
---|
89 | /** |
---|
90 | Create a map from year to set of authors. |
---|
91 | */ |
---|
92 | std::map<int, std::set<Alias> > |
---|
93 | copyright_map(std::map<std::string, Alias>& alias) const; |
---|
94 | |
---|
95 | /** |
---|
96 | Create a map from year to set of authors. |
---|
97 | |
---|
98 | \return true if Copyright block is found |
---|
99 | */ |
---|
100 | bool detect_copyright(std::string& block, size_t& start_at_line, |
---|
101 | size_t& end_at_line, std::string& prefix) const; |
---|
102 | |
---|
103 | /** |
---|
104 | @brief Print blame output |
---|
105 | */ |
---|
106 | void print_blame(std::ofstream& os) const; |
---|
107 | |
---|
108 | void print_core(bool verbose=false) const; |
---|
109 | |
---|
110 | /// |
---|
111 | /// print page for specific user (or all) and specific line_style |
---|
112 | /// (or total). |
---|
113 | /// |
---|
114 | void print_core(const std::string& user, const std::string& line_type, |
---|
115 | const SVNlog&) const; |
---|
116 | |
---|
117 | /** |
---|
118 | Doing the actual print of copyright statement |
---|
119 | |
---|
120 | \param block new copyright block |
---|
121 | \param start_at_line line number of first line in old block |
---|
122 | \param end_at_line line number of first line after old block |
---|
123 | */ |
---|
124 | void update_copyright(const std::string& block, |
---|
125 | size_t start_at_line, size_t end_at_line) const; |
---|
126 | }; |
---|
127 | |
---|
128 | }} // end of namespace svndigest and namespace theplu |
---|
129 | |
---|
130 | #endif |
---|
131 | |
---|
132 | |
---|