IndexedDocument
in package
implements
Countable
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
__destruct()
public
__destruct() : mixed
bytesAt()
public
bytesAt(int $i) : string
Parameters
- $i : int
Return values
stringcopyTo()
public
copyTo(resource $out) : void
Parameters
- $out : resource
count()
Records, HEAD and TRLR included.
public
count() : int
Return values
intdiagnostics()
public
diagnostics() : array<int, Diagnostic>
Return values
array<int, Diagnostic> —encoding detection, HEAD, TRLR and version (KV1004–KV1008)
encoding()
public
encoding() : Encoding
Return values
Encodingfamilies()
public
families() : Generator<int, Family>
Return values
Generator<int, Family> —the FAM records in order, read one after another
family()
public
family(string $xref) : Family|null
Parameters
- $xref : string
Return values
Family|nullfind()
As {@see Document::find()}.
public
find(string $path) : Node|null
Parameters
- $path : string
Return values
Node|nullhasBom()
public
hasBom() : bool
Return values
boolhead()
public
head() : Node|null
Return values
Node|nullindividual()
public
individual(string $xref) : Individual|null
Parameters
- $xref : string
Return values
Individual|nullindividuals()
public
individuals() : Generator<int, Individual>
Return values
Generator<int, Individual> —the INDI records in order, read one after another
lineAt()
public
lineAt(int $i) : int
Parameters
- $i : int
Return values
intlineEnding()
Dominant line terminator of the file.
public
lineEnding() : string
Return values
stringload()
The whole file read into a document, as {@see \Korin\Gedcom\Gedcom::read()} gives it.
public
load() : Document
Return values
DocumentmediaObject()
public
mediaObject(string $xref) : MediaObject|null
Parameters
- $xref : string
Return values
MediaObject|nullmediaObjects()
public
mediaObjects() : Generator<int, MediaObject>
Return values
Generator<int, MediaObject> —the OBJE records in order, read one after another
record()
public
record(string $xref) : Node|null
Parameters
- $xref : string
Return values
Node|nullrecordAt()
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
Noderecords()
public
records() : Generator<int, Node>
Return values
Generator<int, Node> —all records in order, read one after another (not cached)
recordsAt()
public
recordsAt(array<int, int> $numbers) : Document
Parameters
- $numbers : array<int, int>
-
in file order
Return values
Documentrepositories()
public
repositories() : Generator<int, Repository>
Return values
Generator<int, Repository> —the REPO records in order, read one after another
repository()
public
repository(string $xref) : Repository|null
Parameters
- $xref : string
Return values
Repository|nullsharedNote()
public
sharedNote(string $xref) : SharedNote|null
Parameters
- $xref : string
Return values
SharedNote|nullsharedNotes()
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
intsource()
public
source(string $xref) : Source|null
Parameters
- $xref : string
Return values
Source|nullsources()
public
sources() : Generator<int, Source>
Return values
Generator<int, Source> —the SOUR records in order, read one after another
sourceSystem()
The program that wrote the file, from HEAD.SOUR; null without one.
public
sourceSystem() : SourceSystem|null
Return values
SourceSystem|nullsubmitter()
public
submitter(string $xref) : Submitter|null
Parameters
- $xref : string
Return values
Submitter|nullsubmitters()
public
submitters() : Generator<int, Submitter>
Return values
Generator<int, Submitter> —the SUBM records in order, read one after another
tagAt()
public
tagAt(int $i) : string
Parameters
- $i : int
Return values
stringversion()
public
version() : Version
Return values
Versionxrefs()
public
xrefs() : array<string, int>
Return values
array<string, int> —xref => number of the first record with it