Korin API

IndexedDocument
in package
implements Countable

FinalYes

A file opened for reading without its tree in memory (SPEC section 6, `open()`): an index of where each record starts, and records parsed from the file when they are asked for, the last ones kept in a cache. Building the index parses no record but the first and HEAD.

A record is a read-only document of its own with the nodes, line numbers and line diagnostics Parser gives it in the whole file; Document::copy() of it can be edited. The version is that of the first HEAD, for every record. self::diagnostics() has those of the whole file (encoding, HEAD, TRLR, version); line diagnostics are on the records; in strict mode every record is parsed while the index is built, so a file read() rejects is rejected here too. self::load() reads the whole file into a Document.

The document reads from the handle it was given whenever a record is asked for, seeking it: the handle must stay open and is not for other reads meanwhile. A file that cannot seek (an entry of a ZIP through zip://) is read on forward and opened again to go back, which reads it from the start: records read in order cost one pass, a record behind the last one read costs a pass up to it.

Table of Contents

Interfaces

Countable

Methods

__construct()  : mixed
__destruct()  : mixed
bytesAt()  : string
copyTo()  : void
count()  : int
Records, HEAD and TRLR included.
diagnostics()  : array<int, Diagnostic>
encoding()  : Encoding
families()  : Generator<int, Family>
family()  : Family|null
find()  : Node|null
As {@see Document::find()}.
hasBom()  : bool
head()  : Node|null
individual()  : Individual|null
individuals()  : Generator<int, Individual>
lineAt()  : int
lineEnding()  : string
Dominant line terminator of the file.
load()  : Document
The whole file read into a document, as {@see \Korin\Gedcom\Gedcom::read()} gives it.
mediaObject()  : MediaObject|null
mediaObjects()  : Generator<int, MediaObject>
record()  : Node|null
recordAt()  : Node
records()  : Generator<int, Node>
recordsAt()  : Document
repositories()  : Generator<int, Repository>
repository()  : Repository|null
sharedNote()  : SharedNote|null
sharedNotes()  : Generator<int, SharedNote>
sizeAt()  : int
source()  : Source|null
sources()  : Generator<int, Source>
sourceSystem()  : SourceSystem|null
The program that wrote the file, from HEAD.SOUR; null without one.
submitter()  : Submitter|null
submitters()  : Generator<int, Submitter>
tagAt()  : string
version()  : Version
xrefs()  : array<string, int>

Methods

__construct()

public __construct(resource $handle[, ReadOptions $options = new ReadOptions() ][, bool $close = false ][, int $cacheSize = self::CACHE_SIZE ][, Parser $parser = new Parser() ][, string|null $path = null ]) : mixed
Parameters
$handle : resource

seekable, read from its current position; or, with $path, opened from it

$options : ReadOptions = new ReadOptions()
$close : bool = false

whether the document closes the handle when it is destroyed

$cacheSize : int = self::CACHE_SIZE
$parser : Parser = new Parser()
$path : string|null = null

the file of a handle that cannot seek, opened again to go back

bytesAt()

public bytesAt(int $i) : string
Parameters
$i : int
Return values
string

copyTo()

public copyTo(resource $out) : void
Parameters
$out : resource

count()

Records, HEAD and TRLR included.

public count() : int
Return values
int

families()

public families() : Generator<int, Family>
Return values
Generator<int, Family> —

the FAM records in order, read one after another

find()

As {@see Document::find()}.

public find(string $path) : Node|null
Parameters
$path : string
Return values
Node|null

lineAt()

public lineAt(int $i) : int
Parameters
$i : int
Return values
int

lineEnding()

Dominant line terminator of the file.

public lineEnding() : string
Return values
string

recordAt()

public recordAt(int $i[, bool $cache = true ]) : Node
Parameters
$i : int
$cache : bool = true

whether to keep it among the recently used records

Return values
Node

records()

public records() : Generator<int, Node>
Return values
Generator<int, Node> —

all records in order, read one after another (not cached)

sharedNotes()

public sharedNotes() : Generator<int, SharedNote>
Return values
Generator<int, SharedNote> —

the note records (SNOTE in 7.0, NOTE in 5.x) in order, read one after another

sizeAt()

public sizeAt(int $i) : int
Parameters
$i : int
Return values
int

sources()

public sources() : Generator<int, Source>
Return values
Generator<int, Source> —

the SOUR records in order, read one after another

tagAt()

public tagAt(int $i) : string
Parameters
$i : int
Return values
string

xrefs()

public xrefs() : array<string, int>
Return values
array<string, int> —

xref => number of the first record with it

On this page

Search results