[gnote] sharp::string_* use PCRE now



commit b6688f9468939e5d2c98c279236286b38e41ceca
Author: Hubert Figuiere <hub figuiere net>
Date:   Fri Jun 5 23:22:51 2009 -0400

    sharp::string_* use PCRE now
---
 src/Makefile.am          |    8 ++++----
 src/sharp/string.cpp     |   16 ++++++++++------
 src/sharp/xmlconvert.cpp |    1 -
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 1dd9ba7..573cb84 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,15 +32,15 @@ TESTS = trietest stringtest notetest dttest uritest filestest \
 
 trietest_SOURCES = test/trietest.cpp \
 	sharp/string.cpp debug.cpp
-trietest_LDADD =  @BOOST_REGEX_LIBS@ @LIBGLIBMM_LIBS@
+trietest_LDADD =  @PCRE_LIBS@ @LIBGLIBMM_LIBS@
 
 dttest_SOURCES = test/dttest.cpp \
 	sharp/datetime.cpp debug.cpp
-dttest_LDADD = @LIBGLIBMM_LIBS@ @BOOST_REGEX_LIBS@
+dttest_LDADD = @LIBGLIBMM_LIBS@
 
 stringtest_SOURCES = test/stringtest.cpp \
 	sharp/string.cpp debug.cpp
-stringtest_LDADD =  @BOOST_REGEX_LIBS@ @LIBGLIBMM_LIBS@
+stringtest_LDADD =  @PCRE_LIBS@ @LIBGLIBMM_LIBS@
 
 filestest_SOURCES = test/filestest.cpp \
 	sharp/files.cpp
@@ -48,7 +48,7 @@ filestest_LDADD = @BOOST_FILESYSTEM_LIBS@
 
 uritest_SOURCES = test/uritest.cpp \
 	sharp/string.cpp  sharp/uri.cpp debug.cpp
-uritest_LDADD =  @BOOST_REGEX_LIBS@ @LIBGLIBMM_LIBS@
+uritest_LDADD =  @PCRE_LIBS@ @LIBGLIBMM_LIBS@
 
 xmlreadertest_SOURCES = test/xmlreadertest.cpp \
 	sharp/xmlreader.cpp debug.cpp
diff --git a/src/sharp/string.cpp b/src/sharp/string.cpp
index 784d9cc..ab845b2 100644
--- a/src/sharp/string.cpp
+++ b/src/sharp/string.cpp
@@ -31,11 +31,12 @@
 #include <boost/algorithm/string/case_conv.hpp>
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/predicate.hpp>
-#include <boost/algorithm/string/regex.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/trim.hpp>
 
+#include <pcrecpp.h>
+
 #include "debug.hpp"
 
 namespace sharp {
@@ -53,17 +54,20 @@ namespace sharp {
     return boost::replace_all_copy(source, from, with);
   }
 
-  std::string string_replace_regex(const std::string & source, const std::string & regex,
+  std::string string_replace_regex(const std::string & source,
+                                   const std::string & regex,
                                    const std::string & with)
   {
-    return boost::replace_regex_copy(source, boost::regex(regex), with);
+    pcrecpp::RE re(regex);
+    std::string result = source;
+    re.Replace(with, &result);
+    return result;
   }
   
   bool string_match_iregex(const std::string & source, const std::string & regex)  
   {
-    return boost::regex_match(source, 
-                              boost::regex(regex, boost::regex::perl 
-                                           | boost::regex::icase));
+    pcrecpp::RE re(regex, pcrecpp::RE_Options(PCRE_CASELESS|PCRE_UTF8));
+    return re.FullMatch(source);
   }
 
   void string_split(std::vector<std::string> & split, const std::string & source,
diff --git a/src/sharp/xmlconvert.cpp b/src/sharp/xmlconvert.cpp
index cddd77d..bbad047 100644
--- a/src/sharp/xmlconvert.cpp
+++ b/src/sharp/xmlconvert.cpp
@@ -25,7 +25,6 @@
 
 
 #include <string>
-#include <boost/regex.hpp>
 
 #include "sharp/xmlconvert.hpp"
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]