Korin API

Document
in package

FinalYes

Lossless, mutable GEDCOM tree. Nodes live in parallel arrays indexed by a stable id (0 is the virtual root whose children are the records); {@see Node} objects are thin views created on demand. Unmodified lines keep their original bytes, so preserve-mode writing reproduces the input exactly. Removed nodes become tombstones and keep their id.

Table of Contents

Methods

__construct()  : mixed
addDiagnostic()  : void
addFamily()  : Family
Adds a FAM record; without an xref the first free one of @F1@, @F2@ …
addIndividual()  : Individual
Adds an INDI record; without an xref the first free one of @I1@, @I2@ …
addParsedLine()  : int
addRecord()  : Node
Adds a record before TRLR (or at the end when there is none).
assertAttached()  : void
assertWritable()  : void
childIds()  : array<int, int>
contains()  : bool
continueAtLine()  : void
copy()  : self
Cheap independent snapshot: arrays are copied on write. A copy of a read-only document can be edited.
create()  : self
A new, empty document: HEAD with GEDC.VERS, and TRLR.
createNode()  : int
depthOf()  : int
diagnostics()  : array<int, Diagnostic>
encoding()  : Encoding
families()  : array<int, Family>
family()  : Family|null
find()  : Node|null
freeze()  : void
hasBom()  : bool
hasChildren()  : bool
hasContinuation()  : bool
hasPayload()  : bool
head()  : Node|null
individual()  : Individual|null
individuals()  : array<int, Individual>
isInvalid()  : bool
isReadOnly()  : bool
isRemoved()  : bool
lineBase()  : int
lineEnding()  : string
Dominant line terminator of the input; used for lines written anew.
lineOf()  : int
mayContain()  : bool
mediaObject()  : MediaObject|null
mediaObjects()  : array<int, MediaObject>
moveNode()  : void
nextId()  : int
nextRecord()  : int|null
node()  : Node
normalSpan()  : array{int, int}|null
originalBytes()  : array{string, string}|null
originalEol()  : string
originalText()  : array{string, string}|null
parentOf()  : int
payloadOf()  : string|null
record()  : Node|null
records()  : array<int, Node>
removeNode()  : void
removeRecord()  : void
renameXref()  : void
Renames a record's xref and every pointer to it.
repositories()  : array<int, Repository>
repository()  : Repository|null
setLineEnding()  : void
setPayload()  : void
setTag()  : void
setVersion()  : void
setXref()  : void
sharedNote()  : SharedNote|null
sharedNotes()  : array<int, SharedNote>
source()  : Source|null
sourceBytes()  : string
sources()  : array<int, Source>
sourceSystem()  : SourceSystem|null
The program that wrote the file, from HEAD.SOUR; null without one.
submitter()  : Submitter|null
submitters()  : array<int, Submitter>
substructureIdsReversed()  : array<int, int>
tagOf()  : string
version()  : Version
walk()  : Generator<int, int>
xrefOf()  : string|null

Methods

__construct()

public __construct(Version $version, Encoding $encoding, bool $bom, string $lineEnding[, string $source = '' ][, array<int, Diagnostic> $diagnostics = [] ][, int $lineBase = 0 ]) : mixed
Parameters
$version : Version
$encoding : Encoding
$bom : bool
$lineEnding : string
$source : string = ''
$diagnostics : array<int, Diagnostic> = []
$lineBase : int = 0

lines of the file before the source (a record of a stream)

addFamily()

Adds a FAM record; without an xref the first free one of @F1@, @F2@ …

public addFamily([string|null $xref = null ]) : Family
Parameters
$xref : string|null = null
Return values
Family

addIndividual()

Adds an INDI record; without an xref the first free one of @I1@, @I2@ …

public addIndividual([string|null $xref = null ]) : Individual
Parameters
$xref : string|null = null
Return values
Individual

addParsedLine()

public addParsedLine(int $parent, string|null $xref, string $tag, string|null $value, int $valueStart, int $offset, int $eolLength[, bool $invalid = false ]) : int
Parameters
$parent : int
$xref : string|null
$tag : string
$value : string|null
$valueStart : int

byte position of the value in the decoded line; 0 when there is none

$offset : int
$eolLength : int
$invalid : bool = false
Return values
int

addRecord()

Adds a record before TRLR (or at the end when there is none).

public addRecord(string $tag[, string|null $xref = null ][, string|null $value = null ]) : Node
Parameters
$tag : string
$xref : string|null = null
$value : string|null = null
Return values
Node

assertAttached()

public assertAttached(int $id) : void
Parameters
$id : int

assertWritable()

public assertWritable() : void

childIds()

public childIds(int $id) : array<int, int>
Parameters
$id : int
Return values
array<int, int> —

child ids in order, continuation lines and unparsable lines included

contains()

public contains(int $id) : bool
Parameters
$id : int
Return values
bool

