1 | /* |
2 | * Copyright (c) 2017-2018, Intel Corporation |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions are met: |
6 | * |
7 | * * Redistributions of source code must retain the above copyright notice, |
8 | * this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of Intel Corporation nor the names of its contributors |
13 | * may be used to endorse or promote products derived from this software |
14 | * without specific prior written permission. |
15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
28 | |
29 | /** |
30 | * \file |
31 | * \brief ExpressionInfo class for storing the properties of an expression. |
32 | */ |
33 | |
34 | #ifndef COMPILER_EXPRESSION_INFO_H |
35 | #define COMPILER_EXPRESSION_INFO_H |
36 | |
37 | #include "ue2common.h" |
38 | #include "som/som.h" |
39 | |
40 | namespace ue2 { |
41 | |
42 | /** \brief Properties of an expression. */ |
43 | class ExpressionInfo { |
44 | public: |
45 | ExpressionInfo(unsigned int index_in, bool allow_vacuous_in, |
46 | bool highlander_in, bool utf8_in, bool prefilter_in, |
47 | som_type som_in, ReportID report_in, u64a min_offset_in, |
48 | u64a max_offset_in, u64a min_length_in, u32 edit_distance_in, |
49 | u32 hamm_distance_in, bool quiet_in) |
50 | : index(index_in), report(report_in), allow_vacuous(allow_vacuous_in), |
51 | highlander(highlander_in), utf8(utf8_in), prefilter(prefilter_in), |
52 | som(som_in), min_offset(min_offset_in), max_offset(max_offset_in), |
53 | min_length(min_length_in), edit_distance(edit_distance_in), |
54 | hamm_distance(hamm_distance_in), quiet(quiet_in) {} |
55 | |
56 | /** |
57 | * \brief Index of the expression represented by this graph. |
58 | * |
59 | * Used: |
60 | * - down the track in error handling; |
61 | * - for identifying parts of an expression in highlander mode. |
62 | */ |
63 | unsigned int index; |
64 | |
65 | /** \brief Report ID specified by the user. */ |
66 | ReportID report; |
67 | |
68 | /** \brief Vacuous pattern is allowed. (HS_FLAG_ALLOWEMPTY) */ |
69 | bool allow_vacuous; |
70 | |
71 | /** \brief "Highlander" (single match) pattern. (HS_FLAG_SINGLEMATCH) */ |
72 | bool highlander; |
73 | |
74 | /** \brief UTF-8 pattern. (HS_FLAG_UTF8) */ |
75 | bool utf8; |
76 | |
77 | /** \brief Prefiltering pattern. (HS_FLAG_PREFILTER) */ |
78 | bool prefilter; |
79 | |
80 | /** \brief Start-of-match type requested, or SOM_NONE. */ |
81 | som_type som; |
82 | |
83 | /** \brief Minimum match offset extended parameter. 0 if not used. */ |
84 | u64a min_offset; |
85 | |
86 | /** |
87 | * \brief Maximum match offset extended parameter. |
88 | * MAX_OFFSET if not used. |
89 | */ |
90 | u64a max_offset; |
91 | |
92 | /** \brief Minimum match length extended parameter. 0 if not used. */ |
93 | u64a min_length; |
94 | |
95 | /** |
96 | * \brief Approximate matching edit distance extended parameter. |
97 | * 0 if not used. |
98 | */ |
99 | u32 edit_distance; |
100 | u32 hamm_distance; |
101 | |
102 | /** \brief Quiet on match. */ |
103 | bool quiet; |
104 | }; |
105 | |
106 | } |
107 | |
108 | #endif // COMPILER_EXPRESSION_INFO_H |
109 | |