source: trunk/lib/LogIterator.cc @ 552

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

fixes linetype Copyright

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1// $Id: LogIterator.cc 552 2008-01-08 14:40:37Z peter $
2
3/*
4  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
5
6  This file is part of svndigest, http://trac.thep.lu.se/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
28#include <cassert>
29
30#include <iostream>
31namespace theplu{
32namespace svndigest{
33
34  LogIterator::LogIterator(const SVNlog& log, size_t index)
35    : commit_(NULL), log_(log), index_(index)
36  {
37    update_commit();
38  }
39
40 
41  LogIterator::LogIterator(const LogIterator& other)
42    : commit_(NULL), log_(other.log_), index_(other.index_) 
43  {
44    update_commit();
45  }
46
47 
48  LogIterator::~LogIterator()
49  {
50    if (commit_)
51      delete commit_;
52  }
53
54
55  void LogIterator::update_commit(void)
56  {
57    if (commit_)
58      delete commit_;
59    if (index_<log_.author().size())
60      commit_ = new Commitment(log_.author()[index_], 
61                               log_.date()[index_], 
62                               log_.message()[index_], 
63                               log_.revision()[index_]);
64    else
65      commit_ = NULL;
66  }
67
68 
69  bool LogIterator::operator<(const LogIterator& other) const
70  {
71    assert(&log_==&other.log_);
72    return index_<other.index_;
73  }
74
75
76  bool LogIterator::operator==(const LogIterator& other) const
77  {
78    assert(&log_==&other.log_);
79    return index_==other.index_;
80  }
81
82
83  bool LogIterator::operator!=(const LogIterator& other) const
84  {
85    assert(&log_==&other.log_);
86    return index_!=other.index_;
87  }
88
89
90  const Commitment& LogIterator::operator*() const
91  {
92    assert(index_<log_.revision().size());
93    if (!commit_){
94      std::cout << index_ << std::endl;
95     
96    }
97    assert(commit_);
98    return *commit_;
99  }
100
101
102  const Commitment* LogIterator::operator->(void) const
103  {
104    return &this->operator*();
105  }
106
107
108  LogIterator& LogIterator::operator++(void)
109  {
110    ++index_;
111    if (index_>log_.revision().size())
112      index_=log_.revision().size();
113    update_commit();
114   
115    return *this;
116  }
117
118}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.