]> git.lyx.org Git - lyx.git/blob - src/support/LRegex.h
the freespacing patch from Kayvan, draw the math empty delim with onoffdash, asure...
[lyx.git] / src / support / LRegex.h
1 // -*- C++ -*-
2
3 /* C++ wrapper around the POSIX regex functions:
4    regcomp, regexec, regerror, regfree.
5 */
6
7 #ifndef LREGEX_H
8 #define LREGEX_H
9
10 #ifdef __GNUG__
11 #pragma interface
12 #endif
13
14 #include "LString.h"
15
16 #include <vector>
17 using std::vector;
18 using std::pair;
19
20 ///
21 class LRegex {
22 public:
23         ///
24         LRegex(string const & regex);
25
26         ///
27         ~LRegex();
28
29         ///
30         typedef pair<string::size_type, string::size_type> MatchPair;
31
32         ///
33         typedef vector<MatchPair> SubMatches;
34
35         /// Returns all the matches in a vector
36         SubMatches const & exec(string const & str) const;
37
38         /// The whole of str matches regex.
39         bool exact_match(string const & str) const;
40
41         ///
42         MatchPair first_match(string const & str) const;
43
44         ///
45         string getError() const;
46
47         ///
48         int getErrorCode() const;
49
50         /// Will the next operation fail of not.
51         bool ok() const;
52 private:
53         ///
54         struct Impl;
55
56         ///
57         Impl * impl;
58 };
59
60
61 // We comment out these, we can comment them in when we need them.
62 #if 0
63 // some built in regular expressions
64
65 extern const LRegex LRXwhite;          // = "[ \n\t\r\v\f]+"
66 extern const LRegex LRXint;            // = "-?[0-9]+"
67 extern const LRegex LRXdouble;         // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
68                                        //    \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
69                                        //    \\([eE][---+]?[0-9]+\\)?"
70 //extern const LRegex LRXalpha;          // = "[A-Za-z]+"
71 //extern const LRegex LRXlowercase;      // = "[a-z]+"
72 //extern const LRegex LRXuppercase;      // = "[A-Z]+"
73 //extern const LRegex LRXalphanum;       // = "[0-9A-Za-z]+"
74 extern const LRegex LRXidentifier;     // = "[A-Za-z_][A-Za-z0-9_]*"
75 #endif
76 #endif