source: trunk/lib/SVNblame.h @ 205

Last change on this file since 205 was 205, checked in by Jari Häkkinen, 15 years ago

Fixed typo.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1#ifndef _theplu_svndigest_svnblame_
2#define _theplu_svndigest_svnblame_
3
4// $Id: SVNblame.h 205 2006-09-10 14:00:55Z jari $
5
6/*
7  Copyright (C) 2006 Jari Häkkinen
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 <string>
28#include <vector>
29
30#include <subversion-1/svn_client.h>
31
32namespace theplu {
33namespace svndigest {
34
35  class SVN;
36
37  ///
38  /// The SVNblame class is a utility class for taking care of 'svn
39  /// blame' information. An 'svn blame' is performed on an item, the
40  /// blame information for each line is traversed with
41  /// SVNblame.next() calls giving access to the blame information in
42  /// a blame_information struct.
43  ///
44  class SVNblame {
45  public:
46
47    ///
48    /// @brief Information return by subversion (blame) API
49    ///
50    /// @see Subversion API for blame usage.
51    ///
52    struct blame_information {
53      apr_int64_t line_no;
54      svn_revnum_t revision;
55      std::string author;
56      std::string date;
57      std::string line;
58    };
59
60    ///
61    /// @brief The contructor.
62    ///
63    /// The constructor performs an 'svn blame' on \a path and
64    /// initializes the SVNblame object for statistics traversal using
65    /// SVNblame::next().
66    ///
67    explicit SVNblame(const std::string& path);
68
69    ///
70    /// @brief The destructor.
71    ///
72    ~SVNblame(void);
73
74    ///
75    /// @brief Returns true if item is binary false otherwise
76    ///
77    /// Binary files are invalid for 'svn blame'.
78    ///
79    inline bool binary(void) { return binary_; }
80
81    /**
82       Traverse all lines in the item for statistics analysis. There
83       is currently no way to reset the pointer to the beginning of
84       item. The pointer is only valid while the SVNblame object is in
85       scope.
86   
87       @see struct blame_information.
88    */
89    const blame_information* next(void);
90
91  private:
92
93    ///
94    /// @brief Copy Constructor, not implemented.
95    ///
96    SVNblame(const SVNblame&);
97
98    // binary_ is true if item in any revision has been binary.
99    bool binary_;
100    // blame_info_iterator_ is used in statistics analysis to traverse
101    // blame_receiver_baton.blame_info vector through calls to next().
102    std::vector<blame_information*>::iterator blame_info_iterator_;
103    SVN* instance_;
104
105    struct blame_receiver_baton_ {
106      std::vector<blame_information*> blame_info;
107    } blame_receiver_baton_ ;
108
109    static svn_error_t *
110    blame_receiver(void *baton, apr_int64_t line_no, svn_revnum_t revision,
111                   const char *author, const char *date, const char *line,
112                   apr_pool_t *pool);
113  };
114
115}} // end of namespace svndigest and namespace theplu
116
117#endif
Note: See TracBrowser for help on using the repository browser.