forked from csutils/csdiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefqueue.hh
102 lines (80 loc) · 2.76 KB
/
defqueue.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright (C) 2011 - 2012 Red Hat, Inc.
*
* This file is part of csdiff.
*
* csdiff is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* csdiff is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with csdiff. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef H_GUARD_DEFQUEUE_H
#define H_GUARD_DEFQUEUE_H
#include "abstract-parser.hh"
#include <list>
#include <boost/foreach.hpp>
class MsgFilter;
class DefQueue {
private:
typedef std::list<Defect> TDefList;
typedef std::map<std::string, TDefList> TDefByFile;
typedef std::map<std::string, TDefByFile> TDefByChecker;
TDefByChecker stor_;
MsgFilter *filt_;
public:
DefQueue();
void hashDefect(const Defect &);
bool lookup(
Defect &dst,
const std::string &checker,
const std::string &fileName);
bool empty() const {
return stor_.empty();
}
template <class TVisitor> bool walk(TVisitor &);
};
template <class TVisitor> bool DefQueue::walk(TVisitor &visitor) {
BOOST_FOREACH(const TDefByChecker::const_reference iRow, stor_)
BOOST_FOREACH(const TDefByFile::const_reference iCol, iRow.second)
BOOST_FOREACH(const Defect &def, iCol.second)
if (! /* continue */ visitor(def))
return false;
return true;
}
class DefQueryParser {
public:
struct QRow {
int cid;
std::string checker;
std::string fileName;
std::string fnc;
QRow(): cid(-1) { }
};
DefQueryParser(std::istream &input, const std::string &fName):
input_(input),
fName_(fName),
lineno_(0),
hasError_(false)
{
}
bool getNext(QRow &dst);
bool hasError() const {
return hasError_;
}
private:
bool parse(QRow &dst);
private:
std::istream &input_;
const std::string fName_;
int lineno_;
bool hasError_;
};
#endif /* H_GUARD_DEFQUEUE_H */