diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index aca8685..987fe41 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,24 +1,36 @@ -# Library sources -file(GLOB_RECURSE LIB_HDRS "${CMAKE_CURRENT_SOURCE_DIR}/matcher/*.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/matcher/*.h") -file(GLOB_RECURSE LIB_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/matcher/impl/*.cpp") +# Library headers +# .hpp = public headers, .ipp = template implementation (included by .hpp) +file(GLOB_RECURSE LIB_HDRS + "${CMAKE_CURRENT_SOURCE_DIR}/matcher/*.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/matcher/*.h" + "${CMAKE_CURRENT_SOURCE_DIR}/matcher/impl/*.ipp" +) # Config header -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/RegexMatcherConfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/matcher/RegexMatcherConfig.h) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/RegexMatcherConfig.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/matcher/RegexMatcherConfig.h +) -# Core library -add_library(RegexMatcher STATIC ${LIB_SRCS}) -target_sources(RegexMatcher PUBLIC FILE_SET regex_matcher_headers TYPE HEADERS FILES ${LIB_HDRS}) +# Header-only library (INTERFACE since all code is in headers/ipp files) +add_library(RegexMatcher INTERFACE) +target_sources(RegexMatcher INTERFACE FILE_SET regex_matcher_headers TYPE HEADERS FILES ${LIB_HDRS}) target_include_directories( RegexMatcher - PUBLIC + INTERFACE $ $ ) -set_target_properties(RegexMatcher PROPERTIES LINKER_LANGUAGE CXX) # Set output properties set_target_properties(RegexMatcher PROPERTIES EXPORT_NAME core) -install(FILES ${LIB_SRCS} - DESTINATION lib/RegexMatcher-${PROJECT_VERSION}/matcher/impl +# Install headers +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/matcher + DESTINATION include + FILES_MATCHING + PATTERN "*.hpp" + PATTERN "*.h" + PATTERN "*.ipp" ) diff --git a/include/matcher/core.hpp b/include/matcher/core.hpp index b6ca72d..9eb7a6c 100644 --- a/include/matcher/core.hpp +++ b/include/matcher/core.hpp @@ -136,22 +136,6 @@ namespace { } }; - /** - * @brief Simulation state for tagged NFA traversal - * Bundles all state needed during matching - */ - template - struct SimulationState { - std::vector active_paths; // Currently active regex paths - std::map captures; // Capture slots per regex - - SimulationState() = default; - SimulationState(const SimulationState&) = default; - SimulationState& operator=(const SimulationState&) = default; - SimulationState(SimulationState&&) = default; - SimulationState& operator=(SimulationState&&) = default; - }; - /** * @brief Class containing the list of regexes using the given edge * @@ -473,8 +457,8 @@ namespace { }; } // namespace -#include -#include +#include +#include namespace matcher { template @@ -538,4 +522,4 @@ namespace matcher { }; } // namespace matcher -#include +#include diff --git a/include/matcher/impl/core.cpp b/include/matcher/impl/core.ipp similarity index 98% rename from include/matcher/impl/core.cpp rename to include/matcher/impl/core.ipp index e93678c..d5e8f1a 100644 --- a/include/matcher/impl/core.cpp +++ b/include/matcher/impl/core.ipp @@ -1,7 +1,8 @@ -#ifndef CORE_IMPL -#define CORE_IMPL - -#include +/** + * @file core.ipp + * @brief Template implementation for RegexMatcher class + * @note This file is included by core.hpp - do not include directly + */ #include @@ -250,5 +251,3 @@ namespace matcher { } } // namespace matcher - -#endif diff --git a/include/matcher/impl/node.cpp b/include/matcher/impl/node.ipp similarity index 98% rename from include/matcher/impl/node.cpp rename to include/matcher/impl/node.ipp index 5d64a48..cb2650b 100644 --- a/include/matcher/impl/node.cpp +++ b/include/matcher/impl/node.ipp @@ -1,7 +1,9 @@ -#ifndef NODE_IMPL -#define NODE_IMPL +/** + * @file node.ipp + * @brief Template implementation for Node class + * @note This file is included by core.hpp - do not include directly + */ -#include #include namespace { @@ -454,6 +456,4 @@ namespace { print_helper(0, traversed, nodes); } #endif -} // namespace - -#endif +} // anonymous namespace diff --git a/include/matcher/impl/subtree.cpp b/include/matcher/impl/subtree.ipp similarity index 59% rename from include/matcher/impl/subtree.cpp rename to include/matcher/impl/subtree.ipp index 32897d5..b260e99 100644 --- a/include/matcher/impl/subtree.cpp +++ b/include/matcher/impl/subtree.ipp @@ -1,9 +1,11 @@ -#ifndef SUBTREE_IMPL -#define SUBTREE_IMPL - -#include +/** + * @file subtree.ipp + * @brief Template implementation for SubTree class + * @note This file is included by core.hpp - do not include directly + */ namespace { + template inline const std::vector& SubTree::get_roots() const { return roots; @@ -13,6 +15,5 @@ namespace { inline const std::vector& SubTree::get_leafs() const { return leafs; } -} // namespace -#endif +} // anonymous namespace