Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.
/ kms-core Public archive

Commit

Permalink
UriEndpointImpl: Use std regex instead of boost if possible
Browse files Browse the repository at this point in the history
Change-Id: Iaec53be099d26fe1d678f60f15943691829b20ae
  • Loading branch information
jcaden committed Sep 29, 2016
1 parent c31ad02 commit 8bf52ba
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
33 changes: 29 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,35 @@ set (GLIBMM_REQUIRED ^2.37)

include (GenericFind)

generic_find (LIBNAME Boost REQUIRED COMPONENTS filesystem system unit_test_framework regex)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -DHAVE_CONFIG_H -Werror -Wall -Werror=declaration-after-statement -Wno-deprecated-declarations -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DHAVE_CONFIG_H -Wall -Werror -std=c++11 -O2")

include (CheckCXXSourceCompiles)

set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})

check_cxx_source_compiles (
"#include <regex>
#include <iostream>
int main () {
std::regex re (\"//*\");
std::string orig = \"//\";
std::cout << std::regex_replace (orig, re, \"/\") << std::endl;
return 0;
}
"
REGEX_REPLACE_EXISTS
)

if (${REGEX_REPLACE_EXISTS})
set (BOOST_REQUIRED_COMPONENTS "filesystem system")
generic_find (LIBNAME Boost REQUIRED COMPONENTS filesystem system unit_test_framework)
else()
set (BOOST_REQUIRED_COMPONENTS "filesystem system regex")
generic_find (LIBNAME Boost REQUIRED COMPONENTS filesystem system regex unit_test_framework)
endif()

#gst-plugins dependencies
generic_find (LIBNAME gstreamer-1.5 VERSION ${GST_REQUIRED} REQUIRED)
Expand Down Expand Up @@ -56,9 +84,6 @@ set (CMAKE_INSTALL_GST_PLUGINS_DIR ${CMAKE_INSTALL_LIBDIR}/gstreamer-1.5)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -DHAVE_CONFIG_H -Werror -Wall -Werror=declaration-after-statement -Wno-deprecated-declarations -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DHAVE_CONFIG_H -Wall -Werror -std=c++11 -O2")

include(CheckCXXCompilerFlag)

CHECK_CXX_COMPILER_FLAG("-Wno-error=date-time" COMPILER_SUPPORTS_DATETIME_ERROR)
Expand Down
2 changes: 2 additions & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
/* Library installation directory */
#cmakedefine KURENTO_MODULES_DIR "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/@KURENTO_MODULES_DIR_INSTALL_PREFIX@"

#cmakedefine REGEX_REPLACE_EXISTS @REGEX_REPLACE_EXISTS@

#endif /* __GST_KURENTO_CORE_CONFIG_H__ */
2 changes: 1 addition & 1 deletion src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ generate_code (
"KmsJsonRpc ${JSON_RPC_REQUIRED}"
"sigc++-2.0 ${sigc++-2.0_REQUIRED}"
"glibmm-2.4 ${glibmm-2.4_REQUIRED}"
"LIBNAME Boost COMPONENTS filesystem system regex"
"LIBNAME Boost COMPONENTS ${BOOST_REQUIRED_COMPONENTS}"
)

if (NOT ${DISABLE_LIBRARIES_GENERATION})
Expand Down
19 changes: 15 additions & 4 deletions src/server/implementation/objects/UriEndpointImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@
* limitations under the License.
*
*/

#include <config.h>

#include <gst/gst.h>
#include "UriEndpointImpl.hpp"
#include <jsonrpc/JsonSerializer.hpp>
#include <KurentoException.hpp>
#include <gst/gst.h>
#if REGEX_REPLACE_EXISTS
#include <regex>
using std::regex;
using std::regex_replace;
#else
#include <boost/regex.hpp>
using boost::regex;
using boost::regex_replace;
#endif
#include "kmsuriendpointstate.h"
#include <SignalHandler.hpp>

Expand All @@ -35,7 +46,7 @@ namespace kurento

void UriEndpointImpl::removeDuplicateSlashes (std::string &uri)
{
boost::regex re ("//*");
regex re ("//*");
gchar *location, *protocol;

location = gst_uri_get_location (uri.c_str () );
Expand All @@ -53,7 +64,7 @@ void UriEndpointImpl::removeDuplicateSlashes (std::string &uri)
uriWithoutProtocol.erase (0, 1);
}

std::string uriWithoutSlash (boost::regex_replace (uriWithoutProtocol, re,
std::string uriWithoutSlash (regex_replace (uriWithoutProtocol, re,
"/") );

if (uriProtocol == "file") {
Expand All @@ -65,8 +76,8 @@ void UriEndpointImpl::removeDuplicateSlashes (std::string &uri)

void UriEndpointImpl::checkUri ()
{
boost::regex re ("%2F");
this->uri = (boost::regex_replace (uri, re, "/") );
regex re ("%2F");
this->uri = (regex_replace (uri, re, "/") );
this->absolute_uri = this->uri;

//Check if uri is an absolute or relative path.
Expand Down

0 comments on commit 8bf52ba

Please sign in to comment.