RecordParser Module
Core parsing functions for JV-Link fixed-length records.
This module provides low-level parsing utilities used by specific record parsers (RA.fs, UM.fs, etc.) to extract typed values from binary data.
Types
| Type | Description |
|
Represents a parsed field value with type information. |
|
|
Computation expression builder for Result with RecordParseError. |
|
|
Errors that can occur during record parsing. |
|
|
Represents a parsed field value with explicit missing indicators. |
|
|
Computation expression builder for Result with XanthosError. |
Functions and values
| Function or value |
Description
|
Full Usage:
extractBytes data offset length
Parameters:
byte[]
-
The source byte array.
offset : int
-
Zero-based starting position.
length : int
-
Number of bytes to extract.
Returns: Result<byte[], RecordParseError>
Ok with the byte slice, or Error if the slice would exceed data bounds.
|
Extracts a byte slice from record data at the specified offset and length.
|
Full Usage:
getBool fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: bool
The boolean value, or false if field not found.
|
Gets a boolean flag value from parsed fields (defaults to false).
|
Full Usage:
getBytes fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: byte[] option
Some byte array if present, None otherwise.
|
Gets an optional raw bytes field value from parsed fields.
|
Full Usage:
getCode fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: 'T option
Some enum value if present and valid, None otherwise.
|
Gets an optional code table value, parsed as an enum type.
|
Full Usage:
getDate fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: DateTime option
Some DateTime if present and valid, None otherwise.
|
Gets an optional date field value from parsed fields.
|
Full Usage:
getDecimal fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: decimal option
Some decimal if present and valid, None otherwise.
|
Gets an optional decimal field value from parsed fields.
|
Full Usage:
getInt fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: int option
Some int if present and valid, None otherwise.
|
Gets an optional integer field value from parsed fields.
|
Full Usage:
getRecordType data
Parameters:
byte[]
-
The source record byte array.
Returns: string
The record type string (e.g., "RA", "UM"), or empty string if data is too short.
|
Extracts the 2-byte record type identifier from record data.
|
Full Usage:
getRequiredText fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: Result<string, RecordParseError>
Ok with the text value, or Error if missing/empty.
|
Gets a required text field value, returning Error if missing or empty.
|
Full Usage:
getRichBool name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: bool option
|
Gets a boolean value from RichFieldValue map.
|
Full Usage:
getRichBytes name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: byte[] option
|
Gets raw bytes from RichFieldValue map.
|
Full Usage:
getRichCode name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: 'T option
|
Gets and parses a code value as an enum from RichFieldValue map.
|
Full Usage:
getRichDate name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: DateTime option
|
Gets a date value from RichFieldValue map (None for missing or RDateMissing).
|
Full Usage:
getRichDecimal name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: decimal option
|
Gets a decimal value from RichFieldValue map (None for missing or RDecimalMissing).
|
Full Usage:
getRichInt name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: int option
|
Gets an integer value from RichFieldValue map (None for missing or RIntMissing).
|
Full Usage:
getRichText name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: string option
|
Gets a text value from RichFieldValue map.
|
Full Usage:
getText fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: string option
Some text if present and non-empty, None otherwise.
|
Gets an optional text field value from parsed fields.
|
|
Computation expression instance for parsing with RecordParseError.
|
Full Usage:
parseDate bytes format
Parameters:
byte[]
-
The source bytes.
format : string
-
DateTime format string (e.g., "yyyyMMdd").
Returns: DateTime option
|
Parses a byte array as a date using the specified format string.
|
Full Usage:
parseDecimal bytes precision
Parameters:
byte[]
-
The source bytes.
precision : int
-
Number of decimal places (value is divided by 10^precision).
Returns: decimal option
|
Parses a byte array as a fixed-point decimal with the specified precision.
|
Full Usage:
parseField data spec
Parameters:
byte[]
-
The source record byte array.
spec : FieldSpec
-
The field specification defining offset, length, and encoding.
Returns: Result<FieldValue, RecordParseError>
Ok with the parsed FieldValue, or Error on extraction failure.
|
Parses a single field from record data using a field specification. Uses Option types to represent missing values.
|
Full Usage:
parseFieldRich data spec
Parameters:
byte[]
-
The source record byte array.
spec : FieldSpec
-
The field specification defining offset, length, and encoding.
Returns: Result<RichFieldValue, RecordParseError>
Ok with the parsed RichFieldValue, or Error on extraction failure.
|
Parses a single field from record data using a field specification. Returns a RichFieldValue that distinguishes between zero and missing values.
|
Full Usage:
parseFields data specs
Parameters:
byte[]
-
The source record byte array.
specs : FieldSpec list
-
List of field specifications to parse.
Returns: Result<Map<string, FieldValue>, RecordParseError>
Ok with a Map of field names to FieldValues, or Error on first parse failure.
|
Parses multiple fields from record data according to a list of specifications.
|
Full Usage:
parseFieldsRich data specs
Parameters:
byte[]
-
The source record byte array.
specs : FieldSpec list
-
List of field specifications to parse.
Returns: Result<Map<string, RichFieldValue>, RecordParseError>
Ok with a Map of field names to RichFieldValues, or Error on first parse failure.
|
Parses multiple fields from record data, returning RichFieldValue for each.
|
Full Usage:
parseFieldsXanthos data specs
Parameters:
byte[]
specs : FieldSpec list
Returns: Result<Map<string, FieldValue>, XanthosError>
|
Parse fields returning XanthosError (for use with parseRecord builder).
|
Full Usage:
parseFlag bytes
Parameters:
byte[]
Returns: bool
|
Parses a byte array as a boolean flag ("1" = true).
|
Full Usage:
parseInt bytes
Parameters:
byte[]
Returns: int option
|
Parses a byte array as an integer. Returns None if empty or invalid.
|
|
Computation expression instance for parsing with XanthosError.
|
Full Usage:
requireInt fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: Result<int, XanthosError>
Ok with the int value, or Error(XanthosError) if missing/invalid.
|
Gets a required integer field value, returning XanthosError if missing.
|
Full Usage:
requireText fields name
Parameters:
Map<string, FieldValue>
-
Map of parsed field values.
name : string
-
Field name to retrieve.
Returns: Result<string, XanthosError>
Ok with the text value, or Error(XanthosError) if missing/empty.
|
Gets a required text field value, returning XanthosError if missing.
|
Full Usage:
toXanthosError error
Parameters:
RecordParseError
-
The record parse error to convert.
Returns: XanthosError
A XanthosError (ValidationError) with a descriptive message.
|
Converts a RecordParseError to a XanthosError for unified error handling.
|
Full Usage:
tryGetRich name fields
Parameters:
string
fields : Map<string, RichFieldValue>
Returns: RichFieldValue option
|
Attempts to get a RichFieldValue by name from the fields map.
|
Xanthos