Make UEFI boot-platform build again
[haiku.git] / headers / private / shared / RegExp.h
blob02149778486ac26730c6c80a4d6fb00fa93dc482
1 /*
2 * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef REG_EXP_H
6 #define REG_EXP_H
9 #include <stddef.h>
12 class RegExp {
13 public:
14 enum PatternType {
15 PATTERN_TYPE_REGULAR_EXPRESSION,
16 PATTERN_TYPE_WILDCARD
19 class MatchResult;
21 public:
22 RegExp();
23 RegExp(const char* pattern,
24 PatternType patternType
25 = PATTERN_TYPE_REGULAR_EXPRESSION,
26 bool caseSensitive = true);
27 RegExp(const RegExp& other);
28 ~RegExp();
30 bool IsValid() const
31 { return fData != NULL; }
33 bool SetPattern(const char* pattern,
34 PatternType patternType
35 = PATTERN_TYPE_REGULAR_EXPRESSION,
36 bool caseSensitive = true);
38 MatchResult Match(const char* string) const;
40 RegExp& operator=(const RegExp& other);
42 private:
43 struct Data;
44 struct MatchResultData;
46 private:
47 Data* fData;
51 class RegExp::MatchResult {
52 public:
53 MatchResult();
54 MatchResult(const MatchResult& other);
55 ~MatchResult();
57 bool HasMatched() const;
59 size_t StartOffset() const;
60 size_t EndOffset() const;
62 size_t GroupCount() const;
63 size_t GroupStartOffsetAt(size_t index) const;
64 size_t GroupEndOffsetAt(size_t index) const;
66 MatchResult& operator=(const MatchResult& other);
68 private:
69 friend class RegExp;
71 private:
72 MatchResult(MatchResultData* data);
73 // takes over the data reference
75 private:
76 MatchResultData* fData;
80 #endif // REG_EXP_H