-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathchild_node.go
More file actions
52 lines (40 loc) · 1.08 KB
/
child_node.go
File metadata and controls
52 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package gedcom
import "fmt"
// ChildNode is the natural, adopted, or sealed (LDS) child of a father and a
// mother.
type ChildNode struct {
*SimpleNode
family *FamilyNode
}
func newChildNode(family *FamilyNode, value string, children ...Node) *ChildNode {
return &ChildNode{
newSimpleNode(TagChild, value, "", children...),
family,
}
}
func newChildNodeWithIndividual(family *FamilyNode, individual *IndividualNode) *ChildNode {
// TODO: check individual belongs to the same document as family
return newChildNode(family, fmt.Sprintf("@%s@", individual.Pointer()))
}
func (node *ChildNode) Family() *FamilyNode {
return node.family
}
func (node *ChildNode) Individual() *IndividualNode {
if node == nil {
return nil
}
n := node.family.document.NodeByPointer(valueToPointer(node.value))
if IsNil(n) {
return nil
}
return n.(*IndividualNode)
}
func (node *ChildNode) Father() *HusbandNode {
return node.family.Husband()
}
func (node *ChildNode) Mother() *WifeNode {
return node.family.Wife()
}
func (node *ChildNode) String() string {
return node.Individual().String()
}