Merge pull request #2 from NerdyProjects/boost_regex

Use boost::regex instead of std::regex
This commit is contained in:
Michał Słomkowski 2015-11-23 20:27:31 +01:00
commit 9d654eb518
3 changed files with 9 additions and 9 deletions

View File

@ -4,7 +4,7 @@ project(mumsi)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
INCLUDE(FindPkgConfig) INCLUDE(FindPkgConfig)
find_package(Boost COMPONENTS system REQUIRED) find_package(Boost COMPONENTS system regex REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(PJSIP "libpjproject") pkg_check_modules(PJSIP "libpjproject")

View File

@ -13,16 +13,16 @@ sip::IncomingConnectionValidator::IncomingConnectionValidator(std::string validU
for (auto &uri : separateUris) { for (auto &uri : separateUris) {
boost::replace_all(uri, ".", "\\."); boost::replace_all(uri, ".", "\\.");
boost::replace_all(uri, "*", "\\w*"); boost::replace_all(uri, "*", "\\w*");
uriRegexVec.push_back(regex(uri)); uriRegexVec.push_back(boost::regex(uri));
} }
} }
bool sip::IncomingConnectionValidator::validateUri(std::string uri) { bool sip::IncomingConnectionValidator::validateUri(std::string uri) {
regex addressRegex("[\"\\w ]*<sip:([\\w\\.]+@[\\w\\.]+)>"); boost::regex addressRegex("[\"\\w ]*<sip:([\\w\\.]+@[\\w\\.]+)>");
smatch s; boost::smatch s;
if (not regex_match(uri, s, addressRegex)) { if (not boost::regex_match(uri, s, addressRegex)) {
logger.warn("URI has invalid format: %s", uri.c_str()); logger.warn("URI has invalid format: %s", uri.c_str());
return false; return false;
} }
@ -30,7 +30,7 @@ bool sip::IncomingConnectionValidator::validateUri(std::string uri) {
string rawAddress = s[1].str(); string rawAddress = s[1].str();
for (auto &reg : uriRegexVec) { for (auto &reg : uriRegexVec) {
if (regex_match(rawAddress, s, reg)) { if (boost::regex_match(rawAddress, s, reg)) {
logger.info("URI %s is valid.", rawAddress.c_str()); logger.info("URI %s is valid.", rawAddress.c_str());
return true; return true;
} }

View File

@ -4,7 +4,7 @@
#include <log4cpp/Category.hh> #include <log4cpp/Category.hh>
#include <string> #include <string>
#include <regex> #include <boost/regex.hpp>
namespace sip { namespace sip {
class IncomingConnectionValidator : boost::noncopyable { class IncomingConnectionValidator : boost::noncopyable {
@ -16,6 +16,6 @@ namespace sip {
private: private:
log4cpp::Category &logger; log4cpp::Category &logger;
std::string validUriExpression; std::string validUriExpression;
std::vector<std::regex> uriRegexVec; std::vector<boost::regex> uriRegexVec;
}; };
} }