source: trunk/lib/File.h @ 745

Last change on this file since 745 was 693, checked in by Jari Häkkinen, 13 years ago

Fixes #339. Change to GPLv3.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1#ifndef _theplu_svndigest_file_
2#define _theplu_svndigest_file_
3
4// $Id: File.h 693 2008-09-11 20:42:56Z jari $
5
6/*
7  Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
8
9  This file is part of svndigest, http://dev.thep.lu.se/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 3 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 svndigest. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "Node.h"
26
27#include <map>
28#include <string>
29
30namespace theplu{
31namespace svndigest{
32
33  class File : public Node
34  {
35  public:
36    ///
37    /// @brief Default Constructor
38    ///
39    File(const unsigned int level, const std::string& path, 
40         const std::string& output=""); 
41
42    /**
43       For example 'File.h.html'
44
45       @return href to this file
46    */
47    std::string href(void) const;
48
49    /**
50       @return The explicit string "file", nothing else.
51    */
52    std::string node_type(void) const;
53
54    /**
55       @return output path for example 'lib/File.h.html' for this file
56     */
57    std::string output_path(void) const;
58
59    ///
60    /// @brief Parsing out information from svn repository
61    ///
62    /// @return Stats object of the file
63    ///
64    const StatsCollection& parse(bool verbose, bool ignore);
65
66    using Node::print_copyright;
67    /**
68       @throw std::runtime_error when a file error is encountered
69       updating the copyrights.
70    */
71    void print_copyright(std::map<std::string, Alias>&, bool verbose,
72                         const std::map<int, svn_revnum_t>&) const;
73
74  private:
75    /**
76       @return log of this File.
77    */
78    SVNlog log_core(void) const;
79
80    ///
81    /// @brief Copy Constructor, not implemented
82    ///
83    File(const File&);
84
85    ///
86    /// @brief Parsing svn blame output
87    ///
88    /// @return true if parsing is succesful
89    ///
90    bool blame(void) const;
91
92    /**
93       \return copyright block
94     */
95    std::string copyright_block(const std::map<int, std::set<Alias> >& map,
96                                const std::string& prefix) const;
97
98    /**
99       Create a map from year to set of authors.
100     */
101    std::map<int, std::set<Alias> > 
102    copyright_map(std::map<std::string, Alias>& alias,
103                  const std::map<int, svn_revnum_t>&) const;
104
105    /**
106       Create a map from year to set of authors.
107
108       \return true if Copyright block is found
109     */
110    bool detect_copyright(std::string& block, size_t& start_at_line,
111                          size_t& end_at_line, std::string& prefix) const;
112
113    /**
114       @brief Print blame output
115    */
116    void print_blame(std::ofstream& os) const;
117
118    void print_core(bool verbose=false) const;
119
120    ///
121    /// print page for specific user (or all) and specific line_style
122    /// (or total).
123    ///
124    void print_core(const std::string& stats_type, const std::string& user, 
125                    const std::string& line_type, const SVNlog&) const; 
126
127    /**
128       Doing the actual print of copyright statement
129
130       \param block new copyright block
131       \param start_at_line line number of first line in old block
132       \param end_at_line line number of first line after old block
133     */
134    void update_copyright(const std::string& block,
135                          size_t start_at_line, size_t end_at_line) const;
136  };
137
138}} // end of namespace svndigest and namespace theplu
139
140#endif
141
142
Note: See TracBrowser for help on using the repository browser.