continueAtLine()

public continueAtLine(int $line) : void
Parameters
$line : int

copy()

Cheap independent snapshot: arrays are copied on write. A copy of a read-only document can be edited.

public copy() : self
Return values
self

createNode()

public createNode(int $parent, string|null $xref, string $tag, string|null $payload[, int|null $before = null ]) : int
Parameters
$parent : int
$xref : string|null
$tag : string
$payload : string|null
$before : int|null = null

sibling to insert before; null appends

Return values
int

depthOf()

public depthOf(int $id) : int
Parameters
$id : int
Return values
int

families()

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

the FAM records, in order

family()

public family(string $xref) : Family|null
Parameters
$xref : string
Return values
Family|null

find()

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

hasBom()

public hasBom() : bool
Return values
bool

hasChildren()

public hasChildren(int $id) : bool
Parameters
$id : int
Return values
bool

hasContinuation()

public hasContinuation(int $id, string $ascii) : bool
Parameters
$id : int
$ascii : string
Return values
bool

hasPayload()

public hasPayload(int $id) : bool
Parameters
$id : int
Return values
bool

isInvalid()

public isInvalid(int $id) : bool
Parameters
$id : int
Return values
bool

isReadOnly()

public isReadOnly() : bool
Return values
bool

isRemoved()

public isRemoved(int $id) : bool
Parameters
$id : int
Return values
bool

lineBase()

public lineBase() : int
Return values
int

lineEnding()

Dominant line terminator of the input; used for lines written anew.

public lineEnding() : string
Return values
string

lineOf()

public lineOf(int $id) : int
Parameters
$id : int
Return values
int

mayContain()

public mayContain(int $id, string $ascii) : bool
Parameters
$id : int
$ascii : string
Return values
bool

moveNode()

public moveNode(int $id, int $parent[, int|null $before = null ]) : void
Parameters
$id : int
$parent : int
$before : int|null = null

nextId()

public nextId() : int
Return values
int

nextRecord()

public nextRecord(int $after) : int|null
Parameters
$after : int
Return values
int|null

normalSpan()

public normalSpan(int $id, int $depth, string $eol, int|null $limit) : array{int, int}|null
Parameters
$id : int
$depth : int
$eol : string
$limit : int|null
Return values
array{int, int}|null —

offset and length; null for new, modified and invalid lines

originalBytes()

public originalBytes(int $id) : array{string, string}|null
Parameters
$id : int
Return values
array{string, string}|null —

original line content and terminator; null for new or modified nodes

originalEol()

public originalEol(int $id) : string
Parameters
$id : int
Return values
string

originalText()

public originalText(int $id) : array{string, string}|null
Parameters
$id : int
Return values
array{string, string}|null —

line content and terminator; null for new or modified nodes

parentOf()

public parentOf(int $id) : int
Parameters
$id : int
Return values
int

payloadOf()

public payloadOf(int $id) : string|null
Parameters
$id : int
Return values
string|null

record()

public record(string $xref) : Node|null
Parameters
$xref : string
Return values
Node|null

records()

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

all records in order, HEAD and TRLR included

removeNode()

public removeNode(int $id) : void
Parameters
$id : int

removeRecord()

public removeRecord(string $xref) : void
Parameters
$xref : string

renameXref()

Renames a record's xref and every pointer to it.

public renameXref(string $from, string $to) : void
Parameters
$from : string
$to : string

setLineEnding()

public setLineEnding(string $lineEnding) : void
Parameters
$lineEnding : string

setPayload()

public setPayload(int $id, string|null $payload) : void
Parameters
$id : int
$payload : string|null

setTag()

public setTag(int $id, string $tag) : void
Parameters
$id : int
$tag : string

setXref()

public setXref(int $id, string|null $xref) : void
Parameters
$id : int
$xref : string|null

sharedNotes()

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

the note records (SNOTE in 7.0, NOTE in 5.x), in order

source()

public source(string $xref) : Source|null
Parameters
$xref : string
Return values
Source|null

sourceBytes()

public sourceBytes(int $offset, int $length) : string
Parameters
$offset : int
$length : int
Return values
string

sources()

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

the SOUR records, in order

substructureIdsReversed()

public substructureIdsReversed(int $id) : array<int, int>
Parameters
$id : int
Return values
array<int, int>

tagOf()

public tagOf(int $id) : string
Parameters
$id : int
Return values
string

walk()

public walk([array<int, int>|null $records = null ]) : Generator<int, int>
Parameters
$records : array<int, int>|null = null

only these records (convertFile() writes some of a document's records apart)

Return values
Generator<int, int> —

attached node ids in document order (depth first), root excluded, keyed by their depth (0 for records)

xrefOf()

public xrefOf(int $id) : string|null
Parameters
$id : int
Return values
string|null
On this page

Search results