libcamgm
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
ca-mgm
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 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_POSIX_REGEX_HPP
35
#define CA_MGM_POSIX_REGEX_HPP
36
37
#include <
ca-mgm/String.hpp
>
38
#include <vector>
39
40
#include <regex.h>
41
42
namespace
ca_mgm
43
{
44
54
class
PosixRegEx
55
{
56
public
:
63
typedef
regmatch_t
match_t
;
64
68
typedef
std::vector<match_t>
MatchArray
;
69
73
PosixRegEx
();
74
84
PosixRegEx
(
const
std::string ®ex,
int
cflags = REG_EXTENDED);
85
94
PosixRegEx
(
const
PosixRegEx
&ref);
95
99
~PosixRegEx
();
100
108
PosixRegEx
&
operator =
(
const
PosixRegEx
&ref);
109
110
132
bool
compile
(
const
std::string ®ex,
133
int
cflags = REG_EXTENDED);
134
141
int
errorCode
();
142
149
std::string
errorString
()
const
;
150
151
155
std::string
patternString
()
const
;
156
160
int
compileFlags
()
const
;
161
165
bool
isCompiled
()
const
;
166
167
233
bool
execute
(
MatchArray
&sub,
234
const
std::string &str,
235
size_t
index = 0,
236
size_t
count = 0,
237
int
eflags = 0);
238
265
std::vector<std::string>
capture
(
const
std::string &str,
266
size_t
index = 0,
267
size_t
count = 0,
268
int
eflags = 0);
269
305
std::string
replace
(
const
std::string &str,
306
const
std::string &rep,
307
bool
global =
false
,
308
int
eflags = 0);
309
341
std::vector<std::string>
split
(
const
std::string &str,
342
bool
empty =
false
,
343
int
eflags = 0);
344
371
std::vector<std::string>
grep
(
const
std::vector<std::string> &src,
372
int
eflags = 0);
373
399
bool
match
(
const
std::string &str,
400
size_t
index = 0,
401
int
eflags = 0)
const
;
402
403
private
:
404
bool
compiled
;
405
int
m_flags
;
406
mutable
int
m_ecode
;
407
mutable
std::string
m_error
;
408
std::string
m_rxstr
;
409
regex_t
m_regex
;
410
};
411
412
}
// End of BLOCXX_NAMESPACE
413
414
#endif // CA_MGM_POSIX_REGEX_HPP
415
/* vim: set ts=8 sts=8 sw=8 ai noet: */
416
Generated by
1.8.2