/[libconf]/libconf/perl-Libconf/Glueconf/Ups.pm
ViewVC logotype

Diff of /libconf/perl-Libconf/Glueconf/Ups.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by tv, Thu Nov 27 09:38:17 2003 UTC revision 1.5 by tv, Thu Nov 27 10:23:46 2003 UTC
# Line 37  sub new { Line 37  sub new {
37          $data_mapping = $data_synopsis->{$o_data_synopsis_version}{mapping};          $data_mapping = $data_synopsis->{$o_data_synopsis_version}{mapping};
38      }      }
39      my $libconf = Libconf::new('Libconf', $filename, 'ups', '');      my $libconf = Libconf::new('Libconf', $filename, 'ups', '');
40      $libconf->setUniq();      $libconf->setUniq;
41      tie my %wrapper, 'Libconf::Glueconf::Ups::Wrapper', $libconf, $data_description, $data_mapping ;      tie my %wrapper, 'Libconf::Glueconf::Ups::Wrapper', $libconf, $data_description, $data_mapping;
42      bless \%wrapper, $class;      bless \%wrapper, $class;
43  }  }
44    
45  sub readConf {  sub readConf {
46      my ($obj) = @_;      my ($obj) = @_;
47      $obj->{libconf}->readConf();      $obj->{libconf}->readConf;
48  }  }
49    
50  sub writeConf {  sub writeConf {
51      my ($obj) = @_;      my ($obj) = @_;
52      $obj->{libconf}->writeConf();      $obj->{libconf}->writeConf;
53  }  }
54    
55    
# Line 70  sub TIEHASH { Line 70  sub TIEHASH {
70  sub CLEAR {  sub CLEAR {
71      my ($obj) = @_;      my ($obj) = @_;
72      debug();      debug();
73      $obj->{libconf}->clear();      $obj->{libconf}->clear;
74  }  }
75    
76  #sub DESTROY {  #sub DESTROY {
# Line 124  sub STORE { Line 124  sub STORE {
124      ref $value eq 'HASH' or die 'trying to store something else than hash ref';      ref $value eq 'HASH' or die 'trying to store something else than hash ref';
125      my $index;      my $index;
126      my $pos = $obj->{libconf}->findAtomPos({ type => 'SECTION', section_name => $key, sections => [] });      my $pos = $obj->{libconf}->findAtomPos({ type => 'SECTION', section_name => $key, sections => [] });
127      defined $pos or $pos = $obj->{libconf}->appendAtom({ section_name => $key, type => 'SECTION', sections => [ ] });      defined $pos or $pos = $obj->{libconf}->appendAtom({ section_name => $key, type => 'SECTION', sections => [] });
128      my %hash;      my %hash;
129      tie %hash, 'Libconf::Glueconf::Ups::SectionWrapper', $obj->{libconf}, $pos;      tie %hash, 'Libconf::Glueconf::Ups::SectionWrapper', $obj->{libconf}, $pos;
130      %hash = %$value;      %hash = %$value;
# Line 135  sub FETCH { Line 135  sub FETCH {
135      debug("key : $key");      debug("key : $key");
136      $key eq 'libconf' and return $obj->{libconf};      $key eq 'libconf' and return $obj->{libconf};
137      substr($key, 0, 1) eq '_' and return $obj->{$key};      substr($key, 0, 1) eq '_' and return $obj->{$key};
138      my $section_position = $obj->{libconf}->findAtomPos( { type => 'SECTION', section_name => $key, sections => [ ] });      my $section_position = $obj->{libconf}->findAtomPos( { type => 'SECTION', section_name => $key, sections => [] });
139      defined $section_position or $section_position = $obj->{libconf}->appendAtom({ section_name => $key, type => 'SECTION', sections => [ ] });      defined $section_position or $section_position = $obj->{libconf}->appendAtom({ section_name => $key, type => 'SECTION', sections => [] });
140      my %ret;      my %ret;
141      tie %ret, 'Libconf::Glueconf::Ups::SectionWrapper', $obj->{libconf}, $section_position;      tie %ret, 'Libconf::Glueconf::Ups::SectionWrapper', $obj->{libconf}, $section_position;
142      \%ret;      \%ret;
# Line 155  sub TIEHASH { Line 155  sub TIEHASH {
155      push @depth, { name => $atom->{section_name} };      push @depth, { name => $atom->{section_name} };
156    
157      my $key = $beginning+1;      my $key = $beginning+1;
158      foreach ($beginning+1..$libconf->size()-1) {      foreach ($beginning+1..$libconf->size-1) {
159          my $atom = $libconf->getAtom($_);          my $atom = $libconf->getAtom($_);
160          @{$atom->{sections}} >= @depth and next;          @{$atom->{sections}} >= @depth and next;
161          Libconf::compare_depth($atom->{sections}, \@depth) or last;          Libconf::compare_depth($atom->{sections}, \@depth) or last;
# Line 182  sub CLEAR { Line 182  sub CLEAR {
182  sub DELETE {  sub DELETE {
183      my ($obj, $key) = @_;      my ($obj, $key) = @_;
184      debug("key : $key");      debug("key : $key");
185      my @pos = $obj->{libconf}->findAtomPos( {type => 'KEY_VALUE', key => $key },      my @pos = $obj->{libconf}->findAtomPos({ type => 'KEY_VALUE', key => $key },
186                                              $obj->{firstatom}+1, $obj->{lastatom}-1                                              $obj->{firstatom}+1, $obj->{lastatom}-1
187                                            );                                            );
188      foreach (@pos) {      foreach (@pos) {
# Line 203  sub FIRSTKEY { Line 203  sub FIRSTKEY {
203  sub EXISTS {  sub EXISTS {
204      my ($obj, $key) = @_;      my ($obj, $key) = @_;
205      debug("key : $key");      debug("key : $key");
206      my $pos = $obj->{libconf}->findAtomPos( {type => 'KEY_VALUE', key => $key },      my $pos = $obj->{libconf}->findAtomPos({ type => 'KEY_VALUE', key => $key },
207                                              $obj->{firstatom}+1, $obj->{lastatom}-1                                              $obj->{firstatom}+1, $obj->{lastatom}-1
208                                            );                                            );
209      defined $pos ? 1 : 0;      defined $pos ? 1 : 0;
# Line 212  sub EXISTS { Line 212  sub EXISTS {
212  sub NEXTKEY {  sub NEXTKEY {
213      my ($obj, $lastkey) = @_;      my ($obj, $lastkey) = @_;
214      debug("SectionWrapper - NEXTKEY - lastkey : $lastkey");      debug("SectionWrapper - NEXTKEY - lastkey : $lastkey");
215      my $pos = $obj->{libconf}->findAtomPos( {type => 'KEY_VALUE', key => $lastkey },      my $pos = $obj->{libconf}->findAtomPos({ type => 'KEY_VALUE', key => $lastkey },
216                                              $obj->{firstatom}+1, $obj->{lastatom}-1                                              $obj->{firstatom}+1, $obj->{lastatom}-1
217                                            );                                            );
218      !defined $pos || $pos+1 == $obj->{lastatom} and return undef;      !defined $pos || $pos+1 == $obj->{lastatom} and return undef;
# Line 224  sub STORE { Line 224  sub STORE {
224      debug("key : $key - value : $value");      debug("key : $key - value : $value");
225      #ref $value eq 'HASH' or die 'trying to store anything else than hash ref';      #ref $value eq 'HASH' or die 'trying to store anything else than hash ref';
226      ref $value eq '' or die "try to store a hash in a kery_value atom";      ref $value eq '' or die "try to store a hash in a kery_value atom";
227      my $pos = $obj->{libconf}->findAtomPos( {type => 'KEY_VALUE', key => $key },      my $pos = $obj->{libconf}->findAtomPos({ type => 'KEY_VALUE', key => $key },
228                                              $obj->{firstatom}+1, $obj->{lastatom}-1                                              $obj->{firstatom}+1, $obj->{lastatom}-1
229                                            );                                            );
230      if (!defined $pos) {      if (!defined $pos) {
# Line 240  sub STORE { Line 240  sub STORE {
240  sub FETCH {  sub FETCH {
241      my ($obj, $key) = @_;      my ($obj, $key) = @_;
242      debug("key : $key\n");      debug("key : $key\n");
243      my $pos = $obj->{libconf}->findAtomPos( {type => 'KEY_VALUE', key => $key },      my $pos = $obj->{libconf}->findAtomPos({ type => 'KEY_VALUE', key => $key },
244                                              $obj->{firstatom}+1, $obj->{lastatom}-1                                              $obj->{firstatom}+1, $obj->{lastatom}-1
245                                            );                                            );
246      defined $pos or return undef;      defined $pos or return undef;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26