Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-10-31 18:14:04 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:46:29 +0300
commit93f9610292ef0baadb7afd58465112c5d7968665 (patch)
tree7d73e3586163e880e486149571193918a326e07e /base
parent65dd7e4f2bee7f55c52c02e8d5e6e2175ae9cd4b (diff)
Fix calling convention of Platform::GetFilesByExt.
Diffstat (limited to 'base')
-rw-r--r--base/base.pro1
-rw-r--r--base/base_tests/base_tests.pro1
-rw-r--r--base/base_tests/regexp_test.cpp22
-rw-r--r--base/regexp.hpp18
4 files changed, 42 insertions, 0 deletions
diff --git a/base/base.pro b/base/base.pro
index f7ce1aa03f..06587971b3 100644
--- a/base/base.pro
+++ b/base/base.pro
@@ -79,3 +79,4 @@ HEADERS += \
strings_bundle.hpp \
string_format.hpp \
object_tracker.hpp \
+ regexp.hpp
diff --git a/base/base_tests/base_tests.pro b/base/base_tests/base_tests.pro
index 021127f81c..0cb91f591d 100644
--- a/base/base_tests/base_tests.pro
+++ b/base/base_tests/base_tests.pro
@@ -35,6 +35,7 @@ SOURCES += \
containers_test.cpp \
fence_manager_test.cpp \
string_format_test.cpp \
+ regexp_test.cpp
HEADERS +=
diff --git a/base/base_tests/regexp_test.cpp b/base/base_tests/regexp_test.cpp
new file mode 100644
index 0000000000..7e0e0dea35
--- /dev/null
+++ b/base/base_tests/regexp_test.cpp
@@ -0,0 +1,22 @@
+#include "../../testing/testing.hpp"
+
+#include "../regexp.hpp"
+
+
+UNIT_TEST(RegExp_Or)
+{
+ regexp::RegExpT exp;
+ regexp::Create("\\.mwm\\.(downloading2?$|resume2?$)", exp);
+
+ TEST(regexp::IsExist("Aruba.mwm.downloading", exp), ());
+ TEST(!regexp::IsExist("Aruba.mwm.downloading1", exp), ());
+ TEST(regexp::IsExist("Aruba.mwm.downloading2", exp), ());
+ TEST(!regexp::IsExist("Aruba.mwm.downloading3", exp), ());
+ TEST(!regexp::IsExist("Aruba.mwm.downloading.tmp", exp), ());
+
+ TEST(regexp::IsExist("Aruba.mwm.resume", exp), ());
+ TEST(!regexp::IsExist("Aruba.mwm.resume1", exp), ());
+ TEST(regexp::IsExist("Aruba.mwm.resume2", exp), ());
+ TEST(!regexp::IsExist("Aruba.mwm.resume3", exp), ());
+ TEST(!regexp::IsExist("Aruba.mwm.resume.tmp", exp), ());
+}
diff --git a/base/regexp.hpp b/base/regexp.hpp
new file mode 100644
index 0000000000..171c365684
--- /dev/null
+++ b/base/regexp.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <boost/xpressive/xpressive.hpp>
+
+namespace regexp
+{
+ typedef boost::xpressive::sregex RegExpT;
+
+ inline void Create(string const & regexp, RegExpT & out)
+ {
+ out = RegExpT::compile(regexp);
+ }
+
+ inline bool IsExist(string const & str, RegExpT const & regexp)
+ {
+ return boost::xpressive::regex_search(str, regexp);
+ }
+}