cprover
Loading...
Searching...
No Matches
prefix_filter.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Prefix Filtering
4
5
Author: Peter Schrammel
6
7
\*******************************************************************/
8
11
12
#include "
prefix_filter.h
"
13
14
#include <algorithm>
15
16
#include "
prefix.h
"
17
18
prefix_filtert::prefix_filtert
(
19
std::vector<std::string>
included_prefixes
,
20
std::vector<std::string>
excluded_prefixes
)
21
:
included_prefixes
(
std
::move(
included_prefixes
)),
22
excluded_prefixes
(
std
::move(
excluded_prefixes
))
23
{
24
}
25
26
bool
prefix_filtert::operator()
(
const
std::string &value)
const
27
{
28
if
(!
included_prefixes
.empty())
29
{
30
// We don't include everything, so let's check whether value is included.
31
const
bool
matches_included = std::any_of(
32
included_prefixes
.begin(),
33
included_prefixes
.end(),
34
[value](
const
std::string &prefix) { return has_prefix(value, prefix); });
35
if
(!matches_included)
36
return
false
;
37
}
38
39
// We know it's included so let's check whether it's excluded.
40
const
bool
matches_excluded = std::any_of(
41
excluded_prefixes
.begin(),
42
excluded_prefixes
.end(),
43
[value](
const
std::string &prefix) { return has_prefix(value, prefix); });
44
return
!matches_excluded;
45
}
prefix_filtert::included_prefixes
std::vector< std::string > included_prefixes
Definition
prefix_filter.h:33
prefix_filtert::prefix_filtert
prefix_filtert(std::vector< std::string > included_prefixes, std::vector< std::string > excluded_prefixes)
Definition
prefix_filter.cpp:18
prefix_filtert::operator()
bool operator()(const std::string &value) const
Return true iff value matches a prefix in included_prefixes, but doesn't match a prefix in excluded_p...
Definition
prefix_filter.cpp:26
prefix_filtert::excluded_prefixes
std::vector< std::string > excluded_prefixes
Definition
prefix_filter.h:34
std
STL namespace.
prefix.h
prefix_filter.h
Prefix Filtering.
util
prefix_filter.cpp
Generated by
1.13.2