| 1 | |||
| 2 | package IOC::Config::XML; | ||
| 3 | |||
| 4 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | our $VERSION = '0.03'; | ||
| 8 | |||
| 9 | 5 | ▶ | use IOC::Exceptions; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 0 | ▶ | use IOC::Config::XML::SAX::Handler; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 11 | |||
| 12 | use XML::SAX::ParserFactory; | ||
| 13 | |||
| 14 | sub new { | ||
| 15 | my ($_class) = @_; | ||
| 16 | my $class = ref($_class) || $_class; | ||
| 17 | my $config = { | ||
| 18 | _config => {} | ||
| 19 | }; | ||
| 20 | bless($config, $class); | ||
| 21 | return $config; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub read { | ||
| 25 | my ($self, $source) = @_; | ||
| 26 | (defined($source) && $source) | ||
| 27 | || throw IOC::InsufficientArguments "You must provide something to read"; | ||
| 28 | my $handler = IOC::Config::XML::SAX::Handler->new(); | ||
| 29 | my $p = XML::SAX::ParserFactory->parser(Handler => $handler); | ||
| 30 | if ($source =~ /\.xml$/) { | ||
| 31 | $p->parse_uri($source); | ||
| 32 | } | ||
| 33 | else { | ||
| 34 | $p->parse_string($source); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; | ||
| 39 | |||
| 40 | __END__ | ||