Skip to content

Commit 9522f1b

Browse files
committed
lib/pcre/UniqueRegex: move struct CompileOptions to Options.hxx
1 parent cc10aab commit 9522f1b

2 files changed

Lines changed: 33 additions & 25 deletions

File tree

src/lib/pcre/Options.hxx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: BSD-2-Clause
2+
// Copyright CM4all GmbH
3+
// author: Max Kellermann <max.kellermann@ionos.com>
4+
5+
#pragma once
6+
7+
#include <pcre2.h>
8+
9+
namespace Pcre {
10+
11+
struct CompileOptions {
12+
bool anchored = false;
13+
bool caseless = false;
14+
bool capture = false;
15+
16+
explicit constexpr operator int() const noexcept {
17+
int options = PCRE2_DOTALL|PCRE2_NO_AUTO_CAPTURE;
18+
19+
if (anchored)
20+
options |= PCRE2_ANCHORED;
21+
22+
if (caseless)
23+
options |= PCRE2_CASELESS;
24+
25+
if (capture)
26+
options &= ~PCRE2_NO_AUTO_CAPTURE;
27+
28+
return options;
29+
}
30+
};
31+
32+
} // namespace Pcre

src/lib/pcre/UniqueRegex.hxx

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,11 @@
44

55
#pragma once
66

7+
#include "Options.hxx"
78
#include "RegexPointer.hxx"
89

910
#include <utility>
1011

11-
namespace Pcre {
12-
13-
struct CompileOptions {
14-
bool anchored = false;
15-
bool caseless = false;
16-
bool capture = false;
17-
18-
explicit constexpr operator int() const noexcept {
19-
int options = PCRE2_DOTALL|PCRE2_NO_AUTO_CAPTURE;
20-
21-
if (anchored)
22-
options |= PCRE2_ANCHORED;
23-
24-
if (caseless)
25-
options |= PCRE2_CASELESS;
26-
27-
if (capture)
28-
options &= ~PCRE2_NO_AUTO_CAPTURE;
29-
30-
return options;
31-
}
32-
};
33-
34-
} // namespace Pcre
35-
3612
class UniqueRegex : public RegexPointer {
3713
public:
3814
UniqueRegex() = default;

0 commit comments

Comments
 (0)