blocxx
Main Page
Namespaces
Classes
Files
File List
File Members
src
blocxx
PosixRegEx.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright (C) 2005 Novell, Inc. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
6
*
7
* - Redistributions of source code must retain the above copyright notice,
8
* this list of conditions and the following disclaimer.
9
*
10
* - Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
*
14
* - Neither the name of Vintela, Inc., Novell, Inc., nor the names of its
15
* contributors may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc., Novell, Inc., OR THE
22
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*******************************************************************************/
34
#ifndef BLOCXX_POSIX_REGEX_HPP_INCLUDE_GUARD_HPP_
35
#define BLOCXX_POSIX_REGEX_HPP_INCLUDE_GUARD_HPP_
36
#include "blocxx/BLOCXX_config.h"
37
#include "
blocxx/RegExException.hpp
"
38
39
#ifdef BLOCXX_HAVE_REGEX
40
#include "
blocxx/String.hpp
"
41
#include "
blocxx/Array.hpp
"
42
43
#ifdef BLOCXX_HAVE_REGEX_H
44
#include <regex.h>
45
46
namespace
BLOCXX_NAMESPACE
47
{
48
58
class
BLOCXX_COMMON_API PosixRegEx
59
{
60
public
:
67
typedef
regmatch_t match_t;
68
72
typedef
blocxx::Array<match_t> MatchArray;
73
77
PosixRegEx();
78
88
PosixRegEx(
const
String ®ex,
int
cflags = REG_EXTENDED);
89
98
PosixRegEx(
const
PosixRegEx &ref);
99
103
~PosixRegEx();
104
112
PosixRegEx& operator = (
const
PosixRegEx &ref);
113
114
136
bool
compile(
const
String ®ex,
137
int
cflags = REG_EXTENDED);
138
145
int
errorCode();
146
153
String errorString()
const
;
154
155
159
String patternString()
const
;
160
164
int
compileFlags()
const
;
165
169
bool
isCompiled()
const
;
170
171
237
bool
execute(MatchArray &sub,
238
const
String &str,
239
size_t
index = 0,
240
size_t
count = 0,
241
int
eflags = 0);
242
269
StringArray
capture(
const
String &str,
270
size_t
index = 0,
271
size_t
count = 0,
272
int
eflags = 0);
273
309
String replace(
const
String &str,
310
const
String &rep,
311
bool
global =
false
,
312
int
eflags = 0);
313
345
StringArray
split (
const
String &str,
346
bool
empty =
false
,
347
int
eflags = 0);
348
375
StringArray
grep (
const
StringArray
&src,
376
int
eflags = 0);
377
403
bool
match (
const
String &str,
404
size_t
index = 0,
405
int
eflags = 0)
const
;
406
407
private
:
408
bool
compiled;
409
int
m_flags;
410
mutable
int
m_ecode;
411
mutable
String m_error;
412
String m_rxstr;
413
regex_t m_regex;
414
};
415
416
}
// End of BLOCXX_NAMESPACE
417
418
#endif // BLOCXX_HAVE_REGEX_H
419
#endif // BLOCXX_HAVE_REGEX
420
421
#endif // BLOCXX_POSIX_REGEX_HPP_INCLUDE_GUARD_HPP_
422
/* vim: set ts=8 sts=8 sw=8 ai noet: */
423
Generated by
1.8.2