topspeed_io library
package:topspeed plus reading files on disk without loading them into
memory: openTps, readTps and TpsFileSource. Needs dart:io, so it
does not work on the web.
import 'package:topspeed/topspeed_io.dart';
void main() {
final reader = openTps(r'C:\data\INV.TPS');
try {
final inv = reader.table();
print('${inv.rowCount} rows');
print(inv.get('ITEM_KEY', {'ITEM_NBR': '12345'})?['DESCR']);
} finally {
reader.close();
}
}
Classes
- ClarionDateNames
- Month and weekday names used by formatClarionDate and formatClarionPicture.
- TpsByteSource
- Random access to the bytes of a .tps file, for TpsReader.
- TpsCodePage
- A single-byte code page: bytes 0x00–0x7F are ASCII and bytes 0x80–0xFF map through a 128-character table.
- TpsField
- One field (column) of a table.
- TpsFile
- An in-memory TopSpeed file. Parse it, read or change rows, then call toBytes to get the complete new file.
- TpsFileSource
- A TpsByteSource that reads a file on disk as needed.
- TpsIndex
- A KEY or INDEX of a table.
- TpsKeyPart
- One component of a key.
- TpsMemo
- A MEMO or BLOB column. Its data lives in separate memo records, not in the row payload.
- TpsMemorySource
- A TpsByteSource over bytes already in memory.
- TpsReader
- Reads a .tps file a few pages at a time, for files too large for TpsFile.parse.
- TpsReaderTable
- One table of a TpsReader: its definition and rows, read on demand.
- TpsRecord
- One entry of the file's B+tree. The tree is ordered by header bytes; whatever follows the header is the payload.
- TpsRecordType
- Record kinds, taken from byte 4 of the record header.
- TpsRow
- One data row of a table.
- TpsTable
- One table of a file: its definition, rows and indexes.
- TpsTableDefinition
- The layout of one table: its fields, memos and indexes.
- TpsTableInfo
-
What every table offers, whether it was loaded by TpsFile.parse
(TpsTable) or is read on demand (
TpsReaderTable).
Enums
- TpsFieldType
- Clarion field type codes as stored in the table definition.
Constants
- cp437 → const TpsCodePage
- IBM code page 437 (original IBM PC / DOS US).
- cp850 → const TpsCodePage
- IBM code page 850 (DOS Latin-1), common in older Clarion for DOS data.
- windows1252 → const TpsCodePage
- Windows-1252 (Western European ANSI), the default for TpsFile.parse.
Functions
-
clarionDateToDateTime(
int days) → DateTime? -
Converts a Clarion standard date (days since 28 December 1800; day 4 is
1 January 1801) to a UTC DateTime. Returns
nullfor 0, which Clarion uses for "no date". -
clarionTimeToDuration(
int time) → Duration? -
Converts a Clarion standard time (hundredths of a second since midnight,
plus one) to a Duration. Returns
nullfor 0, which Clarion uses for "no time". -
dateTimeToClarionDate(
DateTime? date) → int -
Converts
dateto a Clarion standard date, using only its calendar day. Returns 0 fornull. -
durationToClarionTime(
Duration? time) → int -
Converts
timeto a Clarion standard time. Returns 0 fornull. -
formatClarionDate(
Object? date, {String pattern = 'dd/MM/yyyy', ClarionDateNames names = ClarionDateNames.english}) → String -
Formats a date with
pattern; an empty string when there is no date. -
formatClarionPicture(
Object? value, String picture, {ClarionDateNames names = ClarionDateNames.english}) → String -
Formats
valuewith a Clarion date picture (@D1to@D16) or time picture (@T1to@T6), the way a Clarion window shows it, but without leading spaces. An empty string when there is no value. -
formatClarionTime(
Object? time, {String pattern = 'HH:mm:ss'}) → String -
Formats a time of day with
pattern; an empty string when there is no time. -
openTps(
String path, {String? password, Encoding encoding = windows1252, int cachePages = 64}) → TpsReader -
Opens the .tps file at
pathfor reading a few pages at a time. See TpsReader for the arguments; call TpsReader.close when done. -
readTps<
T> (String path, T read(TpsReader reader), {String? password, Encoding encoding = windows1252, int cachePages = 64, int attempts = 3}) → T -
Opens
path, runsreadand closes the file again, returning whatreadreturns. Safe on a file a Clarion program is writing to.
Exceptions / Errors
- TpsException
- Thrown when a file cannot be read or a change cannot be applied safely.