Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #34 from steinwurf/replace-re2-with-std-regex
Browse files Browse the repository at this point in the history
Replace RE2 with std::regex
  • Loading branch information
Jeffail authored Apr 10, 2018
2 parents 02c33e7 + 7df2959 commit b4c9ec5
Show file tree
Hide file tree
Showing 20 changed files with 22 additions and 243 deletions.
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: cpp

os:
- linux

compiler:
- clang

Expand Down Expand Up @@ -33,13 +33,6 @@ before_install:
- cmake --version
- which g++
- g++ -v
- git clone https://github.com/google/re2.git
- cd re2
- git checkout fcdcf25d1a3209355411c57c342e8db115fc9582
- make
- make test
- sudo make install
- sudo make testinstall
- cd ..

script:
Expand Down
12 changes: 3 additions & 9 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ exports_files(["LICENSE.md"])

cc_library(
name = "served",
copts = [
"-Iexternal/com_googlesource_code_re2",
],
copts = [],
srcs = [
"src/served/methods_handler.cpp",
"src/served/multiplexer.cpp",
Expand Down Expand Up @@ -56,17 +54,13 @@ cc_library(
deps = [
"//third_party/boost:system",
"//third_party/boost:asio",
"//third_party/boost:date_time",
"@com_googlesource_code_re2//:re2",
"//third_party/boost:date_time"
],
)

cc_test(
name = "served-test",
copts = [
"-Iexternal/com_googlesource_code_re2",
"-Isrc",
],
copts = ["-Isrc",],
srcs = [
"src/served/methods_handler.test.cpp",
"src/served/multiplexer.test.cpp",
Expand Down
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ LINK_DIRECTORIES (${Boost_LIBRARY_DIRS})
INCLUDE (FindRAGEL)
FIND_PACKAGE (RAGEL)

INCLUDE (FindRE2)
FIND_PACKAGE (RE2 REQUIRED)
INCLUDE_DIRECTORIES (${RE2_INCLUDE_DIR})

FIND_PACKAGE (Threads)

INCLUDE (EnableStdCXX11)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Features:
### Requirements

* [Required] - [Boost 1.56](http://www.boost.org/)
* [Required] - [RE2](http://code.google.com/p/re2/)
* [Optional] - [Ragel](http://www.complang.org/ragel/)

### Building
Expand Down
6 changes: 0 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
workspace(name = "com_github_datasift_served")

git_repository(
name = "com_googlesource_code_re2",
remote = "https://github.com/google/re2.git",
commit = "22fc950c75d238f8b2dcbc43d8a60573cad2b8d7",
)
68 changes: 0 additions & 68 deletions cmake/FindRE2.cmake

This file was deleted.

124 changes: 0 additions & 124 deletions cmake/FindZeroMQ.cmake

This file was deleted.

2 changes: 0 additions & 2 deletions src/examples/handlers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

#include <iostream>

#include <unistd.h>

/* handlers example
*
* This is a demonstration of using various handler mechanisms, including REST parameters with rejex
Expand Down
2 changes: 0 additions & 2 deletions src/examples/list_endpoints/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

#include <iostream>

#include <unistd.h>

/* list_endpoints example
*
* This example demonstrates how to expose a list of registered API endpoints using the
Expand Down
2 changes: 0 additions & 2 deletions src/examples/rest_resource/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

#include <iostream>

#include <unistd.h>

/* rest_resource example
*
* This example demonstrates how you might use served to create REST resources.
Expand Down
4 changes: 2 additions & 2 deletions src/served/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ IF (RAGEL_FOUND)
ENDFOREACH (R_FILE ${served_RL})
ENDIF (RAGEL_FOUND)

#
#
# Locate project sources
#
FILE (GLOB_RECURSE served_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
Expand All @@ -47,7 +47,7 @@ LIST (REMOVE_ITEM served_SRCS ${test_SRCS})
#
# Configure common project settings
#
SET (served_LIBS ${Boost_LIBRARIES} ${RE2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
SET (served_LIBS ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
SET (served_BIN ${PROJECT_NAME})

IF (NOT DEFINED SERVED_BUILD_SHARED)
Expand Down
11 changes: 2 additions & 9 deletions src/served/mux/regex_matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,14 @@ namespace served { namespace mux {
regex_matcher::regex_matcher(const std::string & variable_name, const std::string & regex)
: _variable_name(variable_name)
, _regex(regex)
{
if (!_regex.ok()) {
throw std::runtime_error(_regex.error());
}
}
{ }

// ----- matching logic -----

bool
regex_matcher::check_match(const std::string & path_segment)
{
if (_regex.ok()) {
return (re2::RE2::FullMatch(path_segment, _regex));
}
return false;
return std::regex_match(path_segment, _regex);
}

// ----- REST param collecting -----
Expand Down
5 changes: 2 additions & 3 deletions src/served/mux/regex_matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#define SERVED_PATH_REGEX_MATCHER_HPP

#include <string>

#include <re2/re2.h>
#include <regex>

#include <served/mux/segment_matcher.hpp>

Expand All @@ -39,7 +38,7 @@ namespace served { namespace mux {
class regex_matcher : public segment_matcher
{
const std::string _variable_name;
re2::RE2 _regex;
const std::regex _regex;

public:
/*
Expand Down
1 change: 1 addition & 0 deletions src/served/net/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <utility>
#include <vector>

using namespace served;
using namespace served::net;

connection::connection( boost::asio::io_service & io_service
Expand Down
3 changes: 3 additions & 0 deletions src/served/net/connection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ connection_manager::stop_all() {
}
_connections.clear();
}

connection_manager::~connection_manager()
{}
2 changes: 2 additions & 0 deletions src/served/net/connection_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class connection_manager
* Stops all remaining open connections.
*/
void stop_all();

~connection_manager();
};

} } // net, served
Expand Down
Loading

0 comments on commit b4c9ec5

Please sign in to comment.