releasing/cbrtools/perl/Symbian/CBR/MRP/Reader.pm
author lorewang
Thu, 11 Nov 2010 12:38:08 +0800
changeset 678 f0d451bf8bcb
parent 602 3145852acc89
permissions -rw-r--r--
update version info
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
# Symbian::CBR::MRP::Reader
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
package Symbian::CBR::MRP::Reader;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use Carp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use Symbian::CBR::MRP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use base qw(Class::Singleton);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
sub _new_instance {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
    my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
    my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
    # caller(0))[3] gives the package and the method called, e.g. Symbian::CBR::MRP::Reader::_new_instance
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
    croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n" if (scalar(@_));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
    bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
sub ReadFile {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
    my $self = shift;    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
    my $file = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
    my $type = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
    if (!$file || !$type || shift) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
        croak "Invalid number of arguments passed to " . (caller(0))[3] . "\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
    }    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
    my $mrpObject;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
    # First we create the type of object required...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
    if ($type eq 'MRP') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
        $mrpObject = Symbian::CBR::MRP->new($file);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
    elsif ($type eq 'MRPDATA') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
        if (!eval "require MrpData") {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
            croak "Error: MrpData module is not available\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
        # PDDEF128617 fix
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
        # The envDb uses the path to the mrp file as a key with SRCROOT removed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
        # An earlier MrpData->New was provided data from the envDb to create an MrpData Object
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
        # (so the key was mrp location with SRCROOT removed)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
        # The below MrpData->New is given the full filename (because this function has to read the file)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
        # This is wrong, the key for MrpData->New is not the full path
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
        # So the below line removes the SRCROOT from the key before providing it to MrpData->New
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
        my $localMrpName = $file;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
        if (Utils::WithinSourceRoot($localMrpName)){
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
            $localMrpName = Utils::RemoveSourceRoot($localMrpName);        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
        #The 1 is to tell MrpData not to read the file
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
        $mrpObject = MrpData->New($localMrpName, undef, undef, undef, undef, undef ,1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
        croak "Error: Invalid MRP object type $type\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
    if ($mrpObject->Populated()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
        # MrpData is a multiton, it's possible a populated object has been returned
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
        return $mrpObject;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
    if (!$mrpObject) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
        croak "Unable to create an $type object for '$file'\n";   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
    if (!-f $file) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
        croak "Error: \"$file\" does not exist\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
    if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
        print "Reading $file...\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
    # Then parse the file and populate the object
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
    open MRP, $file or die "Unable to open \"$file\" for reading: $!\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
    while (my $line = <MRP>) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
        chomp $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
        $line =~ s/(?<!\\)#.*$//;  # remove comments
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
        $line =~ s/^\s+//;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
        next if (!$line); # blank lines
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
        my @parts;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
        my $string = $line;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
        while ($string) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
            if ($string =~ s/^\"(.*?)\"//    # Match and remove next quoted string
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
            or $string =~ s/^(.*?)\s+//  # or, match and remove next (but not last) unquoted string
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
            or $string =~ s/^(.*)\s*$//) {  # or, match and remove last unquoted string.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
                push (@parts, $1);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
                $string =~ s/^\s+//; # Remove delimiter if present.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
        my $keyword = shift @parts;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
        my $remove = ($keyword =~ s/^-//);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
        
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
        if (!scalar(@parts) or ($remove && $keyword !~ /binary|testbinary|export_file/)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
            croak "Error: Invalid line in \"$file\" \(Line $.\): \"$line\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
        if ($keyword eq 'component') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
            if (scalar @parts > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
                croak "Error: Invalid number of arguments to $keyword keyword in \"$file\"\n";   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
            if (!$mrpObject->SetComponent($parts[0])) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
                croak "Error: 'component' keyword used more than once in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
        elsif ($keyword eq 'notes_source') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
            if (scalar @parts > 1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
                croak "Error: Invalid number of arguments to $keyword keyword in \"$file\"\n";   
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
            if (!$mrpObject->SetNotesSource($parts[0])) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
                croak "Error: 'notes_source' keyword used more than once in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
        }       
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
        elsif ($keyword eq 'source') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
            my $source = join ' ', @parts;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
            if (!$mrpObject->SetSource($source)) { # some source statements contain spaces in the name
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
                croak "Error: 'source' entry for \"$source\" defined more than once in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
        elsif ($keyword =~ /^(test)?binary$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
            if (scalar @parts > 4) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
                croak "Error: Invalid number of arguments to $keyword keyword in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
            
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
            # SetBinary (operand, test, remove)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
            $mrpObject->SetBinary(\@parts, $1, $remove);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
        elsif ($keyword =~ /^(test)?exports$/) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
            if (scalar @parts > 2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
                croak "Error: Invalid number of arguments to $keyword keyword in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
            # SetExports (operand, test, dependantComponet)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
            $mrpObject->SetExports($parts[0], $1, $parts[1]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
        elsif ($keyword eq 'export_file') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
            if (scalar @parts > 3) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
                croak "Error: Invalid number of arguments to $keyword keyword in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
            # SetExportFile (source, destination, remove, dependantComponet)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
            $mrpObject->SetExportFile($parts[0], $parts[1], $remove, $parts[2]);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
        elsif ($keyword eq 'ipr') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
            if (scalar @parts > 3) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
                croak "Error: Invalid number of arguments to $keyword keyword in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
            # SetIPR (category, path, exportRestricted)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
            if ($parts[0] eq 'export-restricted') {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
                if (!$mrpObject->SetIPR($parts[1], $parts[2], 1)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
                   croak "Error: IPR information for \"$parts[2]\" specified more than once in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
                }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
            else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
                if (!$mrpObject->SetIPR($parts[0], $parts[1], 0)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
                   croak "Error: IPR information for \"$parts[1]\" specified more than once in \"$file\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
                }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
            }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
        else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
            croak "Error: Invalid line in \"$file\" \(Line $.\): \"$line\"\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
        }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
    close MRP;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
    $mrpObject->ValidateParsing();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
    return $mrpObject;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
sub SetVerbose {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
    my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
    
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
    $self->{verbose} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
=pod
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
Symbian::CBR::MRP::Reader - Parses MRP files and returns a populated MRP object
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
=head1 SYNOPSIS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
 use Symbian::CBR::MRP::Reader;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
 # Instantiate an instance of the Symbian::CBR::MRP::Reader object
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
 my $mrpReader = Symbian::CBR::MRP::Reader->instance();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
 my $mrpFile = '\someFolder\anMrpFile.mrp';
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
 # Enable verbose output
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
 $mrpReader->SetVerbose();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
 # Call ReadFile on the mrp reader, specifying the MRP file to parse and the type
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
 # of MRP object you want to be populated and returned
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
 my $mrpObject = $mrpReader->ReadFile($mrpFile, 'MRP');
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
 ...
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
 # Call methods on the returned MRP object
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
 $mrpObject->GetIPRInformation();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
This module is used to parse MRP files and populate MRP objects.  The user can
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
specify the type of MRP object to be populated and returned.  This module includes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
basic MRP syntax checking but stronger syntax checking should be implemented
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
in the MRP object to be populated.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
=head1 METHODS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
=head2 instance()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
Instantiates and returns Symbian::CBR::MRP::Reader object.  This object is a
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
singleton.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
=head2 ReadFile (mrpfile, type)
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
Reads the specified MRP file, instantiates and populates an MRP object of the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
type specified and then returns the populated MRP object to the caller.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
Valid MRP types are MRP and MRPDATA.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
MRP: This is a Symbian::CBR::MRP object.  It is a lightweight MRP object and
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
contains only basic MRP functionality.  This option should be used when MRP
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
objects are required for tools which are not part of the CBR Tools.  See the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
Symbian::CBR::MRP documentation for more details.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
MRPDATA:  This is an MrpData object, as used by the CBR Tools.  This option
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
should only be used for the CBR Tools. See the MrpData documentation
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
for more details.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
=head2 SetVerbose ()
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
Used to set enable verbose output.  Once set it is not possible to unset the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
verbose output.  This is because this package is a singleton, and disabling the
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
verbose output could disrupt other code using this same instance.  This means
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
that it is not possible to disable the verbosity once it has been enabled.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
 Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
=cut