File: CWRegEx.h

package info (click to toggle)
pantomime 1.4.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,288 kB
  • sloc: objc: 22,039; makefile: 11; sh: 4
file content (105 lines) | stat: -rw-r--r-- 3,534 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
**  CWRegEx.h
**
**  Copyright (c) 2001-2004 Ludovic Marcotte, Francis Lachapelle
**
**  Author: Francis Lachapelle <francis@Sophos.ca>
**          Ludovic Marcotte <ludovic@Sophos.ca>
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**  
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
**  Lesser General Public License for more details.
**  
** You should have received a copy of the GNU General Public License
** along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _Pantomime_H_CWRegEx
#define _Pantomime_H_CWRegEx

#include <sys/types.h>
#include <regex.h>

#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>

/*!
  @class CWRegEx
  @abstract Provides a simple object-oriented wrapper around POSIX regex.
  @discussion This class provides a simple and efficient interface around
              POSIX regex, which are available on most UNIX (or like) systems.
*/
@interface CWRegEx : NSObject
{
  @private
    regex_t _re;
}

/*!
  @method initWithPattern:
  @discussion This method invokes initWithPattern: flags: with
              the default REG_EXTENDED flag.
  @param thePattern The regular expression to use.
  @result An instance of CWRegEx, nil in case of an error.
*/
- (id) initWithPattern: (NSString *) thePattern;

/*!
  @method initWithPattern: flags:
  @discussion This method is used to initialize a CWRegEx instance
              using the specified pattern and flags.
  @param thePattern The regular expression to use.
  @param theFlags The flags to use. See regcomp(3) for a description
                  of the available flags.
  @result An instance of CWRegEx, nil in case of an error.
*/
- (id) initWithPattern: (NSString *) thePattern
                 flags: (int) theFlags;

/*!
  @method regexWithPattern:
  @discussion Invokes initWithPattern: with <i>thePattern</i> and
              autoreleases the returned instance.
*/
+ (id) regexWithPattern: (NSString *) thePattern;

/*!
  @method regexWithPattern: flags:
  @discussion Invokes initWithPattern: flags: with <i>thePattern</i> and
              <i>theFlags</i>, then autoreleases the returned instance.
*/
+ (id) regexWithPattern: (NSString *) thePattern
                  flags: (int) theFlags;

/*!
  @method matchString:
  @discussion This method is used to try to match <i>theString</i>
              using the instance's pattern.
  @param theString The string to match.
  @result An array of matches (NSString instances), which can be empty but not nil.
*/
- (NSArray *) matchString: (NSString *) theString;

/*!
  @method matchString: withPattern: isCaseSensitive:
  @discussion This method provides an easy way to quickly
              match a string with the specified pattern, in a
	      case-sensitive manner or not.
  @param theString The string to match.
  @param thePattern The regular expression to use.
  @param theBOOL Case-sensitive, or not.
  @result An array of matches (NSString instances), which can be empty but not nil.
*/
+ (NSArray *) matchString: (NSString *) theString
              withPattern: (NSString *) thePattern
          isCaseSensitive: (BOOL) theBOOL;

@end

#endif // _Pantomime_H_CWRegEx