Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
regex.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2#ifndef __ASE_REGEX_HH__
3#define __ASE_REGEX_HH__
4
5#include <ase/cxxaux.hh>
6
7namespace Ase {
8
10class Re final {
11public:
12 enum Flags : int32_t {
13 DEFAULT = 0,
14 ERE = 1 << 0, // Posix Extended
15 I = 1 << 4, // IGNORECASE
16 M = 1 << 5, // MULTILINE
17 N = 1 << 6, // NO_AUTO_CAPTURE
18 S = 1 << 7, // DOTALL
19 X = 1 << 8, // EXTENDED
20 XX = 1 << 9, // EXTENDED_MORE
21 J = 1 << 10, // DUPNAMES
22 U = 1 << 11, // UNGREEDY
23 };
24 static StringS findall (const String &regex, const String &input, Flags = DEFAULT);
25 static ssize_t search (const String &regex, const String &input, Flags = DEFAULT);
26 static String grep (const String &regex, const String &input, int group = 0, Flags = DEFAULT);
27 static String sub (const String &regex, const String &subst, const String &input, Flags = DEFAULT);
28 static String sub (const String &regex, const String &subst, const String &input, uint count, Flags = DEFAULT);
29};
30extern constexpr inline Re::Flags operator| (Re::Flags a, Re::Flags b) { return Re::Flags (int32_t (a) | int32_t (b)); }
31
32} // Ase
33
34#endif // __ASE_REGEX_HH__
Wrapper for std::regex to simplify usage and reduce compilation time.
Definition regex.hh:10
static String sub(const String &regex, const String &subst, const String &input, Flags=DEFAULT)
Substitute regex in input by sbref with backreferences $00…$99 or $&.
Definition regex.cc:249
static String grep(const String &regex, const String &input, int group=0, Flags=DEFAULT)
Find regex in input and return matching string.
Definition regex.cc:225
static StringS findall(const String &regex, const String &input, Flags=DEFAULT)
Find regex in input and return non-overlapping matches.
Definition regex.cc:233
static ssize_t search(const String &regex, const String &input, Flags=DEFAULT)
Find regex in input and return match position >= 0 or return < 0 otherwise.
Definition regex.cc:217
The Anklang C++ API namespace.
Definition api.hh:9
uint32_t uint
Provide 'uint' as convenience type.
Definition cxxaux.hh:18
typedef int32_t
typedef ssize_t