summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2004-07-15 15:42:53 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2004-07-15 15:42:53 +0000
commit4ed942bce4ffa1153722358e58aa6ea4c5b93d68 (patch)
treeb4fb1e6aa9c3268b68a80323dab272faba4a0e8b
parent0590c43a5318eca70aeb3376c32d1cb51e4cbb86 (diff)
downloadATCD-wotte-ACE-pcre-integration.tar.gz
Thu Jul 15 10:39:24 2004 Will Otte <wotte@dre.vanderbilt.edu>wotte-ACE-pcre-integration
-rw-r--r--ChangeLog7
-rw-r--r--ace/PCRE_Regex.cpp9
-rw-r--r--ace/PCRE_Regex.h126
-rw-r--r--ace/PCRE_Regex.inl257
4 files changed, 399 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9420d617f62..05a36d1413e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jul 15 10:39:24 2004 Will Otte <wotte@dre.vanderbilt.edu>
+ * ace/PCRE_Regex.h
+ * ace/PCRE_Regex.cpp
+ * ace/PCRE_Regex.inl
+
+ Initial commit. Provides an interface to the PCRE regex library.
+
Tue Jul 13 10:43:57 2004 Will Otte <wotte@dre.vanderbilt.edu>
* ace/OS_NS_regex.h:
diff --git a/ace/PCRE_Regex.cpp b/ace/PCRE_Regex.cpp
new file mode 100644
index 00000000000..5a1a0e2571d
--- /dev/null
+++ b/ace/PCRE_Regex.cpp
@@ -0,0 +1,9 @@
+// PCRE_Regex.cpp
+// $Id$
+
+#include "ace/PCRE_Regex.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ace/PCRE_Regex.inl"
+#endif /*__ACE_INLINE__*/
+
diff --git a/ace/PCRE_Regex.h b/ace/PCRE_Regex.h
new file mode 100644
index 00000000000..5b53417badb
--- /dev/null
+++ b/ace/PCRE_Regex.h
@@ -0,0 +1,126 @@
+// -*- C++ -*-
+
+/**
+ * @file PCRE_Regex.h
+ * @author Will Otte <wotte@dre.vanderbilt.edu>
+ *
+ * $Id$
+ */
+
+#ifndef ACE_PCRE_REGEX_H
+#define ACE_PCRE_REGEX_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/ACE_export.h"
+
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+// Pull in includes and define types needed for PCRE
+#if defined (ACE_HAS_PCRE)
+//# include "pcre/pcre.h"
+# include "pcre.h"
+ typedef ::pcre ACE_pcre;
+ typedef ::pcre_extra ACE_pcre_extra;
+#else
+ struct ACE_pcre {};
+ struct ACE_pcre_extra {};
+#endif /*ACE_HAS_PCRE*/
+
+/**
+ * @class ACE_Regex
+ *
+ * @brief Provides a wrapper for the PCRE regex library.
+ *
+ * This class provides an interface for perl compatible regular
+ * expressions using the PCRE library. If you want a POSIX interface,
+ * use OS_NS_regex.h
+ *
+ * Please see documentation included with PCRE for full usage
+ * explanations.
+ */
+class ACE_Export ACE_Regex
+{
+public:
+ static ACE_pcre *compile (const char *pattern,
+ int options,
+ const char **errptr,
+ int *erroffset,
+ const unsigned char *tableptr);
+
+ static int config (int what, void *where);
+
+ static int copy_named_substring (const ACE_pcre *code,
+ const char *subject,
+ int *ovector,
+ int stringcount,
+ const char *stringname,
+ char *buffer,
+ int buffersize);
+
+ static int copy_substring (const char *subject,
+ int *ovector,
+ int stringcount,
+ int stringnumber,
+ char *buffer,
+ int buffersize);
+
+ static int exec (const ACE_pcre *code,
+ const ACE_pcre_extra *extra,
+ const char *subject,
+ int length, int startoffset,
+ int options, int *ovector, int ovecsize);
+
+ static void free_substring (const char *stringptr);
+
+ static void free_substring_list (const char **stringptr);
+
+ static int fullinfo (const ACE_pcre *code,
+ const ACE_pcre_extra *extra,
+ int what, void *where);
+
+ static int get_named_substring (const ACE_pcre *code,
+ const char *subject,
+ int *ovector, int stringcount,
+ const char *stringname,
+ const char **stringptr);
+
+ static int get_stringnumber (const ACE_pcre *code,
+ const char *name);
+
+ static int get_substring (const char *subject,
+ int *ovector, int stringcount, int stringnumber,
+ const char **stringptr);
+
+ static int get_substring_list (const char *subject,
+ int *ovector, int stringcount,
+ const char ***listptr);
+
+ static int fullinfo (const ACE_pcre *,
+ int *optptr, int *firstcharptr);
+
+ static const unsigned char *maketables (void);
+
+ static ACE_pcre_extra *study (const ACE_pcre *code,
+ int options,
+ const char **errptr);
+
+ static const char *version (void);
+
+protected:
+ ACE_Regex ();
+
+};
+
+
+
+#if defined (__ACE_INLINE__)
+#include "ace/PCRE_Regex.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACE_PCRE_REGEX_H */
diff --git a/ace/PCRE_Regex.inl b/ace/PCRE_Regex.inl
new file mode 100644
index 00000000000..10e7ed7376d
--- /dev/null
+++ b/ace/PCRE_Regex.inl
@@ -0,0 +1,257 @@
+/* -*- C++ -*- */
+// $Id$
+// PCRE_Regex.inl
+
+ACE_INLINE ACE_pcre *
+ACE_Regex::compile (const char *pattern,
+ int options,
+ const char **errptr,
+ int *erroffset,
+ const unsigned char *tableptr)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_compile(pattern, options, errptr, erroffset, tableptr);
+#else
+ ACE_UNUSED_ARG (pattern);
+ ACE_UNUSED_ARG (options);
+ ACE_UNUSED_ARG (errptr);
+ ACE_UNUSED_ARG (erroffset);
+ ACE_UNUSED_ARG (tableptr);
+
+ ACE_NOTSUP_RETURN (0);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::config (int what, void *where)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_config (what, where);
+#else
+ ACE_UNUSED_ARG (what);
+ ACE_UNUSED_ARG (where);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif
+}
+
+ACE_INLINE int
+ACE_Regex::copy_named_substring (const ACE_pcre *code,
+ const char *subject,
+ int *ovector,
+ int stringcount,
+ const char *stringname,
+ char *buffer,
+ int buffersize)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_copy_named_substring (code, subject, ovector, stringcount,
+ stringname, buffer, buffersize);
+#else
+ ACE_UNUSED_ARG (code);
+ ACE_UNUSED_ARG (subject);
+ ACE_UNUSED_ARG (ovector);
+ ACE_UNUSED_ARG (stringcount);
+ ACE_UNUSED_ARG (stringname);
+ ACE_UNUSED_ARG (buffer);
+ ACE_UNUSED_ARG (buffersize);
+
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::copy_substring (const char *subject,
+ int *ovector,
+ int stringcount,
+ int stringnumber,
+ char *buffer,
+ int buffersize)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_copy_substring (subject, ovector, stringcount, stringnumber,
+ buffer, buffersize);
+#else
+ ACE_UNUSED_ARG (subject);
+ ACE_UNUSED_ARG (ovector);
+ ACE_UNUSED_ARG (stringcount);
+ ACE_UNUSED_ARG (stringnumber);
+ ACE_UNUSED_ARG (buffer);
+ ACE_UNUSED_ARG (buffersize);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::exec (const ACE_pcre *code,
+ const ACE_pcre_extra *extra,
+ const char *subject,
+ int length, int startoffset,
+ int options, int *ovector, int ovecsize)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_exec (code, extra, subject, length, startoffset,
+ options, ovector, ovecsize);
+#else
+ ACE_UNUSED_ARG (code);
+ ACE_UNUSED_ARG (extra);
+ ACE_UNUSED_ARG (subject);
+ ACE_UNUSED_ARG (length);
+ ACE_UNUSED_ARG (startoffset);
+ ACE_UNUSED_ARG (options);
+ ACE_UNUSED_ARG (ovector);
+ ACE_UNUSED_ARG (ovecsize);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+
+ACE_INLINE void
+ACE_Regex::free_substring (const char *stringptr)
+{
+#ifdef ACE_HAS_PCRE
+ ::pcre_free_substring (stringptr);
+#else
+ ACE_UNUSED_ARG (stringptr);
+
+ ACE_NOTSUP;
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE void
+ACE_Regex::free_substring_list (const char **stringptr)
+{
+#ifdef ACE_HAS_PCRE
+ ::pcre_free_substring_list (stringptr);
+#else
+ ACE_UNUSED_ARG (stringptr);
+
+ ACE_NOTSUP;
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::fullinfo (const ACE_pcre *code,
+ const ACE_pcre_extra *extra,
+ int what, void *where)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_fullinfo (code, extra, what, where);
+#else
+ ACE_UNUSED_ARG (code);
+ ACE_UNUSED_ARG (extra);
+ ACE_UNUSED_ARG (what);
+ ACE_UNUSED_ARG (where);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::get_named_substring (const ACE_pcre *code,
+ const char *subject,
+ int *ovector, int stringcount,
+ const char *stringname,
+ const char **stringptr)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_get_named_substring (code, subject, ovector, stringcount,
+ stringname, stringptr);
+#else
+ ACE_UNUSED_ARG (code);
+ ACE_UNUSED_ARG (subject);
+ ACE_UNUSED_ARG (ovector);
+ ACE_UNUSED_ARG (stringcount);
+ ACE_UNUSED_ARG (stringname);
+ ACE_UNUSED_ARG (stringptr);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::get_stringnumber (const ACE_pcre *code,
+ const char *name)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_get_stringnumber (code, name);
+#else
+ ACE_UNUSED_ARG (code);
+ ACE_UNUSED_ARG (name);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::get_substring (const char *subject,
+ int *ovector, int stringcount, int stringnumber,
+ const char **stringptr)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_get_substring (subject, ovector, stringcount, stringnumber,
+ stringptr);
+#else
+ ACE_UNUSED_ARG (subject);
+ ACE_UNUSED_ARG (ovector);
+ ACE_UNUSED_ARG (stringcount);
+ ACE_UNUSED_ARG (stringnumber);
+ ACE_UNUSED_ARG (stringptr);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE int
+ACE_Regex::fullinfo (const ACE_pcre *code,
+ int *optptr, int *firstcharptr)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_info (code, optptr, firstcharptr);
+#else
+ ACE_UNUSED_ARG (code);
+ ACE_UNUSED_ARG (optptr);
+ ACE_UNUSED_ARG (firstcharptr);
+
+ ACE_NOTSUP_RETURN (-1);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE const unsigned char *
+ACE_Regex::maketables (void)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_maketables ();
+#else
+ ACE_NOTSUP_RETURN (0);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE ACE_pcre_extra *
+ACE_Regex::study (const ACE_pcre *code,
+ int options,
+ const char **errptr)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_study (code, options, errptr);
+#else
+ ACE_UNUSED_ARG (code);
+ ACE_UNUSED_ARG (options);
+ ACE_UNUSED_ARG (errptr);
+
+ ACE_NOTSUP_RETURN (0);
+#endif /*ACE_HAS_PCRE*/
+}
+
+ACE_INLINE const char *
+ACE_Regex::version (void)
+{
+#ifdef ACE_HAS_PCRE
+ return ::pcre_version ();
+#else
+ ACE_NOTSUP_RETURN (0);
+#endif /*ACE_HAS_PCRE*/
+}