1use std::ffi::c_int;
2
3use crate::tre;
4
5#[allow(clippy::module_name_repetitions)]
6pub type RegFlags = c_int;
7
8#[allow(clippy::module_name_repetitions)]
10#[derive(Clone, Copy, Debug)]
11pub struct RegcompFlags(RegFlags);
12
13impl RegcompFlags {
14 pub const NONE: RegFlags = 0;
16
17 pub const BASIC: RegFlags = tre::REG_BASIC;
19
20 pub const EXTENDED: RegFlags = tre::REG_EXTENDED;
22
23 pub const ICASE: RegFlags = tre::REG_ICASE;
25
26 pub const LITERAL: RegFlags = tre::REG_LITERAL;
28
29 pub const NOSPEC: RegFlags = tre::REG_NOSPEC;
31
32 pub const NEWLINE: RegFlags = tre::REG_NEWLINE;
34
35 pub const NOSUB: RegFlags = tre::REG_NOSUB;
37
38 pub const RIGHT_ASSOC: RegFlags = tre::REG_RIGHT_ASSOC;
40
41 pub const UNGREEDY: RegFlags = tre::REG_UNGREEDY;
43
44 pub const USEBYTES: RegFlags = tre::REG_USEBYTES;
46
47 #[must_use]
49 pub const fn new() -> Self {
50 Self(0)
51 }
52
53 #[must_use]
55 #[inline]
56 pub const fn add(&self, flag: RegFlags) -> Self {
57 Self(self.0 | flag)
58 }
59
60 #[must_use]
62 #[inline]
63 pub const fn remove(&self, flag: RegFlags) -> Self {
64 Self(self.0 & !flag)
65 }
66
67 #[must_use]
69 #[inline]
70 pub const fn get(&self) -> RegFlags {
71 self.0
72 }
73}
74
75#[allow(clippy::module_name_repetitions)]
77#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
78pub struct RegexecFlags(RegFlags);
79
80impl RegexecFlags {
81 pub const NONE: RegFlags = 0;
83
84 pub const APPROX_MATCHER: RegFlags = tre::REG_APPROX_MATCHER;
86
87 pub const BACKTRACKING_MATCHER: RegFlags = tre::REG_BACKTRACKING_MATCHER;
89
90 pub const NOTBOL: RegFlags = tre::REG_NOTBOL;
92
93 pub const NOTEOL: RegFlags = tre::REG_NOTEOL;
95
96 #[must_use]
98 #[inline]
99 pub const fn new() -> Self {
100 Self(0)
101 }
102
103 #[must_use]
105 #[inline]
106 pub const fn add(&self, flag: RegFlags) -> Self {
107 Self(self.0 | flag)
108 }
109
110 #[must_use]
112 #[inline]
113 pub const fn remove(&self, flag: RegFlags) -> Self {
114 Self(self.0 & !flag)
115 }
116
117 #[must_use]
119 #[inline]
120 pub const fn get(&self) -> RegFlags {
121 self.0
122 }
123}