summaryrefslogtreecommitdiff
path: root/CyteKit/PerlCompatibleRegEx.hpp
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-03-20 16:02:29 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-20 16:02:29 -0700
commite967efd5e9745242298f8792cb7d47dca141bfbf (patch)
tree60915ce2b3ed202cc11e2db3baa5d79dfd2dcbee /CyteKit/PerlCompatibleRegEx.hpp
parent2d46d29e56fa4e58003787c67953937099fe249c (diff)
Expose ramifications of kCFCoreFoundationVersionNumber.
Diffstat (limited to 'CyteKit/PerlCompatibleRegEx.hpp')
-rw-r--r--CyteKit/PerlCompatibleRegEx.hpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/CyteKit/PerlCompatibleRegEx.hpp b/CyteKit/PerlCompatibleRegEx.hpp
index e1c0e2e..38a9462 100644
--- a/CyteKit/PerlCompatibleRegEx.hpp
+++ b/CyteKit/PerlCompatibleRegEx.hpp
@@ -56,15 +56,20 @@ class Pcre {
public:
Pcre() :
code_(NULL),
- study_(NULL)
+ study_(NULL),
+ data_(NULL)
{
}
- Pcre(const char *regex) :
+ Pcre(const char *regex, NSString *data = nil) :
code_(NULL),
- study_(NULL)
+ study_(NULL),
+ data_(NULL)
{
this->operator =(regex);
+
+ if (data != nil)
+ this->operator ()(data);
}
void operator =(const char *regex) {
@@ -102,8 +107,17 @@ class Pcre {
}
bool operator ()(const char *data, size_t size) {
- data_ = data;
- return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
+ if (pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0) {
+ data_ = data;
+ return true;
+ } else {
+ data_ = NULL;
+ return false;
+ }
+ }
+
+ operator bool() const {
+ return data_ != NULL;
}
NSString *operator ->*(NSString *format) const {