//
//  LKFFilterGroup.swift
//  lkfc
//
//  Created by Alexander Holzer on 20.04.25.
//  Copyright © 2025 Alexander Holzer. All rights reserved.
//

import Foundation

public class LKFFilterGroup : LKFFilter {
    let group: String
    let groupChar: [CChar]
    let groupCharLength: UInt32
    
    public init? (context: LKFContext, group: String) {
        let group = group.trimmingCharacters(in: .whitespaces)
        guard let groupChar = group.cString(using: .utf8) else {
            return nil
        }
        self.group = group
        self.groupChar = groupChar
        self.groupCharLength = UInt32(group.count)
    }
    
    public override func isIncluded(contact: LKFAufenthalt) -> Bool {
        return contact.matches(group: groupChar, len: groupCharLength)
    }
}
