Merge pull request #3380 from greyanubis/devel

Add proc to change an element tag and proc to insert xmlnode child
This commit is contained in:
Andreas Rumpf 2015-10-07 09:26:01 +02:00
commit 52342a11f6

View file

@ -104,10 +104,23 @@ proc tag*(n: XmlNode): string {.inline.} =
assert n.k == xnElement assert n.k == xnElement
result = n.fTag result = n.fTag
proc `tag=`*(n: XmlNode, tag: string) {.inline.} =
## sets the tag name of `n`. `n` has to be an ``xnElement`` node.
assert n.k == xnElement
n.fTag = tag
proc add*(father, son: XmlNode) {.inline.} = proc add*(father, son: XmlNode) {.inline.} =
## adds the child `son` to `father`. ## adds the child `son` to `father`.
add(father.s, son) add(father.s, son)
proc insert*(father, son: XmlNode, index: int) {.inline.} =
## insert the child `son` to a given position in `father`.
assert father.k == xnElement and son.k == xnElement
if len(father.s) > index:
insert(father.s, son, index)
else:
insert(father.s, son, len(father.s))
proc len*(n: XmlNode): int {.inline.} = proc len*(n: XmlNode): int {.inline.} =
## returns the number `n`'s children. ## returns the number `n`'s children.
if n.k == xnElement: result = len(n.s) if n.k == xnElement: result = len(n.s)