xref: /webtrees/app/Gedcom.php (revision f4c767fd89cdb62ee54edec032285924cd767af7)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees;
21
22/**
23 * GEDCOM 5.5.1 specification
24 */
25class Gedcom
26{
27    // Use MSDOS style line endings, for maximum compatibility.
28    public const EOL = "\r\n";
29
30    // 255 less the EOL character.
31    public const LINE_LENGTH = 253;
32
33    // Gedcom tags which indicate the start of life.
34    public const BIRTH_EVENTS = ['BIRT', 'CHR', 'BAPM', 'ADOP'];
35
36    // Gedcom tags which indicate the end of life.
37    public const DEATH_EVENTS = ['DEAT', 'BURI', 'CREM'];
38
39    // Gedcom tags which indicate the start of a relationship.
40    public const MARRIAGE_EVENTS = ['MARR', '_NMR'];
41
42    // Gedcom tags which indicate the end of a relationship.
43    public const DIVORCE_EVENTS = ['DIV', 'ANUL', '_SEPR'];
44
45    // Regular expression to match a GEDCOM tag.
46    public const REGEX_TAG = '[_A-Z][_A-Z0-9]*';
47
48    // Regular expression to match a GEDCOM XREF.
49    public const REGEX_XREF = '[A-Za-z0-9:_.-]+';
50
51    // UTF-8 encoded files may begin with an optional byte-order-mark (U+FEFF).
52    public const UTF8_BOM = "\xEF\xBB\xBF";
53
54    // Separates parts of a place name.
55    public const PLACE_SEPARATOR = ', ';
56
57    // Regex to match a (badly formed) GEDCOM place separator.
58    public const PLACE_SEPARATOR_REGEX = ' *, *';
59
60    // Not all record types allow a CHAN event.
61    public const RECORDS_WITH_CHAN = [
62        Family::RECORD_TYPE,
63        Individual::RECORD_TYPE,
64        Media::RECORD_TYPE,
65        Note::RECORD_TYPE,
66        Repository::RECORD_TYPE,
67        Source::RECORD_TYPE,
68        Submitter::RECORD_TYPE,
69    ];
70}
71