Changeset 30348 for gs2-extensions/tdb


Ignore:
Timestamp:
2015-12-16T10:41:27+13:00 (8 years ago)
Author:
jmt12
Message:

Turns out some non-70-hyphen drivers need the functions to convert to and from string... may need to think about further refactoring

Location:
gs2-extensions/tdb/trunk/perllib/DBDrivers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb/trunk/perllib/DBDrivers/70HyphenFormat.pm

    r30347 r30348  
    8888}
    8989## close_infodb_write_handle(filehandle) => void ##
    90 
    91 
    92 ## @function convert_infodb_hash_to_string(hashmap) => string
    93 #
    94 sub convert_infodb_hash_to_string
    95 {
    96     my $self = shift(@_);
    97     my $infodb_map = shift(@_);
    98     my $infodb_entry_value = "";
    99     foreach my $infodb_value_key (keys(%$infodb_map)) {
    100         foreach my $infodb_value (@{$infodb_map->{$infodb_value_key}}) {
    101             $infodb_entry_value .= "<$infodb_value_key>" . $infodb_value . "\n";
    102         }
    103     }
    104     return $infodb_entry_value;
    105 }
    106 ## convert_infodb_hash_to_string(hashmap) => string ##
    107 
    108 
    109 ## @function convert_infodb_string_to_hash(string) => hashmap
    110 #
    111 sub convert_infodb_string_to_hash
    112 {
    113     my $self = shift(@_);
    114     my $infodb_entry_value = shift(@_);
    115     my $infodb_map = ();
    116 
    117     if (!defined $infodb_entry_value) {
    118     print STDERR "Warning: No value to convert into a infodb hashtable\n";
    119     }
    120     else {
    121         while ($infodb_entry_value =~ /^<(.*?)>(.*)$/mg) {
    122             my $infodb_value_key = $1;
    123             my $infodb_value = $2;
    124 
    125             if (!defined($infodb_map->{$infodb_value_key})) {
    126                 $infodb_map->{$infodb_value_key} = [ $infodb_value ];
    127             }
    128             else {
    129                 push(@{$infodb_map->{$infodb_value_key}}, $infodb_value);
    130             }
    131     }
    132     }
    133 
    134     return $infodb_map;
    135 }
    136 ## convert_infodb_string_to_hash(string) => hashmap ##
    13790
    13891
  • gs2-extensions/tdb/trunk/perllib/DBDrivers/BaseDBDriver.pm

    r30347 r30348  
    250250
    251251
     252## @function convert_infodb_hash_to_string(hashmap) => string
     253#
     254sub convert_infodb_hash_to_string
     255{
     256    my $self = shift(@_);
     257    my $infodb_map = shift(@_);
     258    my $infodb_entry_value = "";
     259    foreach my $infodb_value_key (keys(%$infodb_map)) {
     260        foreach my $infodb_value (@{$infodb_map->{$infodb_value_key}}) {
     261            $infodb_entry_value .= "<$infodb_value_key>" . $infodb_value . "\n";
     262        }
     263    }
     264    return $infodb_entry_value;
     265}
     266## convert_infodb_hash_to_string(hashmap) => string ##
     267
     268
     269## @function convert_infodb_string_to_hash(string) => hashmap
     270#
     271sub convert_infodb_string_to_hash
     272{
     273    my $self = shift(@_);
     274    my $infodb_entry_value = shift(@_);
     275    my $infodb_map = ();
     276
     277    if (!defined $infodb_entry_value) {
     278    print STDERR "Warning: No value to convert into a infodb hashtable\n";
     279    }
     280    else {
     281        while ($infodb_entry_value =~ /^<(.*?)>(.*)$/mg) {
     282            my $infodb_value_key = $1;
     283            my $infodb_value = $2;
     284
     285            if (!defined($infodb_map->{$infodb_value_key})) {
     286                $infodb_map->{$infodb_value_key} = [ $infodb_value ];
     287            }
     288            else {
     289                push(@{$infodb_map->{$infodb_value_key}}, $infodb_value);
     290            }
     291    }
     292    }
     293
     294    return $infodb_map;
     295}
     296## convert_infodb_string_to_hash(string) => hashmap ##
     297
     298
    252299## @function get_infodb_file_path(string, string) => string
    253300#
Note: See TracChangeset for help on using the changeset viewer.