source: trunk/lib/LogIterator.cc @ 519

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

trac moved to new location.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1// $Id: LogIterator.cc 519 2007-12-23 20:14:50Z jari $
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  const Commitment& LogIterator::operator*() const
77  {
78    assert(index_<log_.revision().size());
79    if (!commit_){
80      std::cout << index_ << std::endl;
81     
82    }
83    assert(commit_);
84    return *commit_;
85  }
86
87
88  const Commitment* LogIterator::operator->(void) const
89  {
90    return &this->operator*();
91  }
92
93
94  LogIterator& LogIterator::operator++(void)
95  {
96    ++index_;
97    if (index_>log_.revision().size())
98      index_=log_.revision().size();
99    update_commit();
100   
101    return *this;
102  }
103
104}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.