VIPA - Vectorized IP Address Parser
VIPA is a small, header-only C++23 library for SIMD-assisted IPv4/IPv6 text parsing. It exposes allocation-free parser functions under the llmx::vipa namespace and ships as an installable CMake interface target.
Features
- Header-only C++23 library
- Strict IPv4 dotted-decimal parser
- IPv6 parser with compressed forms and IPv4-embedded tails
- AVX2-assisted parser scans with portable scalar fallbacks
- Portable scalar fallback for other targets
- GoogleTest-based parser tests
AVX2 compile options are enabled by default through the llmx::vipa CMake target. Configure with -DVIPA_ENABLE_AVX2=OFF to force the scalar fallback.
Using VIPA from CMake
Via add_subdirectory
add_subdirectory(path/to/vipa)
target_link_libraries(my_app PRIVATE llmx::vipa)
Via FetchContent
include(FetchContent)
FetchContent_Declare(vipa
GIT_REPOSITORY https://github.com/llmxio/vipa.git
GIT_TAG vX.Y.Z
)
FetchContent_MakeAvailable(vipa)
target_link_libraries(my_app PRIVATE llmx::vipa)
Installed packages can be consumed with:
find_package(VIPA CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE llmx::vipa)
Build And Test
cmake -G Ninja -B build -S . -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON
cmake --build build
ctest --test-dir build -V
Build And Benchmark
cmake -G Ninja -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_BENCHMARKS=ON
cmake --build build --target vipa_ipv4_benchmarks vipa_ipv6_benchmarks
./build/benchmarks/vipa_ipv4_benchmarks
./build/benchmarks/vipa_ipv6_benchmarks
Usage
}
auto parse_address(std::string_view text) noexcept -> std::optional< ParseResult >
Parse an IPv4 or IPv6 text address.
Definition parser.hxx:21
@ IPv6
Definition address.hxx:11
Credits
This project is inspired by the work of Daniel Lemire and related tooling from https://github.com/lemire.
Documentation
Build the HTML API docs using Doxygen:
cmake -S . -B build -DBUILD_DOCS=ON
cmake --build build --target docs
HTML output is written to build/docs/html.