-
Notifications
You must be signed in to change notification settings - Fork 19
/
child_node.go
45 lines (35 loc) 路 1.04 KB
/
child_node.go
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
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 {
n := node.family.document.NodeByPointer(valueToPointer(node.value))
// TODO: may not exist
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()
}