Document
in package
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)
addDiagnostic()
public
addDiagnostic(Diagnostic $diagnostic) : void
Parameters
- $diagnostic : Diagnostic
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
FamilyaddIndividual()
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
IndividualaddParsedLine()
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
intaddRecord()
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
NodeassertAttached()
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
boolcontinueAtLine()
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
selfcreate()
A new, empty document: HEAD with GEDC.VERS, and TRLR.
public
static create([Version $version = Version::V7_0 ]) : self
Parameters
- $version : Version = Version::V7_0
Return values
selfcreateNode()
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
intdepthOf()
public
depthOf(int $id) : int
Parameters
- $id : int
Return values
intdiagnostics()
public
diagnostics() : array<int, Diagnostic>
Return values
array<int, Diagnostic>encoding()
public
encoding() : Encoding
Return values
Encodingfamilies()
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|nullfind()
public
find(string $path) : Node|null
Parameters
- $path : string
Return values
Node|nullfreeze()
public
freeze() : void
hasBom()
public
hasBom() : bool
Return values
boolhasChildren()
public
hasChildren(int $id) : bool
Parameters
- $id : int
Return values
boolhasContinuation()
public
hasContinuation(int $id, string $ascii) : bool
Parameters
- $id : int
- $ascii : string
Return values
boolhasPayload()
public
hasPayload(int $id) : bool
Parameters
- $id : int
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() : array<int, Individual>
Return values
array<int, Individual> —the INDI records, in order
isInvalid()
public
isInvalid(int $id) : bool
Parameters
- $id : int
Return values
boolisReadOnly()
public
isReadOnly() : bool
Return values
boolisRemoved()
public
isRemoved(int $id) : bool
Parameters
- $id : int
Return values
boollineBase()
public
lineBase() : int
Return values
intlineEnding()
Dominant line terminator of the input; used for lines written anew.
public
lineEnding() : string
Return values
stringlineOf()
public
lineOf(int $id) : int
Parameters
- $id : int
Return values
intmayContain()
public
mayContain(int $id, string $ascii) : bool
Parameters
- $id : int
- $ascii : string
Return values
boolmediaObject()
public
mediaObject(string $xref) : MediaObject|null
Parameters
- $xref : string
Return values
MediaObject|nullmediaObjects()
public
mediaObjects() : array<int, MediaObject>
Return values
array<int, MediaObject> —the OBJE records, in order
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
intnextRecord()
public
nextRecord(int $after) : int|null
Parameters
- $after : int
Return values
int|nullnode()
public
node(int $id) : Node
Parameters
- $id : int
Return values
NodenormalSpan()
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
stringoriginalText()
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
intpayloadOf()
public
payloadOf(int $id) : string|null
Parameters
- $id : int
Return values
string|nullrecord()
public
record(string $xref) : Node|null
Parameters
- $xref : string
Return values
Node|nullrecords()
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
repositories()
public
repositories() : array<int, Repository>
Return values
array<int, Repository> —the REPO records, in order
repository()
public
repository(string $xref) : Repository|null
Parameters
- $xref : string
Return values
Repository|nullsetLineEnding()
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
setVersion()
public
setVersion(Version $version) : void
Parameters
- $version : Version
setXref()
public
setXref(int $id, string|null $xref) : void
Parameters
- $id : int
- $xref : string|null
sharedNote()
public
sharedNote(string $xref) : SharedNote|null
Parameters
- $xref : string
Return values
SharedNote|nullsharedNotes()
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|nullsourceBytes()
public
sourceBytes(int $offset, int $length) : string
Parameters
- $offset : int
- $length : int
Return values
stringsources()
public
sources() : array<int, Source>
Return values
array<int, Source> —the SOUR records, in order
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() : array<int, Submitter>
Return values
array<int, Submitter> —the SUBM 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
stringversion()
public
version() : Version
Return values
Versionwalk()
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