Skip to content

Header only c++20 constexpr pattern matching library

License

Notifications You must be signed in to change notification settings

notscuffed/nspattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nspattern

Header only c++20 constexpr pattern matching library.

Usage:

void test()
{
    // data can be array or any contiguous container that implements .data() & .size()
    const unsigned char data[] = { 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x00 };

    // non static pattern will be inlined as instructions loading the pattern on stack
    // add static keyword or initialize outside method to put it on .rdata section
    constexpr auto pattern = COMPILE_PATTERN("01 02 ?? 04");

    auto offset = ns::find_pattern(pattern, data);
    if (offset != ns::no_match)
        printf("pattern found at index: %zi\n", offset);
    else
        puts("pattern not found");
}

About

Header only c++20 constexpr pattern matching library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published