source: tags/0.6.8/lib/SVNlog.h @ 848

Last change on this file since 848 was 731, checked in by Peter Johansson, 13 years ago

update copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1#ifndef _theplu_svndigest_svnlog_
2#define _theplu_svndigest_svnlog_
3
4// $Id: SVNlog.h 731 2008-12-15 19:03:04Z peter $
5
6/*
7  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2008 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 2 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 this program; if not, write to the Free Software
24  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25  02111-1307, USA.
26*/
27
28#include "SVN.h"
29
30#include "Commitment.h"
31
32#include <string>
33#include <vector>
34
35#include <subversion-1/svn_client.h>
36
37namespace theplu {
38namespace svndigest {
39
40  class SVN;
41
42  /**
43     The SVNlog class is a utility class for taking care of 'svn
44     log' information. An 'svn log' is performed on an item, the
45     log information for each revision is stored in vectors.
46  */
47  class SVNlog {
48  public:
49
50    /**
51       \brief The contructor.
52       
53       The constructor performs an 'svn log' on \a path and
54       stores the information for later access.
55    */
56    explicit SVNlog(const std::string& path);
57
58    /**
59       \brief The destructor.
60    */
61    ~SVNlog(void);
62
63    /**
64       \return Authors
65    */
66    inline const std::vector<std::string>& author(void) const
67    { return lb_.authors; }
68
69    /**
70       \return Dates
71    */
72    inline const std::vector<std::string>& date(void) const
73    { return lb_.commit_dates; }
74
75    /**
76       \return true if \a author appears in log.
77    */
78    bool exist(std::string author) const;
79
80    /**
81       \return Messages
82    */
83    inline const std::vector<std::string>& message(void) const
84    { return lb_.msg; }
85
86    /**
87       \return Latest commit
88    */
89    Commitment latest_commit(void) const;
90
91    /**
92       \return Latest commit \a author did. If no author is found an
93       empty Commitment (default constructor) is returned.
94    */
95    Commitment latest_commit(std::string author) const;
96
97    /**
98       \return Revisions
99    */
100    inline const std::vector<size_t>& revision(void) const
101    { return lb_.rev; }
102
103  private:
104
105    ///
106    /// @brief Copy Constructor, not implemented.
107    ///
108    SVNlog(const SVNlog&);
109
110    /**
111       log information is stored in the log_receiver_baton. The
112       information is retrieved with the info_* set of member
113       functions. The struct is filled in the info_receiver function.
114
115       \see info_receiver
116    */
117    struct log_receiver_baton {
118      std::vector<std::string> authors;
119      std::vector<std::string> commit_dates;
120      std::vector<std::string> msg;
121      std::vector<size_t> rev;
122    } lb_;
123
124    /**
125       info_receiver is the function passed to the underlying
126       subversion API. This function is called by the subversion API
127       for every item matched by the conditions of the API call.
128
129       \see Subversion API documentation
130    */
131    // The return type should be svn_log_message_receiver_t but I
132    // cannot get it to compile. The svn API has a typedef like
133    // typedef svn_error_t*(* svn_log_message_receiver_t)(void *baton,
134    // apr_hash_t *changed_paths, svn_revnum_t revision, const char
135    // *author, const char *date,const char *message, apr_pool_t
136    // *pool) for svn_log_message_receiver_t.
137    static svn_error_t*
138    log_message_receiver(void *baton, apr_hash_t *changed_paths,
139                         svn_revnum_t rev, const char *author, const char *date,
140                         const char *msg, apr_pool_t *pool);
141  };
142
143}} // end of namespace svndigest and namespace theplu
144
145#endif
Note: See TracBrowser for help on using the repository browser.