source: trunk/lib/File.h @ 834

Last change on this file since 834 was 834, checked in by Peter Johansson, 12 years ago

fixes #397. get latest rev from SVNinfo instead of SVNlog

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