pdftract/swift-sdk/Sources/Pdftract/Models/Match.swift
jedarden 8b9a7bc91a docs(pdftract-5lvpu): verify Swift SDK implementation for v1.1+ release
Bead pdftract-5lvpu implements the Swift SDK for pdftract as a
subprocess-based SDK using Foundation's Process with async/await.
Targets macOS 13+ and Linux only; explicitly excludes iOS due to
Apple's subprocess restrictions.

Acceptance criteria status:
- PASS: SPM package structure (Package.swift configured)
- PASS: All 9 contract methods exposed in Methods.swift
- PASS: All 8 error cases defined in Error.swift
- PASS: iOS documented as unsupported in README.md
- PASS: CI workflow configured (pdftract-swift-publish.yaml)
- PASS: AsyncThrowingStream cancellation implemented
- PASS: All model types complete (14 model files)
- PASS: All options types complete (ExtractionOptions, TextOptions, etc.)
- PASS: Conformance test suite defined (ConformanceTests.swift)
- PASS: Cross-platform Process support (ProcessRunner actor)

Files updated:
- swift-sdk/README.md: Fixed GitHub URL from placeholder to jedarden/pdftract-swift

Verification note: notes/pdftract-5lvpu.md

References:
- Plan: SDK Architecture / The Ten SDKs, line 3480
- Plan: SDK Architecture / Per-SDK Release Channels, line 3577
- Plan: SDK Acceptance Criteria, lines 3581-3589
- ADR-009: Argo Workflows on iad-ci only
2026-06-01 13:40:03 -04:00

77 lines
1.9 KiB
Swift

//
// Match.swift
// Pdftract
//
// Search match result from the grep command.
//
import Foundation
/// A single search match result.
///
/// Represents one occurrence of the search pattern in the PDF.
public struct Match: Codable, Equatable {
/// Page index where the match was found.
public let pageIndex: UInt
/// Span index within the page.
public let spanIndex: UInt
/// The matched text content.
public let text: String
/// Bounding box of the match [x0, y0, x1, y1] in PDF user-space points.
public let bbox: [Double]
/// Coding keys for custom serialization
enum CodingKeys: String, CodingKey {
case pageIndex = "page_index"
case spanIndex = "span_index"
case text
case bbox
}
/// Create a new Match structure.
public init(
pageIndex: UInt,
spanIndex: UInt,
text: String,
bbox: [Double]
) {
self.pageIndex = pageIndex
self.spanIndex = spanIndex
self.text = text
self.bbox = bbox
}
}
/// Options for search operations.
public struct SearchOptions: Codable, Equatable {
/// Case-insensitive search.
public let caseInsensitive: Bool
/// Whole word search (pattern must match complete words).
public let wholeWord: Bool
/// Regex search (pattern is a regular expression).
public let regex: Bool
/// Maximum number of matches to return (0 = unlimited).
public let maxMatches: UInt
/// Create default search options.
public init(
caseInsensitive: Bool = false,
wholeWord: Bool = false,
regex: Bool = false,
maxMatches: UInt = 0
) {
self.caseInsensitive = caseInsensitive
self.wholeWord = wholeWord
self.regex = regex
self.maxMatches = maxMatches
}
/// Default search options.
public static let `default` = SearchOptions()
}