package neb::Tree::Container; use strict; use Carp; use neb::Tree::Node; our @ISA = ('neb::Tree::Node'); sub init { my $self = shift; $self->{CONTENT} = []; } sub add_content { my $self = shift; my $content = shift; push @{$self->{CONTENT}}, $content; $content->parent($self); $content->index($#{$self->{CONTENT}}); return @{$self->{CONTENT}}; } sub remove { my $self = shift; my $kid = shift; splice @{$self->{CONTENT}}, $kid->index, 1; } sub content { my $self = shift; $self->{CONTENT} = [ @_ ] if (@_); return wantarray ? @{$self->{CONTENT}} : $self->{CONTENT}; } sub canonical { my $self = shift; return join('', map($_->canonical, $self->content)); } sub code { my $self = shift; return join ('', map $_->code, $self->content); } 1;