Types
Database = ref DatabaseObj
ExpressionInfo = object minWidth*, maxWidth*: cuint unorderedMatches*: bool matchesAtEod*: bool matchesOnlyAtEod*: bool
HsException = object of CatchableError code*: HsError
MatchCallback = proc (id: cuint; fromOffset, toOffset: culonglong): bool
- Return false to terminate scanning early
Pattern = object expr*: string flags*: cuint id*: cuint
Scratch = ref ScratchObj
Stream = ref StreamObj
Procs
proc close(stream: Stream; cb: MatchCallback = nil) {....raises: [HsException], tags: [], forbids: [].}
- Closes the stream and flushes any pending matches.
proc compileLit(pattern: string; flags: cuint = 0; mode: cuint = HS_MODE_BLOCK): Database {. ...raises: [HsException], tags: [], forbids: [].}
- Compile a literal (non-regex) pattern into a Database.
proc deserialize(data: openArray[byte]): Database {....raises: [HsException], tags: [], forbids: [].}
- Deserializes a database from a byte sequence.
proc expressionInfo(pattern: string; flags: cuint = 0): ExpressionInfo {. ...raises: [HsException], tags: [], forbids: [].}
- Returns width and match property info for a pattern without compiling.
proc newScratch(db: Database): Scratch {....raises: [HsException], tags: [], forbids: [].}
- Allocates a scratch space for the given database.
proc openStream(db: Database; scratch: Scratch): Stream {....raises: [HsException], tags: [], forbids: [].}
- Opens a streaming scan session.
proc reset(stream: Stream; cb: MatchCallback = nil) {....raises: [HsException], tags: [], forbids: [].}
- Resets a stream without closing it.
proc scan(db: Database; data: string; cb: MatchCallback): bool {. ...raises: [HsException], tags: [], forbids: [].}
- Convenience overload — allocates a temporary scratch space.
proc scan(db: Database; data: string; scratch: Scratch; cb: MatchCallback): bool {. ...raises: [HsException], tags: [], forbids: [].}
- Scans data in block mode. Returns true if scanning completed, false if the callback requested early termination.
proc scan(stream: Stream; data: string; cb: MatchCallback): bool {. ...raises: [HsException], tags: [], forbids: [].}
- Pushes data into the stream. Returns false on early termination.
proc validPlatform() {....raises: [HsException], tags: [], forbids: [].}
- Raises HsException if the current CPU is unsupported.
proc version(): string {....raises: [], tags: [], forbids: [].}
- Returns the Hyperscan library version string.
Exports
-
HS_TUNE_FAMILY_GENERIC, hs_set_database_allocator, HS_ARCH_ERROR, hs_reset_and_expand_stream, hs_stream_size, hs_set_allocator, HsExprInfo, hs_open_stream, HS_TUNE_FAMILY_GLM, HS_INVALID, HsScratchPtr, HsDatabasePtr, HS_EXT_FLAG_MIN_LENGTH, HS_FLAG_QUIET, HsCompileError, hs_free_database, HS_TUNE_FAMILY_HSW, HsStream, HS_DB_MODE_ERROR, hs_set_stream_allocator, HS_TUNE_FAMILY_SLM, hs_expression_ext_info, HS_MODE_SOM_HORIZON_SMALL, HS_EXT_FLAG_MAX_OFFSET, hs_serialized_database_info, HsStreamPtr, HS_CPU_FEATURES_AVX512VBMI, hs_scan_stream, MatchEventHandler, hs_database_info, HsExprInfoPtr, hs_compress_stream, HS_BAD_ALLOC, HS_MODE_STREAM, HsDatabase, hs_compile_ext_multi, HS_EXT_FLAG_HAMMING_DISTANCE, HS_TUNE_FAMILY_ICX, hs_close_stream, HS_DB_VERSION_ERROR, HS_FLAG_SOM_LEFTMOST, hs_deserialize_database_at, HS_FLAG_PREFILTER, hs_set_scratch_allocator, HS_TUNE_FAMILY_IVB, HS_MODE_SOM_HORIZON_MEDIUM, hs_reset_stream, HsPlatformInfo, HsExprExt, HS_CPU_FEATURES_AVX512, HS_UNKNOWN_ERROR, HS_TUNE_FAMILY_SKX, HS_FLAG_DOTALL, HsCompileErrorPtr, HS_FLAG_MULTILINE, hs_compile_lit, hs_free_scratch, HsPlatformInfoPtr, HS_BAD_ALIGN, hs_expression_info, hs_serialize_database, hs_populate_platform, hs_compile_multi, hs_copy_stream, HS_EXT_FLAG_MIN_OFFSET, HS_FLAG_SINGLEMATCH, HsFreeFunc, HS_SCRATCH_IN_USE, hs_scan, hs_scan_vector, hs_deserialize_database, HS_TUNE_FAMILY_BDW, hs_set_misc_allocator, HS_TUNE_FAMILY_SNB, hs_scratch_size, HS_OFFSET_PAST_HORIZON, hs_free_compile_error, HsError, HS_INSUFFICIENT_SPACE, HsScratch, HS_TUNE_FAMILY_SKL, hs_alloc_scratch, HS_MODE_BLOCK, HS_DB_PLATFORM_ERROR, HS_NOMEM, HsAllocFunc, HS_FLAG_ALLOWEMPTY, hs_compile, HS_FLAG_UCP, HS_MODE_VECTORED, hs_valid_platform, HS_COMPILER_ERROR, HS_EXT_FLAG_EDIT_DISTANCE, HS_SCAN_TERMINATED, HS_SUCCESS, HS_MODE_SOM_HORIZON_LARGE, HS_FLAG_CASELESS, hs_database_size, hs_serialized_database_size, HsExprExtPtr, hs_clone_scratch, hs_version, hs_expand_stream, HS_FLAG_UTF8, HS_MODE_NOSTREAM, hs_compile_lit_multi, HS_FLAG_COMBINATION, HS_TUNE_FAMILY_ICL, HS_CPU_FEATURES_AVX2, hs_reset_and_copy_stream