source: trunk/lib/LogIterator.cc @ 448

Last change on this file since 448 was 448, checked in by Peter Johansson, 14 years ago

adding LogIterator?

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: LogIterator.cc 448 2007-08-16 18:44:46Z peter $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of svndigest, http://trac.thep.lu.se/trac/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "LogIterator.h"
25
26#include "SVNlog.h"
27
28namespace theplu{
29namespace svndigest{
30
31  LogIterator::LogIterator(const SVNlog& log, size_t index)
32    : log_(log), index_(index) 
33  {}
34
35 
36  LogIterator::~LogIterator()
37  {
38    if (commit_)
39      delete commit_;
40  }
41
42
43  bool LogIterator::operator<(const LogIterator& other) const
44  {
45    return index_<other.index_;
46  }
47
48
49  const Commitment& LogIterator::operator*()
50  {
51    assert(index_<log_.revision().size());
52    if (!commit_)
53      commit_ = new Commitment(log_.author()[index_], 
54                              log_.date()[index_], 
55                              log_.message()[index_], 
56                              log_.revision()[index_]);
57    return *commit_;
58  }
59
60
61  const Commitment* LogIterator::operator->(void)
62  {
63    return &this->operator*();
64  }
65
66
67  LogIterator& LogIterator::operator++(void)
68  {
69    if (index_<log_.revision().size()){
70      ++index_;
71      delete commit_;
72      commit_ = NULL;
73    }                               
74   
75    return *this;
76  }
77
78}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.