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