Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
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"
)
22 changes: 3 additions & 19 deletions include/matcher/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,6 @@
}
};

/**
* @brief Simulation state for tagged NFA traversal
* Bundles all state needed during matching
*/
template <typename RegexData>
struct SimulationState {
std::vector<RegexData> active_paths; // Currently active regex paths
std::map<RegexData, CaptureSlots> 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
*
Expand Down Expand Up @@ -473,12 +457,12 @@
};
} // namespace

#include <matcher/impl/subtree.cpp>
#include <matcher/impl/node.cpp>
#include <matcher/impl/subtree.ipp>
#include <matcher/impl/node.ipp>

namespace matcher {
template <typename RegexData, typename char_t>
class RegexMatcher {

Check warning on line 465 in include/matcher/core.hpp

View workflow job for this annotation

GitHub Actions / gather_annotations

‘matcher::RegexMatcher<int, char>’ has a field ‘matcher::RegexMatcher<int, char>::root’ whose type uses the anonymous namespace [-Wsubobject-linkage]
Node<RegexData, char_t> root;

template <typename ConstIterator>
Expand Down Expand Up @@ -538,4 +522,4 @@
};
} // namespace matcher

#include <matcher/impl/core.cpp>
#include <matcher/impl/core.ipp>
11 changes: 5 additions & 6 deletions include/matcher/impl/core.cpp → include/matcher/impl/core.ipp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef CORE_IMPL
#define CORE_IMPL

#include <matcher/core.hpp>
/**
* @file core.ipp
* @brief Template implementation for RegexMatcher class
* @note This file is included by core.hpp - do not include directly
*/

#include <list>

Expand Down Expand Up @@ -250,5 +251,3 @@ namespace matcher {
}

} // namespace matcher

#endif
12 changes: 6 additions & 6 deletions include/matcher/impl/node.cpp → include/matcher/impl/node.ipp
Original file line number Diff line number Diff line change
@@ -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 <matcher/core.hpp>
#include <stack>

namespace {
Expand Down Expand Up @@ -454,6 +456,4 @@ namespace {
print_helper(0, traversed, nodes);
}
#endif
} // namespace

#endif
} // anonymous namespace
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ifndef SUBTREE_IMPL
#define SUBTREE_IMPL

#include <matcher/core.hpp>
/**
* @file subtree.ipp
* @brief Template implementation for SubTree class
* @note This file is included by core.hpp - do not include directly
*/

namespace {

template <typename Node_T>
inline const std::vector<Node_T*>& SubTree<Node_T>::get_roots() const {
return roots;
Expand All @@ -13,6 +15,5 @@ namespace {
inline const std::vector<Node_T*>& SubTree<Node_T>::get_leafs() const {
return leafs;
}
} // namespace

#endif
} // anonymous namespace
Loading