ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/TemplateStash.pm
Revision: 1.2
Committed: Fri Jan 14 17:41:28 2011 UTC (14 years, 3 months ago) by muzaffar
Content type: text/plain
Branch: MAIN
CVS Tags: V2_2_5_pre2, V2_2_5_pre1, V2_2_4, V2_2_4_pre9, V2_2_4_pre8, V2_2_4_pre7, V2_2_4_pre6, V2_2_4_pre5, V2_2_4_pre4, V2_2_4_pre3, V2_2_4_pre2, V2_2_4_pre1, V2_2_3, forV2_2_3, HEAD
Changes since 1.1: +59 -0 lines
Error occurred while calculating annotation data.
Log Message:
merged new files from SCRAM_V2 branch

File Contents

# Content
1 package BuildSystem::TemplateStash;
2 require 5.004;
3 use Exporter;
4 @ISA=qw(Exporter);
5
6 sub new()
7 {
8 my $class=shift;
9 my $self={};
10 $self->{stash}[0]={};
11 $self->{index}=0;
12 bless($self, $class);
13 return $self;
14 }
15
16 sub pushstash ()
17 {
18 my $self=shift;
19 push @{$self->{stash}},{};
20 $self->{index}=$self->{index}+1;
21 }
22
23 sub popstash ()
24 {
25 my $self=shift;
26 if($self->{index}>0){pop @{$self->{stash}};$self->{index}=$self->{index}-1;}
27 }
28
29 sub stash()
30 {
31 my $self=shift;
32 my ($stash)=@_;
33 if($stash)
34 {
35 $self->{stash}=[];
36 $self->{stash}[0]=$stash;
37 $self->{index}=0;
38 }
39 else{return $self;}
40 }
41
42 sub set()
43 {
44 my $self=shift;
45 my $key=shift || return;
46 my $c=$self->{index};
47 $self->{stash}[$c]{$key}=shift;
48 }
49
50 sub get()
51 {
52 my $self=shift;
53 my $key=shift || return "";
54 my $c=$self->{index};
55 for(my $i=$c;$i>=0;$i--){if(exists $self->{stash}[$i]{$key}){return $self->{stash}[$i]{$key};}}
56 return "";
57 }
58
59 1;