ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/UserQuery.pm
(Generate patch)

Comparing COMP/SCRAM/src/ActiveDoc/UserQuery.pm (file contents):
Revision 1.3 by williamc, Thu Sep 23 10:35:02 1999 UTC vs.
Revision 1.4 by williamc, Mon Oct 25 15:09:21 1999 UTC

# Line 1 | Line 1
1   #
2   #  UserQuery
3   #
4 < #  Set up and record Queries requested fromthe user
4 > #  Set up and record Queries requested from the user
5   #
6   # Interface
7   # ---------
8   # new(UserInterface)    : A new query object with a specific interface
9 + # dump(fh,expr)         : dump out parameters that match expr to filehandle
10 + # store(fh)             : dump every param to fh
11 + # restore(fh)           : restore from filehandle
12 + # params()              : return list of all params
13   # setparam(name,value)  : set a parameter
14   # setifundef(name,value) : only set param to value if undefined
15   # getparam(name)        : return value of named parameter
# Line 33 | Line 37 | sub new {
37          return $self;
38   }
39  
40 + sub dump {
41 +        my $self=shift;
42 +        my $fh=shift;
43 +        my $string=shift;
44 +
45 +        foreach $key ( %{$self->{params}} ) {
46 +          if ( $key=~/$string/ ) {
47 +                print $fh "k:".$key."\n";
48 +                print $fh "v:".$$self->{params}{$key}."\n";
49 +          }
50 +        }
51 +        print $fh "#End\n";
52 + }
53 +
54 + sub store {
55 +        my $self=shift;
56 +        my $fh=shift;
57 +
58 +        my $key;
59 +        foreach $key ( keys %{$self->{params}} ) {
60 +          print "$fh $key\n";
61 +          print $fh "k:".$key."\n";
62 +          print $fh "v:".$self->{params}{$key}."\n";
63 +        }
64 +        print $fh "#End\n";
65 + }
66 +
67 + sub restore {
68 +        my $self=shift;
69 +        my $fh=shift;
70 +
71 +        my $check="k:";
72 +        my $key="";
73 +        while ( $line=<$fh> ) {
74 +          chomp $line;
75 +          last if ( $line eq "\#End" );
76 +          if ( $line!~/^$check/ ) {
77 +                die "Data Corruption Error when restoring $self\n";
78 +          }
79 +          if ( $check eq "k:" ) {
80 +                $check="v:";
81 +                ($key=$line)=~s/k://;
82 +          }
83 +          else {
84 +                $check="k:";
85 +                ($value=$line)=~s/v://;
86 +                $self->setparam($key,$value);
87 +          }
88 +        } #end while
89 + }
90 +
91   sub setparam {
92          my $self=shift;
93          my $name=shift;
94          my $value=shift;
95  
96 +        print "Setting $name = $value\n";
97          $self->{params}{$name}=$value;
98   }
99  
100 + sub params {
101 +        my $self=shift;
102 +        
103 +        return ( keys %{$self->{params}} );
104 + }
105 +
106   sub setifundef {
107          my $self=shift;
108          my $name=shift;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines