/** * The ten fixed header fields. * * Layer 2. Sole owner of the 256-byte fixed header: where each field lives, what its bytes say * verbatim, and which diagnostic a field that fails its grammar deserves. It owns no ORDER — * `header/parse.ts` decides that and calls the functions here one field at a time, because the * fixed header has to be read in dependency order rather than in file order (the signal count * has to be trusted before the header-size field is worth reading at all). * * Raw first, always: a numeric field that failed to parse is exactly the case where the caller * needs the bytes as written, so every field is exposed as text before it is interpreted. */ import { type EdfNumberParse } from '../bytes/numbers.js'; import { HEADER_FIELDS } from '../constants.js'; import { type DiagnosticSink } from '../diagnostics/collector.js'; import type { EdfRawHeaderFields } from '../types.js'; /** The ten fixed fields. Same keys as `EdfRawHeaderFields`, by construction. */ export type FixedHeaderFieldName = keyof typeof HEADER_FIELDS; /** `'EDF specification, header record bytes 236-243'`. */ export declare function fixedFieldSpecReference(field: FixedHeaderFieldName): string; /** `'number of data records (8 bytes at offset 236)'`. */ export declare function describeFixedField(field: FixedHeaderFieldName): string; /** Every fixed field as the text it holds, padding included and nothing interpreted. */ export declare function readRawHeaderFields(headerBytes: Uint8Array): EdfRawHeaderFields; /** * Report `NON_ASCII_HEADER_FIELD` for every fixed text field carrying a byte outside ASCII * 32..126. * * A warning, never more: the field still decodes truthfully, because edfcore reads header text * as ISO-8859-1 — real equipment writes accented patient names and a bare 0xB5 for micro. */ export declare function reportNonAsciiHeaderFields(headerBytes: Uint8Array, sink: DiagnosticSink): void; /** * Everything a numeric-field diagnostic needs that the parse result does not carry. * * Per-signal fields use this too — `header/signals.ts` supplies its own offsets and wording, so * the comma/malformed/justification decision exists in exactly one place. */ export interface NumericFieldContext { /** Goes on the diagnostic's `field`. */ readonly field: string; /** `'number of data records (8 bytes at offset 236)'` — completes the first sentence. */ readonly description: string; readonly byteOffset: number; readonly byteLength: number; /** What the grammar wanted: `'a whole number of data records, or -1 when unknown'`. */ readonly expected: string; readonly specReference: string; /** The actionable next step, without a trailing full stop. */ readonly nextStep: string; readonly signalIndex?: number; } /** * The value of a field that edfcore cannot proceed without. * * A comma decimal or a failed grammar throws: these fields decide where bytes are and what they * mean, so a wrong reading would be worse than no reading. */ export declare function requireNumericField(parse: EdfNumberParse, context: NumericFieldContext, sink: DiagnosticSink): number; /** * The value of a field edfcore can survive without, or `NaN` when it could not be read. * * Only for the two fields with an authoritative alternative source — the declared header size, * which always loses to the computed one, and the record count, which is recoverable from the * source length. The caller reports what it did instead; a comma decimal is still fatal. */ export declare function readNumericField(parse: EdfNumberParse, context: NumericFieldContext, sink: DiagnosticSink): number; /** * The signal count at offset 252, validated to 1..9999. * * Fatal on anything else, including a comma, and deliberately reported as * `SIGNAL_COUNT_INVALID` rather than as the generic numeric codes: every per-signal field * address is `256 + ns * blockOffset + i * width`, so an unusable ns makes every byte after the * fixed header unlocatable. It is validated before any ns-sized allocation for the same reason. */ export declare function parseSignalCount(raw: string, sink: DiagnosticSink): number; /** * The declared header size at offset 184, checked against the computed `256 * (ns + 1)`. * * The computed value ALWAYS wins, which is what makes this a warning rather than a fatal * numeric field: a value edfcore never uses cannot make it read the wrong bytes. An unreadable * field is reported the same way and returned as `NaN`, so `header.declaredHeaderByteLength` * never claims a size the file did not state. */ export declare function checkDeclaredHeaderByteLength(raw: string, computedHeaderByteLength: number, sink: DiagnosticSink): number; /** * The record duration at offset 244, in seconds. * * May legitimately be 0 — an EDF+ file whose records carry only annotations does exactly that — * and `ZERO_RECORD_DURATION` says so without refusing the file. A NEGATIVE duration is refused: * it is not a tolerable oddity but a value that would make every record onset, sample time and * sample rate derived from it run backwards. So is a POSITIVE duration that no 100 ns tick count * can express, in either direction — see the comment on that check. */ export declare function parseRecordDuration(raw: string, sink: DiagnosticSink): number; /** * The declared record count at offset 236, verbatim. * * `-1` is the sanctioned "the writer never closed the file" value and is returned as `-1`; an * unreadable field is returned as `NaN`. Both mean the same thing to the caller — the count has * to come from the source length instead — and `header/parse.ts` reports which happened, since * only it knows the source length that resolves it. */ export declare function parseDeclaredRecordCount(raw: string, sink: DiagnosticSink): number; //# sourceMappingURL=fields.d.ts.map