1549 |
24 Oct 12 |
peter |
// $Id$ |
1549 |
24 Oct 12 |
peter |
2 |
|
1549 |
24 Oct 12 |
peter |
3 |
/* |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2012, 2023 Peter Johansson |
1549 |
24 Oct 12 |
peter |
5 |
|
1549 |
24 Oct 12 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
1549 |
24 Oct 12 |
peter |
7 |
|
1549 |
24 Oct 12 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
1549 |
24 Oct 12 |
peter |
under the terms of the GNU General Public License as published by |
1549 |
24 Oct 12 |
peter |
the Free Software Foundation; either version 3 of the License, or |
1549 |
24 Oct 12 |
peter |
(at your option) any later version. |
1549 |
24 Oct 12 |
peter |
12 |
|
1549 |
24 Oct 12 |
peter |
svndigest is distributed in the hope that it will be useful, but |
1549 |
24 Oct 12 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1549 |
24 Oct 12 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1549 |
24 Oct 12 |
peter |
General Public License for more details. |
1549 |
24 Oct 12 |
peter |
17 |
|
1549 |
24 Oct 12 |
peter |
You should have received a copy of the GNU General Public License |
1549 |
24 Oct 12 |
peter |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
1549 |
24 Oct 12 |
peter |
20 |
*/ |
1549 |
24 Oct 12 |
peter |
21 |
|
1619 |
12 Mar 23 |
peter |
22 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
23 |
|
1549 |
24 Oct 12 |
peter |
24 |
#include "SkipWhiteSpaceIterator.h" |
1549 |
24 Oct 12 |
peter |
25 |
|
1549 |
24 Oct 12 |
peter |
26 |
#include <string> |
1549 |
24 Oct 12 |
peter |
27 |
|
1549 |
24 Oct 12 |
peter |
28 |
namespace theplu { |
1549 |
24 Oct 12 |
peter |
29 |
namespace svndigest { |
1549 |
24 Oct 12 |
peter |
30 |
|
1549 |
24 Oct 12 |
peter |
31 |
using std::string; |
1549 |
24 Oct 12 |
peter |
32 |
|
1549 |
24 Oct 12 |
peter |
33 |
SkipWhiteSpaceIterator::SkipWhiteSpaceIterator(string::const_iterator b, |
1549 |
24 Oct 12 |
peter |
34 |
string::const_iterator e) |
1550 |
24 Oct 12 |
peter |
35 |
: base_(b), end_(e) |
1550 |
24 Oct 12 |
peter |
36 |
{ |
1550 |
24 Oct 12 |
peter |
// if b points to whitespace, increment |
1550 |
24 Oct 12 |
peter |
38 |
if (base_ != end_ && isspace(*base_)) |
1550 |
24 Oct 12 |
peter |
39 |
++(*this); |
1550 |
24 Oct 12 |
peter |
40 |
} |
1549 |
24 Oct 12 |
peter |
41 |
|
1549 |
24 Oct 12 |
peter |
42 |
|
1549 |
24 Oct 12 |
peter |
43 |
const std::string::const_iterator& SkipWhiteSpaceIterator::base(void) const |
1549 |
24 Oct 12 |
peter |
44 |
{ |
1549 |
24 Oct 12 |
peter |
45 |
return base_; |
1549 |
24 Oct 12 |
peter |
46 |
} |
1549 |
24 Oct 12 |
peter |
47 |
|
1549 |
24 Oct 12 |
peter |
48 |
|
1549 |
24 Oct 12 |
peter |
49 |
SkipWhiteSpaceIterator::reference SkipWhiteSpaceIterator::operator*(void) const |
1549 |
24 Oct 12 |
peter |
50 |
{ |
1549 |
24 Oct 12 |
peter |
51 |
return *base_; |
1549 |
24 Oct 12 |
peter |
52 |
} |
1549 |
24 Oct 12 |
peter |
53 |
|
1549 |
24 Oct 12 |
peter |
54 |
|
1549 |
24 Oct 12 |
peter |
55 |
SkipWhiteSpaceIterator::pointer SkipWhiteSpaceIterator::operator->(void) const |
1549 |
24 Oct 12 |
peter |
56 |
{ |
1549 |
24 Oct 12 |
peter |
57 |
return &(*base_); |
1549 |
24 Oct 12 |
peter |
58 |
} |
1549 |
24 Oct 12 |
peter |
59 |
|
1549 |
24 Oct 12 |
peter |
60 |
|
1549 |
24 Oct 12 |
peter |
61 |
SkipWhiteSpaceIterator& SkipWhiteSpaceIterator::operator++(void) |
1549 |
24 Oct 12 |
peter |
62 |
{ |
1549 |
24 Oct 12 |
peter |
63 |
++base_; |
1549 |
24 Oct 12 |
peter |
// go to next non white space |
1549 |
24 Oct 12 |
peter |
65 |
while (base_!= end_ && isspace(*base_)) |
1549 |
24 Oct 12 |
peter |
66 |
++base_; |
1549 |
24 Oct 12 |
peter |
67 |
return *this; |
1549 |
24 Oct 12 |
peter |
68 |
} |
1549 |
24 Oct 12 |
peter |
69 |
|
1549 |
24 Oct 12 |
peter |
70 |
|
1549 |
24 Oct 12 |
peter |
71 |
bool operator==(const SkipWhiteSpaceIterator& lhs, |
1549 |
24 Oct 12 |
peter |
72 |
const SkipWhiteSpaceIterator& rhs) |
1549 |
24 Oct 12 |
peter |
73 |
{ |
1549 |
24 Oct 12 |
peter |
74 |
return lhs.base() == rhs.base(); |
1549 |
24 Oct 12 |
peter |
75 |
} |
1549 |
24 Oct 12 |
peter |
76 |
|
1549 |
24 Oct 12 |
peter |
77 |
|
1549 |
24 Oct 12 |
peter |
78 |
bool operator!=(const SkipWhiteSpaceIterator& lhs, |
1549 |
24 Oct 12 |
peter |
79 |
const SkipWhiteSpaceIterator& rhs) |
1549 |
24 Oct 12 |
peter |
80 |
{ |
1549 |
24 Oct 12 |
peter |
81 |
return lhs.base() != rhs.base(); |
1549 |
24 Oct 12 |
peter |
82 |
} |
1549 |
24 Oct 12 |
peter |
83 |
|
1549 |
24 Oct 12 |
peter |
84 |
}} // end of namespace svndigest and namespace theplu |