1 package gedcom 2 3 // File automatically generated with ./genTypes.sh 4 5 import ( 6 "strconv" 7 "strings" 8 ) 9 10 // AddressCity is a GEDCOM base type 11 type AddressCity string 12 13 func (e *AddressCity) parse(l *Line, o options) error { 14 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 15 return ErrInvalidLength{"AddressCity", l.value, 1, 60} 16 } 17 *e = AddressCity(l.value) 18 return nil 19 } 20 21 // AddressCountry is a GEDCOM base type 22 type AddressCountry string 23 24 func (e *AddressCountry) parse(l *Line, o options) error { 25 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 26 return ErrInvalidLength{"AddressCountry", l.value, 1, 60} 27 } 28 *e = AddressCountry(l.value) 29 return nil 30 } 31 32 // AddressLine is a GEDCOM base type 33 type AddressLine string 34 35 func (e *AddressLine) parse(l *Line, o options) error { 36 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 37 return ErrInvalidLength{"AddressLine", l.value, 1, 60} 38 } 39 *e = AddressLine(l.value) 40 for i := 0; i < len(l.Sub); i++ { 41 switch l.Sub[i].tag { 42 case cCONT: 43 *e += "\n" 44 fallthrough 45 case cCONC: 46 if !o.allowWrongLength && (len(l.Sub[i].value) < 1 || len(l.Sub[i].value) > 60) { 47 return ErrContext{"AddressLine", l.Sub[i].tag, ErrInvalidLength{"AddressLine", l.value, 1, 60}} 48 } 49 *e += AddressLine(l.Sub[i].value) 50 copy(l.Sub[i:], l.Sub[i+1:]) 51 l.Sub = l.Sub[:len(l.Sub)-1] 52 i-- 53 } 54 } 55 return nil 56 } 57 58 // AddressLine1 is a GEDCOM base type 59 type AddressLine1 string 60 61 func (e *AddressLine1) parse(l *Line, o options) error { 62 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 63 return ErrInvalidLength{"AddressLine1", l.value, 1, 60} 64 } 65 *e = AddressLine1(l.value) 66 return nil 67 } 68 69 // AddressLine2 is a GEDCOM base type 70 type AddressLine2 string 71 72 func (e *AddressLine2) parse(l *Line, o options) error { 73 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 74 return ErrInvalidLength{"AddressLine2", l.value, 1, 60} 75 } 76 *e = AddressLine2(l.value) 77 return nil 78 } 79 80 // AddressPostalCode is a GEDCOM base type 81 type AddressPostalCode string 82 83 func (e *AddressPostalCode) parse(l *Line, o options) error { 84 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 10) { 85 return ErrInvalidLength{"AddressPostalCode", l.value, 1, 10} 86 } 87 *e = AddressPostalCode(l.value) 88 return nil 89 } 90 91 // AddressState is a GEDCOM base type 92 type AddressState string 93 94 func (e *AddressState) parse(l *Line, o options) error { 95 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 96 return ErrInvalidLength{"AddressState", l.value, 1, 60} 97 } 98 *e = AddressState(l.value) 99 return nil 100 } 101 102 // AdoptedBy is a GEDCOM base type 103 type AdoptedBy string 104 105 func (e *AdoptedBy) parse(l *Line, o options) error { 106 switch strings.ToUpper(l.value) { 107 case cHUSB: 108 *e = cHUSB 109 case cWIFE: 110 *e = cWIFE 111 case cBOTH: 112 *e = cBOTH 113 default: 114 if !o.ignoreInvalidValue { 115 return ErrInvalidValue{"AdoptedBy", l.value} 116 } 117 } 118 return nil 119 } 120 121 // AgeAtEvent is a GEDCOM base type 122 type AgeAtEvent string 123 124 func (e *AgeAtEvent) parse(l *Line, o options) error { 125 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 12) { 126 return ErrInvalidLength{"AgeAtEvent", l.value, 1, 12} 127 } 128 *e = AgeAtEvent(l.value) 129 return nil 130 } 131 132 // AncestralFileNumber is a GEDCOM base type 133 type AncestralFileNumber string 134 135 func (e *AncestralFileNumber) parse(l *Line, o options) error { 136 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 12) { 137 return ErrInvalidLength{"AncestralFileNumber", l.value, 1, 12} 138 } 139 *e = AncestralFileNumber(l.value) 140 return nil 141 } 142 143 // ApprovedSystemID is a GEDCOM base type 144 type ApprovedSystemID string 145 146 func (e *ApprovedSystemID) parse(l *Line, o options) error { 147 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 20) { 148 return ErrInvalidLength{"ApprovedSystemID", l.value, 1, 20} 149 } 150 *e = ApprovedSystemID(l.value) 151 return nil 152 } 153 154 // AttributeType is a GEDCOM base type 155 type AttributeType string 156 157 func (e *AttributeType) parse(l *Line, o options) error { 158 switch strings.ToUpper(l.value) { 159 case cCAST: 160 *e = cCAST 161 case cEDUC: 162 *e = cEDUC 163 case cNATI: 164 *e = cNATI 165 case cOCCU: 166 *e = cOCCU 167 case cPROP: 168 *e = cPROP 169 case cRELI: 170 *e = cRELI 171 case cRESI: 172 *e = cRESI 173 case cTITL: 174 *e = cTITL 175 default: 176 if !o.ignoreInvalidValue { 177 return ErrInvalidValue{"AttributeType", l.value} 178 } 179 } 180 return nil 181 } 182 183 // AutomatedRecordID is a GEDCOM base type 184 type AutomatedRecordID string 185 186 func (e *AutomatedRecordID) parse(l *Line, o options) error { 187 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 12) { 188 return ErrInvalidLength{"AutomatedRecordID", l.value, 1, 12} 189 } 190 *e = AutomatedRecordID(l.value) 191 return nil 192 } 193 194 // CasteName is a GEDCOM base type 195 type CasteName string 196 197 func (e *CasteName) parse(l *Line, o options) error { 198 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 199 return ErrInvalidLength{"CasteName", l.value, 1, 90} 200 } 201 *e = CasteName(l.value) 202 return nil 203 } 204 205 // CauseOfEvent is a GEDCOM base type 206 type CauseOfEvent string 207 208 func (e *CauseOfEvent) parse(l *Line, o options) error { 209 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 210 return ErrInvalidLength{"CauseOfEvent", l.value, 1, 90} 211 } 212 *e = CauseOfEvent(l.value) 213 return nil 214 } 215 216 // CertaintyAssessment is a GEDCOM base type 217 type CertaintyAssessment uint 218 219 func (e *CertaintyAssessment) parse(l *Line, o options) error { 220 switch l.value { 221 case c0: 222 *e = 0 223 case c1: 224 *e = 1 225 case c2: 226 *e = 2 227 case c3: 228 *e = 3 229 default: 230 if !o.ignoreInvalidValue { 231 return ErrInvalidValue{"CertaintyAssessment", l.value} 232 } 233 } 234 return nil 235 } 236 237 // ChangeDate is a GEDCOM base type 238 type ChangeDate string 239 240 func (e *ChangeDate) parse(l *Line, o options) error { 241 if !o.allowWrongLength && (len(l.value) < 10 || len(l.value) > 11) { 242 return ErrInvalidLength{"ChangeDate", l.value, 10, 11} 243 } 244 *e = ChangeDate(l.value) 245 return nil 246 } 247 248 // CharacterSet is a GEDCOM base type 249 type CharacterSet string 250 251 func (e *CharacterSet) parse(l *Line, o options) error { 252 switch strings.ToUpper(l.value) { 253 case cANSEL: 254 *e = cANSEL 255 case cUNICODE: 256 *e = cUNICODE 257 case cASCII: 258 *e = cASCII 259 default: 260 if !o.ignoreInvalidValue { 261 return ErrInvalidValue{"CharacterSet", l.value} 262 } 263 } 264 return nil 265 } 266 267 // CopyrightGedcomFile is a GEDCOM base type 268 type CopyrightGedcomFile string 269 270 func (e *CopyrightGedcomFile) parse(l *Line, o options) error { 271 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 272 return ErrInvalidLength{"CopyrightGedcomFile", l.value, 1, 90} 273 } 274 *e = CopyrightGedcomFile(l.value) 275 return nil 276 } 277 278 // CopyrightSourceData is a GEDCOM base type 279 type CopyrightSourceData string 280 281 func (e *CopyrightSourceData) parse(l *Line, o options) error { 282 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 283 return ErrInvalidLength{"CopyrightSourceData", l.value, 1, 90} 284 } 285 *e = CopyrightSourceData(l.value) 286 return nil 287 } 288 289 // CountOfChildren is a GEDCOM base type 290 type CountOfChildren uint8 291 292 func (e *CountOfChildren) parse(l *Line, o options) error { 293 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 3) { 294 return ErrInvalidLength{"CountOfChildren", l.value, 1, 3} 295 } 296 n, err := strconv.ParseUint(l.value, 10, 8) 297 if !o.ignoreInvalidValue && err != nil { 298 return err 299 } 300 *e = CountOfChildren(n) 301 return nil 302 } 303 304 // CountOfMarriages is a GEDCOM base type 305 type CountOfMarriages uint8 306 307 func (e *CountOfMarriages) parse(l *Line, o options) error { 308 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 3) { 309 return ErrInvalidLength{"CountOfMarriages", l.value, 1, 3} 310 } 311 n, err := strconv.ParseUint(l.value, 10, 8) 312 if !o.ignoreInvalidValue && err != nil { 313 return err 314 } 315 *e = CountOfMarriages(n) 316 return nil 317 } 318 319 // Date is a GEDCOM base type 320 type Date string 321 322 func (e *Date) parse(l *Line, o options) error { 323 if !o.allowWrongLength && (len(l.value) < 3 || len(l.value) > 35) { 324 return ErrInvalidLength{"Date", l.value, 3, 35} 325 } 326 *e = Date(l.value) 327 return nil 328 } 329 330 // DateApproximated is a GEDCOM base type 331 type DateApproximated string 332 333 func (e *DateApproximated) parse(l *Line, o options) error { 334 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 35) { 335 return ErrInvalidLength{"DateApproximated", l.value, 4, 35} 336 } 337 *e = DateApproximated(l.value) 338 return nil 339 } 340 341 // DateCalendar is a GEDCOM base type 342 type DateCalendar string 343 344 func (e *DateCalendar) parse(l *Line, o options) error { 345 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 35) { 346 return ErrInvalidLength{"DateCalendar", l.value, 4, 35} 347 } 348 *e = DateCalendar(l.value) 349 return nil 350 } 351 352 // DateCalendarEscape is a GEDCOM base type 353 type DateCalendarEscape string 354 355 func (e *DateCalendarEscape) parse(l *Line, o options) error { 356 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 15) { 357 return ErrInvalidLength{"DateCalendarEscape", l.value, 4, 15} 358 } 359 *e = DateCalendarEscape(l.value) 360 return nil 361 } 362 363 // DateExact is a GEDCOM base type 364 type DateExact string 365 366 func (e *DateExact) parse(l *Line, o options) error { 367 if !o.allowWrongLength && (len(l.value) < 10 || len(l.value) > 11) { 368 return ErrInvalidLength{"DateExact", l.value, 10, 11} 369 } 370 *e = DateExact(l.value) 371 return nil 372 } 373 374 // DateFren is a GEDCOM base type 375 type DateFren string 376 377 func (e *DateFren) parse(l *Line, o options) error { 378 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 35) { 379 return ErrInvalidLength{"DateFren", l.value, 4, 35} 380 } 381 *e = DateFren(l.value) 382 return nil 383 } 384 385 // DateGreg is a GEDCOM base type 386 type DateGreg string 387 388 func (e *DateGreg) parse(l *Line, o options) error { 389 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 35) { 390 return ErrInvalidLength{"DateGreg", l.value, 4, 35} 391 } 392 *e = DateGreg(l.value) 393 return nil 394 } 395 396 // DateHebr is a GEDCOM base type 397 type DateHebr string 398 399 func (e *DateHebr) parse(l *Line, o options) error { 400 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 35) { 401 return ErrInvalidLength{"DateHebr", l.value, 4, 35} 402 } 403 *e = DateHebr(l.value) 404 return nil 405 } 406 407 // DateJuln is a GEDCOM base type 408 type DateJuln string 409 410 func (e *DateJuln) parse(l *Line, o options) error { 411 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 35) { 412 return ErrInvalidLength{"DateJuln", l.value, 4, 35} 413 } 414 *e = DateJuln(l.value) 415 return nil 416 } 417 418 // DateLDSOrd is a GEDCOM base type 419 type DateLDSOrd string 420 421 func (e *DateLDSOrd) parse(l *Line, o options) error { 422 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 35) { 423 return ErrInvalidLength{"DateLDSOrd", l.value, 4, 35} 424 } 425 *e = DateLDSOrd(l.value) 426 return nil 427 } 428 429 // DatePeriod is a GEDCOM base type 430 type DatePeriod string 431 432 func (e *DatePeriod) parse(l *Line, o options) error { 433 if !o.allowWrongLength && (len(l.value) < 7 || len(l.value) > 35) { 434 return ErrInvalidLength{"DatePeriod", l.value, 7, 35} 435 } 436 *e = DatePeriod(l.value) 437 return nil 438 } 439 440 // DatePhrase is a GEDCOM base type 441 type DatePhrase string 442 443 func (e *DatePhrase) parse(l *Line, o options) error { 444 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 35) { 445 return ErrInvalidLength{"DatePhrase", l.value, 1, 35} 446 } 447 *e = DatePhrase(l.value) 448 return nil 449 } 450 451 // DateRange is a GEDCOM base type 452 type DateRange string 453 454 func (e *DateRange) parse(l *Line, o options) error { 455 if !o.allowWrongLength && (len(l.value) < 8 || len(l.value) > 35) { 456 return ErrInvalidLength{"DateRange", l.value, 8, 35} 457 } 458 *e = DateRange(l.value) 459 return nil 460 } 461 462 // DateValue is a GEDCOM base type 463 type DateValue string 464 465 func (e *DateValue) parse(l *Line, o options) error { 466 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 35) { 467 return ErrInvalidLength{"DateValue", l.value, 1, 35} 468 } 469 *e = DateValue(l.value) 470 return nil 471 } 472 473 // Day is a GEDCOM base type 474 type Day uint8 475 476 func (e *Day) parse(l *Line, o options) error { 477 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 2) { 478 return ErrInvalidLength{"Day", l.value, 1, 2} 479 } 480 n, err := strconv.ParseUint(l.value, 10, 8) 481 if !o.ignoreInvalidValue && err != nil { 482 return err 483 } 484 *e = Day(n) 485 return nil 486 } 487 488 // DescriptiveTitle is a GEDCOM base type 489 type DescriptiveTitle string 490 491 func (e *DescriptiveTitle) parse(l *Line, o options) error { 492 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 493 return ErrInvalidLength{"DescriptiveTitle", l.value, 1, 248} 494 } 495 *e = DescriptiveTitle(l.value) 496 return nil 497 } 498 499 // Digit is a GEDCOM base type 500 type Digit uint8 501 502 func (e *Digit) parse(l *Line, o options) error { 503 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 1) { 504 return ErrInvalidLength{"Digit", l.value, 1, 1} 505 } 506 n, err := strconv.ParseUint(l.value, 10, 8) 507 if !o.ignoreInvalidValue && err != nil { 508 return err 509 } 510 *e = Digit(n) 511 return nil 512 } 513 514 // EncodedMultimediaLine is a GEDCOM base type 515 type EncodedMultimediaLine string 516 517 func (e *EncodedMultimediaLine) parse(l *Line, o options) error { 518 if !o.allowWrongLength && len(l.value) > 87 { 519 return ErrInvalidLength{"EncodedMultimediaLine", l.value, 0, 87} 520 } 521 *e = EncodedMultimediaLine(l.value) 522 return nil 523 } 524 525 // EntryRecordingDate is a GEDCOM base type 526 type EntryRecordingDate string 527 528 func (e *EntryRecordingDate) parse(l *Line, o options) error { 529 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 530 return ErrInvalidLength{"EntryRecordingDate", l.value, 1, 90} 531 } 532 *e = EntryRecordingDate(l.value) 533 return nil 534 } 535 536 // EventAttributeType is a GEDCOM base type 537 type EventAttributeType string 538 539 func (e *EventAttributeType) parse(l *Line, o options) error { 540 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 15) { 541 return ErrInvalidLength{"EventAttributeType", l.value, 1, 15} 542 } 543 *e = EventAttributeType(l.value) 544 return nil 545 } 546 547 // EventDescriptor is a GEDCOM base type 548 type EventDescriptor string 549 550 func (e *EventDescriptor) parse(l *Line, o options) error { 551 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 552 return ErrInvalidLength{"EventDescriptor", l.value, 1, 90} 553 } 554 *e = EventDescriptor(l.value) 555 return nil 556 } 557 558 // EventTypeCitedFrom is a GEDCOM base type 559 type EventTypeCitedFrom string 560 561 func (e *EventTypeCitedFrom) parse(l *Line, o options) error { 562 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 15) { 563 return ErrInvalidLength{"EventTypeCitedFrom", l.value, 1, 15} 564 } 565 *e = EventTypeCitedFrom(l.value) 566 return nil 567 } 568 569 // EventTypeFamile is a GEDCOM base type 570 type EventTypeFamile string 571 572 func (e *EventTypeFamile) parse(l *Line, o options) error { 573 switch strings.ToUpper(l.value) { 574 case cANUL: 575 *e = cANUL 576 case cCENS: 577 *e = cCENS 578 case cDIV: 579 *e = cDIV 580 case cDIVF: 581 *e = cDIVF 582 case cENGA: 583 *e = cENGA 584 case cMARR: 585 *e = cMARR 586 case cMARB: 587 *e = cMARB 588 case cMARC: 589 *e = cMARC 590 case cMARL: 591 *e = cMARL 592 case cMARS: 593 *e = cMARS 594 case cEVEN: 595 *e = cEVEN 596 default: 597 if !o.ignoreInvalidValue { 598 return ErrInvalidValue{"EventTypeFamile", l.value} 599 } 600 } 601 return nil 602 } 603 604 // EventTypeIndividual is a GEDCOM base type 605 type EventTypeIndividual string 606 607 func (e *EventTypeIndividual) parse(l *Line, o options) error { 608 switch strings.ToUpper(l.value) { 609 case cADOP: 610 *e = cADOP 611 case cBIRT: 612 *e = cBIRT 613 case cBAPM: 614 *e = cBAPM 615 case cBARM: 616 *e = cBARM 617 case cBASM: 618 *e = cBASM 619 case cBLES: 620 *e = cBLES 621 case cBURI: 622 *e = cBURI 623 case cCENS: 624 *e = cCENS 625 case cCHR: 626 *e = cCHR 627 case cCHRA: 628 *e = cCHRA 629 case cCONF: 630 *e = cCONF 631 case cCREM: 632 *e = cCREM 633 case cDEAT: 634 *e = cDEAT 635 case cEMIG: 636 *e = cEMIG 637 case cFCOM: 638 *e = cFCOM 639 case cGRAD: 640 *e = cGRAD 641 case cIMMI: 642 *e = cIMMI 643 case cNATU: 644 *e = cNATU 645 case cORDN: 646 *e = cORDN 647 case cRETI: 648 *e = cRETI 649 case cPROB: 650 *e = cPROB 651 case cWILL: 652 *e = cWILL 653 case cEVEN: 654 *e = cEVEN 655 default: 656 if !o.ignoreInvalidValue { 657 return ErrInvalidValue{"EventTypeIndividual", l.value} 658 } 659 } 660 return nil 661 } 662 663 // EventsRecorded is a GEDCOM base type 664 type EventsRecorded string 665 666 func (e *EventsRecorded) parse(l *Line, o options) error { 667 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 668 return ErrInvalidLength{"EventsRecorded", l.value, 1, 90} 669 } 670 *e = EventsRecorded(l.value) 671 return nil 672 } 673 674 // FileName is a GEDCOM base type 675 type FileName string 676 677 func (e *FileName) parse(l *Line, o options) error { 678 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 679 return ErrInvalidLength{"FileName", l.value, 1, 90} 680 } 681 *e = FileName(l.value) 682 return nil 683 } 684 685 // ContentDescription is a GEDCOM base type 686 type ContentDescription string 687 688 func (e *ContentDescription) parse(l *Line, o options) error { 689 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 690 return ErrInvalidLength{"ContentDescription", l.value, 1, 248} 691 } 692 *e = ContentDescription(l.value) 693 for i := 0; i < len(l.Sub); i++ { 694 switch l.Sub[i].tag { 695 case cCONT: 696 *e += "\n" 697 fallthrough 698 case cCONC: 699 if !o.allowWrongLength && (len(l.Sub[i].value) < 1 || len(l.Sub[i].value) > 248) { 700 return ErrContext{"ContentDescription", l.Sub[i].tag, ErrInvalidLength{"ContentDescription", l.value, 1, 248}} 701 } 702 *e += ContentDescription(l.Sub[i].value) 703 copy(l.Sub[i:], l.Sub[i+1:]) 704 l.Sub = l.Sub[:len(l.Sub)-1] 705 i-- 706 } 707 } 708 return nil 709 } 710 711 // Form is a GEDCOM base type 712 type Form string 713 714 func (e *Form) parse(l *Line, o options) error { 715 if !o.allowWrongLength && (len(l.value) < 14 || len(l.value) > 20) { 716 return ErrInvalidLength{"Form", l.value, 14, 20} 717 } 718 *e = Form(l.value) 719 return nil 720 } 721 722 // GenerationsOfAncestors is a GEDCOM base type 723 type GenerationsOfAncestors uint16 724 725 func (e *GenerationsOfAncestors) parse(l *Line, o options) error { 726 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 4) { 727 return ErrInvalidLength{"GenerationsOfAncestors", l.value, 1, 4} 728 } 729 n, err := strconv.ParseUint(l.value, 10, 16) 730 if !o.ignoreInvalidValue && err != nil { 731 return err 732 } 733 *e = GenerationsOfAncestors(n) 734 return nil 735 } 736 737 // GenerationsOfDescendants is a GEDCOM base type 738 type GenerationsOfDescendants uint16 739 740 func (e *GenerationsOfDescendants) parse(l *Line, o options) error { 741 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 4) { 742 return ErrInvalidLength{"GenerationsOfDescendants", l.value, 1, 4} 743 } 744 n, err := strconv.ParseUint(l.value, 10, 16) 745 if !o.ignoreInvalidValue && err != nil { 746 return err 747 } 748 *e = GenerationsOfDescendants(n) 749 return nil 750 } 751 752 // LanguageID is a GEDCOM base type 753 type LanguageID string 754 755 func (e *LanguageID) parse(l *Line, o options) error { 756 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 15) { 757 return ErrInvalidLength{"LanguageID", l.value, 1, 15} 758 } 759 *e = LanguageID(l.value) 760 return nil 761 } 762 763 // LanguageOfText is a GEDCOM base type 764 type LanguageOfText string 765 766 func (e *LanguageOfText) parse(l *Line, o options) error { 767 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 15) { 768 return ErrInvalidLength{"LanguageOfText", l.value, 1, 15} 769 } 770 *e = LanguageOfText(l.value) 771 return nil 772 } 773 774 // LanguagePreference is a GEDCOM base type 775 type LanguagePreference string 776 777 func (e *LanguagePreference) parse(l *Line, o options) error { 778 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 779 return ErrInvalidLength{"LanguagePreference", l.value, 1, 90} 780 } 781 *e = LanguagePreference(l.value) 782 return nil 783 } 784 785 // LDSBaptismDateStatus is a GEDCOM base type 786 type LDSBaptismDateStatus string 787 788 func (e *LDSBaptismDateStatus) parse(l *Line, o options) error { 789 switch strings.ToUpper(l.value) { 790 case cCHILD: 791 *e = cCHILD 792 case cCLEARED: 793 *e = cCLEARED 794 case cCOMPLETED: 795 *e = cCOMPLETED 796 case cINFANT: 797 *e = cINFANT 798 case cPRE1970: 799 *e = cPRE1970 800 case cQUALIFIED: 801 *e = cQUALIFIED 802 case cSTILLBORN: 803 *e = cSTILLBORN 804 case cSUBMITTED: 805 *e = cSUBMITTED 806 case cUNCLEARED: 807 *e = cUNCLEARED 808 default: 809 if !o.ignoreInvalidValue { 810 return ErrInvalidValue{"LDSBaptismDateStatus", l.value} 811 } 812 } 813 return nil 814 } 815 816 // LDSChildSealingDateStatus is a GEDCOM base type 817 type LDSChildSealingDateStatus string 818 819 func (e *LDSChildSealingDateStatus) parse(l *Line, o options) error { 820 switch strings.ToUpper(l.value) { 821 case cBIC: 822 *e = cBIC 823 case cCLEARED: 824 *e = cCLEARED 825 case cCOMPLETED: 826 *e = cCOMPLETED 827 case cDNS: 828 *e = cDNS 829 case cPRE1970: 830 *e = cPRE1970 831 case cQUALIFIED: 832 *e = cQUALIFIED 833 case cSTILLBORN: 834 *e = cSTILLBORN 835 case cSUBMITTES: 836 *e = cSUBMITTES 837 case cUNCLEARED: 838 *e = cUNCLEARED 839 default: 840 if !o.ignoreInvalidValue { 841 return ErrInvalidValue{"LDSChildSealingDateStatus", l.value} 842 } 843 } 844 return nil 845 } 846 847 // LDSEndowmentDateStatus is a GEDCOM base type 848 type LDSEndowmentDateStatus string 849 850 func (e *LDSEndowmentDateStatus) parse(l *Line, o options) error { 851 switch strings.ToUpper(l.value) { 852 case cCHILD: 853 *e = cCHILD 854 case cCLEARED: 855 *e = cCLEARED 856 case cCOMPLETED: 857 *e = cCOMPLETED 858 case cINFANT: 859 *e = cINFANT 860 case cPRE1970: 861 *e = cPRE1970 862 case cQUALIFIED: 863 *e = cQUALIFIED 864 case cSTILLBORN: 865 *e = cSTILLBORN 866 case cSUBMITTED: 867 *e = cSUBMITTED 868 case cUNCLEARED: 869 *e = cUNCLEARED 870 default: 871 if !o.ignoreInvalidValue { 872 return ErrInvalidValue{"LDSEndowmentDateStatus", l.value} 873 } 874 } 875 return nil 876 } 877 878 // LDSSpouseSealingDateStatus is a GEDCOM base type 879 type LDSSpouseSealingDateStatus string 880 881 func (e *LDSSpouseSealingDateStatus) parse(l *Line, o options) error { 882 switch strings.ToUpper(l.value) { 883 case cCANCELED: 884 *e = cCANCELED 885 case cCLEARED: 886 *e = cCLEARED 887 case cCOMPLETED: 888 *e = cCOMPLETED 889 case cDNS: 890 *e = cDNS 891 case cDNSCAN: 892 *e = cDNSCAN 893 case cPRE1970: 894 *e = cPRE1970 895 case cQUALIFIED: 896 *e = cQUALIFIED 897 case cSUBMITTED: 898 *e = cSUBMITTED 899 case cUNCLEARED: 900 *e = cUNCLEARED 901 default: 902 if !o.ignoreInvalidValue { 903 return ErrInvalidValue{"LDSSpouseSealingDateStatus", l.value} 904 } 905 } 906 return nil 907 } 908 909 // Month is a GEDCOM base type 910 type Month string 911 912 func (e *Month) parse(l *Line, o options) error { 913 switch strings.ToUpper(l.value) { 914 case cJAN: 915 *e = cJAN 916 case cFEB: 917 *e = cFEB 918 case cMAR: 919 *e = cMAR 920 case cAPR: 921 *e = cAPR 922 case cMAY: 923 *e = cMAY 924 case cJUN: 925 *e = cJUN 926 case cJUL: 927 *e = cJUL 928 case cAUG: 929 *e = cAUG 930 case cSEP: 931 *e = cSEP 932 case cOCT: 933 *e = cOCT 934 case cNOV: 935 *e = cNOV 936 case cDEC: 937 *e = cDEC 938 default: 939 if !o.ignoreInvalidValue { 940 return ErrInvalidValue{"Month", l.value} 941 } 942 } 943 return nil 944 } 945 946 // MonthFren is a GEDCOM base type 947 type MonthFren string 948 949 func (e *MonthFren) parse(l *Line, o options) error { 950 switch strings.ToUpper(l.value) { 951 case cVEND: 952 *e = cVEND 953 case cBRUM: 954 *e = cBRUM 955 case cFRIM: 956 *e = cFRIM 957 case cNIVO: 958 *e = cNIVO 959 case cPLUV: 960 *e = cPLUV 961 case cVENT: 962 *e = cVENT 963 case cGERM: 964 *e = cGERM 965 case cFLOR: 966 *e = cFLOR 967 case cPRAI: 968 *e = cPRAI 969 case cMESS: 970 *e = cMESS 971 case cTHER: 972 *e = cTHER 973 case cFRUC: 974 *e = cFRUC 975 case cCOMP: 976 *e = cCOMP 977 default: 978 if !o.ignoreInvalidValue { 979 return ErrInvalidValue{"MonthFren", l.value} 980 } 981 } 982 return nil 983 } 984 985 // MonthHebr is a GEDCOM base type 986 type MonthHebr string 987 988 func (e *MonthHebr) parse(l *Line, o options) error { 989 switch strings.ToUpper(l.value) { 990 case cTSH: 991 *e = cTSH 992 case cCSH: 993 *e = cCSH 994 case cKSL: 995 *e = cKSL 996 case cTVT: 997 *e = cTVT 998 case cSHV: 999 *e = cSHV 1000 case cADR: 1001 *e = cADR 1002 case cADS: 1003 *e = cADS 1004 case cNSN: 1005 *e = cNSN 1006 case cIYR: 1007 *e = cIYR 1008 case cSVN: 1009 *e = cSVN 1010 case cTMZ: 1011 *e = cTMZ 1012 case cAAV: 1013 *e = cAAV 1014 case cELL: 1015 *e = cELL 1016 default: 1017 if !o.ignoreInvalidValue { 1018 return ErrInvalidValue{"MonthHebr", l.value} 1019 } 1020 } 1021 return nil 1022 } 1023 1024 // MultimediaFileReference is a GEDCOM base type 1025 type MultimediaFileReference string 1026 1027 func (e *MultimediaFileReference) parse(l *Line, o options) error { 1028 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 30) { 1029 return ErrInvalidLength{"MultimediaFileReference", l.value, 1, 30} 1030 } 1031 *e = MultimediaFileReference(l.value) 1032 return nil 1033 } 1034 1035 // MultimediaFormat is a GEDCOM base type 1036 type MultimediaFormat string 1037 1038 func (e *MultimediaFormat) parse(l *Line, o options) error { 1039 switch strings.ToLower(l.value) { 1040 case cbmp: 1041 *e = cbmp 1042 case cgif: 1043 *e = cgif 1044 case cjpeg: 1045 *e = cjpeg 1046 case cole: 1047 *e = cole 1048 case cpcx: 1049 *e = cpcx 1050 case ctiff: 1051 *e = ctiff 1052 case cwav: 1053 *e = cwav 1054 default: 1055 if !o.ignoreInvalidValue { 1056 return ErrInvalidValue{"MultimediaFormat", l.value} 1057 } 1058 } 1059 return nil 1060 } 1061 1062 // NameOfBusiness is a GEDCOM base type 1063 type NameOfBusiness string 1064 1065 func (e *NameOfBusiness) parse(l *Line, o options) error { 1066 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1067 return ErrInvalidLength{"NameOfBusiness", l.value, 1, 90} 1068 } 1069 *e = NameOfBusiness(l.value) 1070 return nil 1071 } 1072 1073 // NameOfFamilyFile is a GEDCOM base type 1074 type NameOfFamilyFile string 1075 1076 func (e *NameOfFamilyFile) parse(l *Line, o options) error { 1077 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 20) { 1078 return ErrInvalidLength{"NameOfFamilyFile", l.value, 1, 20} 1079 } 1080 *e = NameOfFamilyFile(l.value) 1081 return nil 1082 } 1083 1084 // NameOfProduct is a GEDCOM base type 1085 type NameOfProduct string 1086 1087 func (e *NameOfProduct) parse(l *Line, o options) error { 1088 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1089 return ErrInvalidLength{"NameOfProduct", l.value, 1, 90} 1090 } 1091 *e = NameOfProduct(l.value) 1092 return nil 1093 } 1094 1095 // NameOfRepository is a GEDCOM base type 1096 type NameOfRepository string 1097 1098 func (e *NameOfRepository) parse(l *Line, o options) error { 1099 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1100 return ErrInvalidLength{"NameOfRepository", l.value, 1, 90} 1101 } 1102 *e = NameOfRepository(l.value) 1103 return nil 1104 } 1105 1106 // NameOfSourceData is a GEDCOM base type 1107 type NameOfSourceData string 1108 1109 func (e *NameOfSourceData) parse(l *Line, o options) error { 1110 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1111 return ErrInvalidLength{"NameOfSourceData", l.value, 1, 90} 1112 } 1113 *e = NameOfSourceData(l.value) 1114 return nil 1115 } 1116 1117 // NamePersonal is a GEDCOM base type 1118 type NamePersonal string 1119 1120 func (e *NamePersonal) parse(l *Line, o options) error { 1121 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1122 return ErrInvalidLength{"NamePersonal", l.value, 1, 120} 1123 } 1124 *e = NamePersonal(l.value) 1125 return nil 1126 } 1127 1128 // NamePiece is a GEDCOM base type 1129 type NamePiece string 1130 1131 func (e *NamePiece) parse(l *Line, o options) error { 1132 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1133 return ErrInvalidLength{"NamePiece", l.value, 1, 90} 1134 } 1135 *e = NamePiece(l.value) 1136 return nil 1137 } 1138 1139 // NamePieceGiven is a GEDCOM base type 1140 type NamePieceGiven string 1141 1142 func (e *NamePieceGiven) parse(l *Line, o options) error { 1143 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1144 return ErrInvalidLength{"NamePieceGiven", l.value, 1, 120} 1145 } 1146 *e = NamePieceGiven(l.value) 1147 return nil 1148 } 1149 1150 // NamePieceNickname is a GEDCOM base type 1151 type NamePieceNickname string 1152 1153 func (e *NamePieceNickname) parse(l *Line, o options) error { 1154 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 30) { 1155 return ErrInvalidLength{"NamePieceNickname", l.value, 1, 30} 1156 } 1157 *e = NamePieceNickname(l.value) 1158 return nil 1159 } 1160 1161 // NamePiecePrefix is a GEDCOM base type 1162 type NamePiecePrefix string 1163 1164 func (e *NamePiecePrefix) parse(l *Line, o options) error { 1165 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 30) { 1166 return ErrInvalidLength{"NamePiecePrefix", l.value, 1, 30} 1167 } 1168 *e = NamePiecePrefix(l.value) 1169 return nil 1170 } 1171 1172 // NamePieceSuffix is a GEDCOM base type 1173 type NamePieceSuffix string 1174 1175 func (e *NamePieceSuffix) parse(l *Line, o options) error { 1176 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 30) { 1177 return ErrInvalidLength{"NamePieceSuffix", l.value, 1, 30} 1178 } 1179 *e = NamePieceSuffix(l.value) 1180 return nil 1181 } 1182 1183 // NamePieceSurname is a GEDCOM base type 1184 type NamePieceSurname string 1185 1186 func (e *NamePieceSurname) parse(l *Line, o options) error { 1187 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1188 return ErrInvalidLength{"NamePieceSurname", l.value, 1, 120} 1189 } 1190 *e = NamePieceSurname(l.value) 1191 return nil 1192 } 1193 1194 // NamePieceSurnamePrefix is a GEDCOM base type 1195 type NamePieceSurnamePrefix string 1196 1197 func (e *NamePieceSurnamePrefix) parse(l *Line, o options) error { 1198 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 30) { 1199 return ErrInvalidLength{"NamePieceSurnamePrefix", l.value, 1, 30} 1200 } 1201 *e = NamePieceSurnamePrefix(l.value) 1202 return nil 1203 } 1204 1205 // NationalIDNumber is a GEDCOM base type 1206 type NationalIDNumber string 1207 1208 func (e *NationalIDNumber) parse(l *Line, o options) error { 1209 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 30) { 1210 return ErrInvalidLength{"NationalIDNumber", l.value, 1, 30} 1211 } 1212 *e = NationalIDNumber(l.value) 1213 return nil 1214 } 1215 1216 // NationalOrTribalOrigin is a GEDCOM base type 1217 type NationalOrTribalOrigin string 1218 1219 func (e *NationalOrTribalOrigin) parse(l *Line, o options) error { 1220 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1221 return ErrInvalidLength{"NationalOrTribalOrigin", l.value, 1, 120} 1222 } 1223 *e = NationalOrTribalOrigin(l.value) 1224 return nil 1225 } 1226 1227 // NewTag is a GEDCOM base type 1228 type NewTag string 1229 1230 func (e *NewTag) parse(l *Line, o options) error { 1231 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 15) { 1232 return ErrInvalidLength{"NewTag", l.value, 1, 15} 1233 } 1234 *e = NewTag(l.value) 1235 return nil 1236 } 1237 1238 // NobilityTypeTitle is a GEDCOM base type 1239 type NobilityTypeTitle string 1240 1241 func (e *NobilityTypeTitle) parse(l *Line, o options) error { 1242 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1243 return ErrInvalidLength{"NobilityTypeTitle", l.value, 1, 120} 1244 } 1245 *e = NobilityTypeTitle(l.value) 1246 return nil 1247 } 1248 1249 // Number is a GEDCOM base type 1250 type Number uint 1251 1252 func (e *Number) parse(l *Line, o options) error { 1253 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 9) { 1254 return ErrInvalidLength{"Number", l.value, 1, 9} 1255 } 1256 n, err := strconv.ParseUint(l.value, 10, 0) 1257 if !o.ignoreInvalidValue && err != nil { 1258 return err 1259 } 1260 *e = Number(n) 1261 return nil 1262 } 1263 1264 // Occupation is a GEDCOM base type 1265 type Occupation string 1266 1267 func (e *Occupation) parse(l *Line, o options) error { 1268 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1269 return ErrInvalidLength{"Occupation", l.value, 1, 90} 1270 } 1271 *e = Occupation(l.value) 1272 return nil 1273 } 1274 1275 // OrdinanceProcessFlag is a GEDCOM base type 1276 type OrdinanceProcessFlag string 1277 1278 func (e *OrdinanceProcessFlag) parse(l *Line, o options) error { 1279 switch strings.ToLower(l.value) { 1280 case cyes: 1281 *e = cyes 1282 case cno: 1283 *e = cno 1284 default: 1285 if !o.ignoreInvalidValue { 1286 return ErrInvalidValue{"OrdinanceProcessFlag", l.value} 1287 } 1288 } 1289 return nil 1290 } 1291 1292 // PedigreeLinkageType is a GEDCOM base type 1293 type PedigreeLinkageType string 1294 1295 func (e *PedigreeLinkageType) parse(l *Line, o options) error { 1296 switch strings.ToLower(l.value) { 1297 case cadopted: 1298 *e = cadopted 1299 case cbirth: 1300 *e = cbirth 1301 case cfoster: 1302 *e = cfoster 1303 case csealing: 1304 *e = csealing 1305 default: 1306 if !o.ignoreInvalidValue { 1307 return ErrInvalidValue{"PedigreeLinkageType", l.value} 1308 } 1309 } 1310 return nil 1311 } 1312 1313 // PermanentRecordFileNumber is a GEDCOM base type 1314 type PermanentRecordFileNumber string 1315 1316 func (e *PermanentRecordFileNumber) parse(l *Line, o options) error { 1317 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1318 return ErrInvalidLength{"PermanentRecordFileNumber", l.value, 1, 90} 1319 } 1320 *e = PermanentRecordFileNumber(l.value) 1321 return nil 1322 } 1323 1324 // PhoneNumber is a GEDCOM base type 1325 type PhoneNumber string 1326 1327 func (e *PhoneNumber) parse(l *Line, o options) error { 1328 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 25) { 1329 return ErrInvalidLength{"PhoneNumber", l.value, 1, 25} 1330 } 1331 *e = PhoneNumber(l.value) 1332 return nil 1333 } 1334 1335 // PhysicalDescription is a GEDCOM base type 1336 type PhysicalDescription string 1337 1338 func (e *PhysicalDescription) parse(l *Line, o options) error { 1339 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1340 return ErrInvalidLength{"PhysicalDescription", l.value, 1, 248} 1341 } 1342 *e = PhysicalDescription(l.value) 1343 return nil 1344 } 1345 1346 // PlaceHierarchy is a GEDCOM base type 1347 type PlaceHierarchy string 1348 1349 func (e *PlaceHierarchy) parse(l *Line, o options) error { 1350 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1351 return ErrInvalidLength{"PlaceHierarchy", l.value, 1, 120} 1352 } 1353 *e = PlaceHierarchy(l.value) 1354 return nil 1355 } 1356 1357 // PlaceLivingOrdinance is a GEDCOM base type 1358 type PlaceLivingOrdinance string 1359 1360 func (e *PlaceLivingOrdinance) parse(l *Line, o options) error { 1361 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1362 return ErrInvalidLength{"PlaceLivingOrdinance", l.value, 1, 120} 1363 } 1364 *e = PlaceLivingOrdinance(l.value) 1365 return nil 1366 } 1367 1368 // PlaceValue is a GEDCOM base type 1369 type PlaceValue string 1370 1371 func (e *PlaceValue) parse(l *Line, o options) error { 1372 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1373 return ErrInvalidLength{"PlaceValue", l.value, 1, 120} 1374 } 1375 *e = PlaceValue(l.value) 1376 return nil 1377 } 1378 1379 // Possessions is a GEDCOM base type 1380 type Possessions string 1381 1382 func (e *Possessions) parse(l *Line, o options) error { 1383 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1384 return ErrInvalidLength{"Possessions", l.value, 1, 248} 1385 } 1386 *e = Possessions(l.value) 1387 return nil 1388 } 1389 1390 // PublicationDate is a GEDCOM base type 1391 type PublicationDate string 1392 1393 func (e *PublicationDate) parse(l *Line, o options) error { 1394 if !o.allowWrongLength && (len(l.value) < 10 || len(l.value) > 11) { 1395 return ErrInvalidLength{"PublicationDate", l.value, 10, 11} 1396 } 1397 *e = PublicationDate(l.value) 1398 return nil 1399 } 1400 1401 // ReceivingSystemName is a GEDCOM base type 1402 type ReceivingSystemName string 1403 1404 func (e *ReceivingSystemName) parse(l *Line, o options) error { 1405 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 20) { 1406 return ErrInvalidLength{"ReceivingSystemName", l.value, 1, 20} 1407 } 1408 *e = ReceivingSystemName(l.value) 1409 return nil 1410 } 1411 1412 // RecordIdentifier is a GEDCOM base type 1413 type RecordIdentifier string 1414 1415 func (e *RecordIdentifier) parse(l *Line, o options) error { 1416 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 18) { 1417 return ErrInvalidLength{"RecordIdentifier", l.value, 1, 18} 1418 } 1419 *e = RecordIdentifier(l.value) 1420 return nil 1421 } 1422 1423 // RecordType is a GEDCOM base type 1424 type RecordType string 1425 1426 func (e *RecordType) parse(l *Line, o options) error { 1427 switch strings.ToUpper(l.value) { 1428 case cFAM: 1429 *e = cFAM 1430 case cINDI: 1431 *e = cINDI 1432 case cNOTE: 1433 *e = cNOTE 1434 case cOBJE: 1435 *e = cOBJE 1436 case cREPO: 1437 *e = cREPO 1438 case cSOUR: 1439 *e = cSOUR 1440 case cSUBM: 1441 *e = cSUBM 1442 case cSUBN: 1443 *e = cSUBN 1444 default: 1445 if !o.ignoreInvalidValue { 1446 return ErrInvalidValue{"RecordType", l.value} 1447 } 1448 } 1449 return nil 1450 } 1451 1452 // RegisteredResourceIdentifier is a GEDCOM base type 1453 type RegisteredResourceIdentifier string 1454 1455 func (e *RegisteredResourceIdentifier) parse(l *Line, o options) error { 1456 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 25) { 1457 return ErrInvalidLength{"RegisteredResourceIdentifier", l.value, 1, 25} 1458 } 1459 *e = RegisteredResourceIdentifier(l.value) 1460 return nil 1461 } 1462 1463 // RelationIsDescriptor is a GEDCOM base type 1464 type RelationIsDescriptor string 1465 1466 func (e *RelationIsDescriptor) parse(l *Line, o options) error { 1467 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 25) { 1468 return ErrInvalidLength{"RelationIsDescriptor", l.value, 1, 25} 1469 } 1470 *e = RelationIsDescriptor(l.value) 1471 return nil 1472 } 1473 1474 // ReligiousAffiliation is a GEDCOM base type 1475 type ReligiousAffiliation string 1476 1477 func (e *ReligiousAffiliation) parse(l *Line, o options) error { 1478 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 90) { 1479 return ErrInvalidLength{"ReligiousAffiliation", l.value, 1, 90} 1480 } 1481 *e = ReligiousAffiliation(l.value) 1482 return nil 1483 } 1484 1485 // ResponsibleAgency is a GEDCOM base type 1486 type ResponsibleAgency string 1487 1488 func (e *ResponsibleAgency) parse(l *Line, o options) error { 1489 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1490 return ErrInvalidLength{"ResponsibleAgency", l.value, 1, 120} 1491 } 1492 *e = ResponsibleAgency(l.value) 1493 return nil 1494 } 1495 1496 // RestrictionNotice is a GEDCOM base type 1497 type RestrictionNotice string 1498 1499 func (e *RestrictionNotice) parse(l *Line, o options) error { 1500 switch strings.ToLower(l.value) { 1501 case clocked: 1502 *e = clocked 1503 case cprivacy: 1504 *e = cprivacy 1505 default: 1506 if !o.ignoreInvalidValue { 1507 return ErrInvalidValue{"RestrictionNotice", l.value} 1508 } 1509 } 1510 return nil 1511 } 1512 1513 // RoleDescriptor is a GEDCOM base type 1514 type RoleDescriptor string 1515 1516 func (e *RoleDescriptor) parse(l *Line, o options) error { 1517 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 25) { 1518 return ErrInvalidLength{"RoleDescriptor", l.value, 1, 25} 1519 } 1520 *e = RoleDescriptor(l.value) 1521 return nil 1522 } 1523 1524 // RoleInEvent is a GEDCOM base type 1525 type RoleInEvent string 1526 1527 func (e *RoleInEvent) parse(l *Line, o options) error { 1528 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 15) { 1529 return ErrInvalidLength{"RoleInEvent", l.value, 1, 15} 1530 } 1531 *e = RoleInEvent(l.value) 1532 return nil 1533 } 1534 1535 // ScholasticAchievement is a GEDCOM base type 1536 type ScholasticAchievement string 1537 1538 func (e *ScholasticAchievement) parse(l *Line, o options) error { 1539 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1540 return ErrInvalidLength{"ScholasticAchievement", l.value, 1, 248} 1541 } 1542 *e = ScholasticAchievement(l.value) 1543 return nil 1544 } 1545 1546 // SexValue is a GEDCOM base type 1547 type SexValue string 1548 1549 func (e *SexValue) parse(l *Line, o options) error { 1550 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 7) { 1551 return ErrInvalidLength{"SexValue", l.value, 1, 7} 1552 } 1553 *e = SexValue(l.value) 1554 return nil 1555 } 1556 1557 // SocialSecurityNumber is a GEDCOM base type 1558 type SocialSecurityNumber string 1559 1560 func (e *SocialSecurityNumber) parse(l *Line, o options) error { 1561 if !o.allowWrongLength && (len(l.value) < 9 || len(l.value) > 11) { 1562 return ErrInvalidLength{"SocialSecurityNumber", l.value, 9, 11} 1563 } 1564 *e = SocialSecurityNumber(l.value) 1565 return nil 1566 } 1567 1568 // SourceCallNumber is a GEDCOM base type 1569 type SourceCallNumber string 1570 1571 func (e *SourceCallNumber) parse(l *Line, o options) error { 1572 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1573 return ErrInvalidLength{"SourceCallNumber", l.value, 1, 120} 1574 } 1575 *e = SourceCallNumber(l.value) 1576 return nil 1577 } 1578 1579 // SourceDescription is a GEDCOM base type 1580 type SourceDescription string 1581 1582 func (e *SourceDescription) parse(l *Line, o options) error { 1583 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1584 return ErrInvalidLength{"SourceDescription", l.value, 1, 248} 1585 } 1586 *e = SourceDescription(l.value) 1587 for i := 0; i < len(l.Sub); i++ { 1588 switch l.Sub[i].tag { 1589 case cCONT: 1590 *e += "\n" 1591 fallthrough 1592 case cCONC: 1593 if !o.allowWrongLength && (len(l.Sub[i].value) < 1 || len(l.Sub[i].value) > 248) { 1594 return ErrContext{"SourceDescription", l.Sub[i].tag, ErrInvalidLength{"SourceDescription", l.value, 1, 248}} 1595 } 1596 *e += SourceDescription(l.Sub[i].value) 1597 copy(l.Sub[i:], l.Sub[i+1:]) 1598 l.Sub = l.Sub[:len(l.Sub)-1] 1599 i-- 1600 } 1601 } 1602 return nil 1603 } 1604 1605 // SourceDescriptiveTitle is a GEDCOM base type 1606 type SourceDescriptiveTitle string 1607 1608 func (e *SourceDescriptiveTitle) parse(l *Line, o options) error { 1609 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1610 return ErrInvalidLength{"SourceDescriptiveTitle", l.value, 1, 248} 1611 } 1612 *e = SourceDescriptiveTitle(l.value) 1613 for i := 0; i < len(l.Sub); i++ { 1614 switch l.Sub[i].tag { 1615 case cCONT: 1616 *e += "\n" 1617 fallthrough 1618 case cCONC: 1619 if !o.allowWrongLength && (len(l.Sub[i].value) < 1 || len(l.Sub[i].value) > 248) { 1620 return ErrContext{"SourceDescriptiveTitle", l.Sub[i].tag, ErrInvalidLength{"SourceDescriptiveTitle", l.value, 1, 248}} 1621 } 1622 *e += SourceDescriptiveTitle(l.Sub[i].value) 1623 copy(l.Sub[i:], l.Sub[i+1:]) 1624 l.Sub = l.Sub[:len(l.Sub)-1] 1625 i-- 1626 } 1627 } 1628 return nil 1629 } 1630 1631 // SourceFiledByEntry is a GEDCOM base type 1632 type SourceFiledByEntry string 1633 1634 func (e *SourceFiledByEntry) parse(l *Line, o options) error { 1635 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 1636 return ErrInvalidLength{"SourceFiledByEntry", l.value, 1, 60} 1637 } 1638 *e = SourceFiledByEntry(l.value) 1639 return nil 1640 } 1641 1642 // SourceJurisdictionPlace is a GEDCOM base type 1643 type SourceJurisdictionPlace string 1644 1645 func (e *SourceJurisdictionPlace) parse(l *Line, o options) error { 1646 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 120) { 1647 return ErrInvalidLength{"SourceJurisdictionPlace", l.value, 1, 120} 1648 } 1649 *e = SourceJurisdictionPlace(l.value) 1650 return nil 1651 } 1652 1653 // SourceMediaType is a GEDCOM base type 1654 type SourceMediaType string 1655 1656 func (e *SourceMediaType) parse(l *Line, o options) error { 1657 switch strings.ToLower(l.value) { 1658 case caudio: 1659 *e = caudio 1660 case cbook: 1661 *e = cbook 1662 case ccard: 1663 *e = ccard 1664 case celectronic: 1665 *e = celectronic 1666 case cfiche: 1667 *e = cfiche 1668 case cfilm: 1669 *e = cfilm 1670 case cmagazine: 1671 *e = cmagazine 1672 case cmanuscript: 1673 *e = cmanuscript 1674 case cmap: 1675 *e = cmap 1676 case cnewspaper: 1677 *e = cnewspaper 1678 case cphoto: 1679 *e = cphoto 1680 case ctombstone: 1681 *e = ctombstone 1682 case cvideo: 1683 *e = cvideo 1684 default: 1685 if !o.ignoreInvalidValue { 1686 return ErrInvalidValue{"SourceMediaType", l.value} 1687 } 1688 } 1689 return nil 1690 } 1691 1692 // SourceOriginator is a GEDCOM base type 1693 type SourceOriginator string 1694 1695 func (e *SourceOriginator) parse(l *Line, o options) error { 1696 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1697 return ErrInvalidLength{"SourceOriginator", l.value, 1, 248} 1698 } 1699 *e = SourceOriginator(l.value) 1700 for i := 0; i < len(l.Sub); i++ { 1701 switch l.Sub[i].tag { 1702 case cCONT: 1703 *e += "\n" 1704 fallthrough 1705 case cCONC: 1706 if !o.allowWrongLength && (len(l.Sub[i].value) < 1 || len(l.Sub[i].value) > 248) { 1707 return ErrContext{"SourceOriginator", l.Sub[i].tag, ErrInvalidLength{"SourceOriginator", l.value, 1, 248}} 1708 } 1709 *e += SourceOriginator(l.Sub[i].value) 1710 copy(l.Sub[i:], l.Sub[i+1:]) 1711 l.Sub = l.Sub[:len(l.Sub)-1] 1712 i-- 1713 } 1714 } 1715 return nil 1716 } 1717 1718 // SourcePublicationFacts is a GEDCOM base type 1719 type SourcePublicationFacts string 1720 1721 func (e *SourcePublicationFacts) parse(l *Line, o options) error { 1722 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1723 return ErrInvalidLength{"SourcePublicationFacts", l.value, 1, 248} 1724 } 1725 *e = SourcePublicationFacts(l.value) 1726 return nil 1727 } 1728 1729 // SubmitterName is a GEDCOM base type 1730 type SubmitterName string 1731 1732 func (e *SubmitterName) parse(l *Line, o options) error { 1733 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 60) { 1734 return ErrInvalidLength{"SubmitterName", l.value, 1, 60} 1735 } 1736 *e = SubmitterName(l.value) 1737 return nil 1738 } 1739 1740 // SubmitterRegisteredRFN is a GEDCOM base type 1741 type SubmitterRegisteredRFN string 1742 1743 func (e *SubmitterRegisteredRFN) parse(l *Line, o options) error { 1744 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 30) { 1745 return ErrInvalidLength{"SubmitterRegisteredRFN", l.value, 1, 30} 1746 } 1747 *e = SubmitterRegisteredRFN(l.value) 1748 return nil 1749 } 1750 1751 // SubmitterText is a GEDCOM base type 1752 type SubmitterText string 1753 1754 func (e *SubmitterText) parse(l *Line, o options) error { 1755 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1756 return ErrInvalidLength{"SubmitterText", l.value, 1, 248} 1757 } 1758 *e = SubmitterText(l.value) 1759 for i := 0; i < len(l.Sub); i++ { 1760 switch l.Sub[i].tag { 1761 case cCONT: 1762 *e += "\n" 1763 fallthrough 1764 case cCONC: 1765 if !o.allowWrongLength && (len(l.Sub[i].value) < 1 || len(l.Sub[i].value) > 248) { 1766 return ErrContext{"SubmitterText", l.Sub[i].tag, ErrInvalidLength{"SubmitterText", l.value, 1, 248}} 1767 } 1768 *e += SubmitterText(l.Sub[i].value) 1769 copy(l.Sub[i:], l.Sub[i+1:]) 1770 l.Sub = l.Sub[:len(l.Sub)-1] 1771 i-- 1772 } 1773 } 1774 return nil 1775 } 1776 1777 // TempleCode is a GEDCOM base type 1778 type TempleCode string 1779 1780 func (e *TempleCode) parse(l *Line, o options) error { 1781 if !o.allowWrongLength && (len(l.value) < 4 || len(l.value) > 5) { 1782 return ErrInvalidLength{"TempleCode", l.value, 4, 5} 1783 } 1784 *e = TempleCode(l.value) 1785 return nil 1786 } 1787 1788 // Text is a GEDCOM base type 1789 type Text string 1790 1791 func (e *Text) parse(l *Line, o options) error { 1792 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1793 return ErrInvalidLength{"Text", l.value, 1, 248} 1794 } 1795 *e = Text(l.value) 1796 return nil 1797 } 1798 1799 // TextFromSource is a GEDCOM base type 1800 type TextFromSource string 1801 1802 func (e *TextFromSource) parse(l *Line, o options) error { 1803 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1804 return ErrInvalidLength{"TextFromSource", l.value, 1, 248} 1805 } 1806 *e = TextFromSource(l.value) 1807 for i := 0; i < len(l.Sub); i++ { 1808 switch l.Sub[i].tag { 1809 case cCONT: 1810 *e += "\n" 1811 fallthrough 1812 case cCONC: 1813 if !o.allowWrongLength && (len(l.Sub[i].value) < 1 || len(l.Sub[i].value) > 248) { 1814 return ErrContext{"TextFromSource", l.Sub[i].tag, ErrInvalidLength{"TextFromSource", l.value, 1, 248}} 1815 } 1816 *e += TextFromSource(l.Sub[i].value) 1817 copy(l.Sub[i:], l.Sub[i+1:]) 1818 l.Sub = l.Sub[:len(l.Sub)-1] 1819 i-- 1820 } 1821 } 1822 return nil 1823 } 1824 1825 // TimeValue is a GEDCOM base type 1826 type TimeValue string 1827 1828 func (e *TimeValue) parse(l *Line, o options) error { 1829 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 12) { 1830 return ErrInvalidLength{"TimeValue", l.value, 1, 12} 1831 } 1832 *e = TimeValue(l.value) 1833 return nil 1834 } 1835 1836 // TransmissionDate is a GEDCOM base type 1837 type TransmissionDate string 1838 1839 func (e *TransmissionDate) parse(l *Line, o options) error { 1840 if !o.allowWrongLength && (len(l.value) < 10 || len(l.value) > 11) { 1841 return ErrInvalidLength{"TransmissionDate", l.value, 10, 11} 1842 } 1843 *e = TransmissionDate(l.value) 1844 return nil 1845 } 1846 1847 // UserReferenceNumber is a GEDCOM base type 1848 type UserReferenceNumber string 1849 1850 func (e *UserReferenceNumber) parse(l *Line, o options) error { 1851 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 20) { 1852 return ErrInvalidLength{"UserReferenceNumber", l.value, 1, 20} 1853 } 1854 *e = UserReferenceNumber(l.value) 1855 return nil 1856 } 1857 1858 // UserReferenceType is a GEDCOM base type 1859 type UserReferenceType string 1860 1861 func (e *UserReferenceType) parse(l *Line, o options) error { 1862 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 40) { 1863 return ErrInvalidLength{"UserReferenceType", l.value, 1, 40} 1864 } 1865 *e = UserReferenceType(l.value) 1866 return nil 1867 } 1868 1869 // Verified is a GEDCOM base type 1870 type Verified string 1871 1872 func (e *Verified) parse(l *Line, o options) error { 1873 switch strings.ToUpper(l.value) { 1874 case c: 1875 *e = c 1876 case cY: 1877 *e = cY 1878 default: 1879 if !o.ignoreInvalidValue { 1880 return ErrInvalidValue{"Verified", l.value} 1881 } 1882 } 1883 return nil 1884 } 1885 1886 // VersionNumber is a GEDCOM base type 1887 type VersionNumber string 1888 1889 func (e *VersionNumber) parse(l *Line, o options) error { 1890 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 15) { 1891 return ErrInvalidLength{"VersionNumber", l.value, 1, 15} 1892 } 1893 *e = VersionNumber(l.value) 1894 return nil 1895 } 1896 1897 // WhereWithinSource is a GEDCOM base type 1898 type WhereWithinSource string 1899 1900 func (e *WhereWithinSource) parse(l *Line, o options) error { 1901 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 248) { 1902 return ErrInvalidLength{"WhereWithinSource", l.value, 1, 248} 1903 } 1904 *e = WhereWithinSource(l.value) 1905 return nil 1906 } 1907 1908 // Xref is a GEDCOM base type 1909 type Xref string 1910 1911 func (e *Xref) parse(l *Line, o options) error { 1912 if !o.allowWrongLength && (len(l.value) < 1 || len(l.value) > 22) { 1913 return ErrInvalidLength{"Xref", l.value, 1, 22} 1914 } 1915 *e = Xref(l.value) 1916 return nil 1917 } 1918 1919 // Year is a GEDCOM base type 1920 type Year string 1921 1922 func (e *Year) parse(l *Line, o options) error { 1923 if !o.allowWrongLength && (len(l.value) < 3 || len(l.value) > 4) { 1924 return ErrInvalidLength{"Year", l.value, 3, 4} 1925 } 1926 *e = Year(l.value) 1927 return nil 1928 } 1929 1930 // YearGreg is a GEDCOM base type 1931 type YearGreg string 1932 1933 func (e *YearGreg) parse(l *Line, o options) error { 1934 if !o.allowWrongLength && (len(l.value) < 3 || len(l.value) > 7) { 1935 return ErrInvalidLength{"YearGreg", l.value, 3, 7} 1936 } 1937 *e = YearGreg(l.value) 1938 return nil 1939 } 1940 1941 // ErrInvalidValue is an error that is generated when a type is not one of the 1942 // specified values 1943 type ErrInvalidValue struct { 1944 Type, Value string 1945 } 1946 1947 // Error is an implementation of the error interface 1948 func (e ErrInvalidValue) Error() string { 1949 return "Value for " + e.Type + " is invalid" 1950 } 1951 1952 // ErrInvalidLength is an error that is generated when a type is given more or 1953 // less data than is required 1954 type ErrInvalidLength struct { 1955 Type, Value string 1956 Min, Max uint 1957 } 1958 1959 // Error is an implementation of the error interface 1960 func (e ErrInvalidLength) Error() string { 1961 return "Value for " + e.Type + " has an invalid length" 1962 } 1963