libcamgm
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
ca-mgm
PerlRegEx.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 Quest Software, 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 Quest Software, 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 CA_MGM_PERL_REGEX_HPP
35
#define CA_MGM_PERL_REGEX_HPP
36
37
#include <
ca-mgm/String.hpp
>
38
#include <vector>
39
40
#include <pcre.h>
41
42
namespace
ca_mgm
43
{
44
55
class
PerlRegEx
56
{
57
public
:
63
typedef
std::vector<int>
MatchVector
;
64
66
struct
match_t
{
67
int
rm_so
;
68
int
rm_eo
;
69
};
70
72
typedef
std::vector<match_t>
MatchArray
;
73
77
PerlRegEx
();
78
86
PerlRegEx
(
const
std::string ®ex,
int
cflags = 0);
87
96
PerlRegEx
(
const
PerlRegEx
&ref);
97
101
~PerlRegEx
();
102
110
PerlRegEx
&
operator =
(
const
PerlRegEx
&ref);
111
141
bool
compile
(
const
std::string ®ex,
142
int
cflags = 0);
143
157
int
errorCode
();
158
165
std::string
errorString
()
const
;
166
170
std::string
patternString
()
const
;
171
175
int
compileFlags
()
const
;
176
180
bool
isCompiled
()
const
;
181
268
bool
execute
(
MatchVector
&sub,
269
const
std::string &str,
270
size_t
index = 0,
271
size_t
count = 0,
272
int
eflags = 0);
273
bool
execute
(
MatchArray
&sub,
274
const
std::string &str,
275
size_t
index = 0,
276
size_t
count = 0,
277
int
eflags = 0);
278
/* @} */
279
305
std::vector<std::string>
capture
(
const
std::string &str,
306
size_t
index = 0,
307
size_t
count = 0,
308
int
eflags = 0);
309
344
std::string
replace
(
const
std::string &str,
345
const
std::string &rep,
346
bool
global =
false
,
347
int
eflags = 0);
348
379
std::vector<std::string>
split
(
const
std::string &str,
380
bool
empty =
false
,
381
int
eflags = 0);
382
408
std::vector<std::string>
grep
(
const
std::vector<std::string> &src,
409
int
eflags = 0);
410
436
bool
match
(
const
std::string &str,
437
size_t
index = 0,
438
int
eflags = 0)
const
;
439
440
private
:
441
pcre *
m_pcre
;
442
int
m_flags
;
443
mutable
int
m_ecode
;
444
mutable
std::string
m_error
;
445
std::string
m_rxstr
;
446
};
447
448
}
// End of BLOCXX_NAMESPACE
449
450
451
#endif // CA_MGM_PERL_REGEX_HPP
452
/* vim: set ts=8 sts=8 sw=8 ai noet: */
453
Generated by
1.8.2