]> git.lyx.org Git - lyx.git/blob - src/support/LRegex.h
fix the smallcaps drawing, move xfont metrics functions out from LyXFont, move non...
[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
18 ///
19 class LRegex {
20 public:
21         ///
22         LRegex(string const & regex);
23
24         ///
25         ~LRegex();
26
27         ///
28         typedef std::pair<string::size_type, string::size_type> MatchPair;
29
30         ///
31         typedef std::vector<MatchPair> SubMatches;
32
33         /// Returns all the matches in a vector
34         SubMatches const & exec(string const & str) const;
35
36         /// The whole of str matches regex.
37         bool exact_match(string const & str) const;
38
39         ///
40         MatchPair first_match(string const & str) const;
41
42         ///
43         string getError() const;
44
45         ///
46         int getErrorCode() const;
47
48         /// Will the next operation fail of not.
49         bool ok() const;
50 private:
51         ///
52         struct Impl;
53
54         ///
55         Impl * impl;
56 };
57
58
59 // We comment out these, we can comment them in when we need them.
60 #if 0
61 // some built in regular expressions
62
63 extern const LRegex LRXwhite;          // = "[ \n\t\r\v\f]+"
64 extern const LRegex LRXint;            // = "-?[0-9]+"
65 extern const LRegex LRXdouble;         // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
66                                        //    \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
67                                        //    \\([eE][---+]?[0-9]+\\)?"
68 //extern const LRegex LRXalpha;          // = "[A-Za-z]+"
69 //extern const LRegex LRXlowercase;      // = "[a-z]+"
70 //extern const LRegex LRXuppercase;      // = "[A-Z]+"
71 //extern const LRegex LRXalphanum;       // = "[0-9A-Za-z]+"
72 extern const LRegex LRXidentifier;     // = "[A-Za-z_][A-Za-z0-9_]*"
73 #endif
74 #endif