mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Add option for choosing between std::regex and pcrecpp
This commit is contained in:
parent
fe9a4c06ad
commit
2703435815
@ -7,6 +7,8 @@ ENDIF()
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
ADD_DEFINITIONS(-Wall -Wextra -Wno-unused-parameter -Wno-unused-result)
|
||||
|
||||
OPTION(USING_STD_REGEX "Use std::regex from C++ library instead of PCRECPP" OFF)
|
||||
|
||||
IF(MACOS)
|
||||
ADD_DEFINITIONS(-D_MACOS)
|
||||
ENDIF()
|
||||
@ -56,10 +58,14 @@ LINK_DIRECTORIES(${YAML_CPP_LIBRARY_DIRS})
|
||||
INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIRS})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${YAML_CPP_LIBRARY})
|
||||
|
||||
FIND_PACKAGE(PCRECPP REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${PCRECPP_INCLUDE_DIRS})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${PCRECPP_LIBRARIES})
|
||||
ADD_DEFINITIONS(-DPCRE_STATIC)
|
||||
IF(USING_STD_REGEX STREQUAL "ON")
|
||||
ADD_DEFINITIONS(-DUSE_STD_REGEX)
|
||||
ELSE()
|
||||
FIND_PACKAGE(PCRECPP REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${PCRECPP_INCLUDE_DIRS})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${PCRECPP_LIBRARIES})
|
||||
ADD_DEFINITIONS(-DPCRE_STATIC)
|
||||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
TARGET_LINK_LIBRARIES(subconverter wsock32 ws2_32)
|
||||
|
||||
11
src/misc.cpp
11
src/misc.cpp
@ -7,7 +7,12 @@
|
||||
//#include <filesystem>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef USE_STD_REGEX
|
||||
#include <regex>
|
||||
#else
|
||||
#include <pcrecpp.h>
|
||||
#endif // USE_STD_REGEX
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
@ -447,7 +452,7 @@ std::string replace_all_distinct(std::string str, std::string old_value, std::st
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
#ifdef USE_STD_REGEX
|
||||
bool regValid(std::string ®)
|
||||
{
|
||||
try
|
||||
@ -501,7 +506,8 @@ bool regMatch(std::string src, std::string match)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#else
|
||||
|
||||
bool regValid(std::string ®)
|
||||
{
|
||||
@ -560,6 +566,7 @@ bool regMatch(std::string src, std::string match)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // USE_STD_REGEX
|
||||
|
||||
std::string speedCalc(double speed)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user