Config-ReadAndCheck

 view release on metacpan or  search on metacpan

ReadAndCheck.pm  view on Meta::CPAN

			#if($^W) { Carp::carp $@; };
			return;
			};

		$NewParams->{$Name}->{'SubSection'} = &{$CheckParams}($Params->{$Name}->{'SubSection'}, "$Path\->$Name")
			or return;
		};
	return $NewParams;
	};

sub new($%)
	{
	my ($class, %Config) = @_;

	(!&{$CheckLoop}($Config{'Params'}))
		or return;

	my $self = {};

	$self->{'CaseSens'} = $Config{'CaseSens'};

	$self->{'Params'} = &{$CheckParams}($Config{'Params'})
		or return;

	Reset($self);

	return bless $self => $class;
	};

sub Result($)
	{
	my ($self) = @_;
	my %Result = ();
	tie(%Result, 'Tie::IxHash', %{$self->{'Result'}});
	return (wantarray ? %Result : \%Result);
	};

sub Reset($)
	{
	my ($self) = @_;
        tie(%{$self->{'Result'}}, 'Tie::IxHash');
	$self->{'SecStack'} = [];
	unshift(@{$self->{'SecStack'}}, {'Params' => $self->{'Params'},'Result' => $self->{'Result'}});
	};

sub Params($)
	{
	my ($self) = @_;
	my $Params = &{$CheckParams}($self->{'Params'});
	return (wantarray ? %{$Params} : $Params);
	};

my $ParseLine = sub($$)
	{
	my ($self, $Str, $Params) = @_;

ReadAndCheck.pm  view on Meta::CPAN

					};
				&{$CheckRequired}($Params->{$Key}->{'SubSection'}, $SubResult, "$Path\->$Key")
					or return;
				};
			};
		};

	return (wantarray ? %{$Result} : $Result);
	};

sub CheckRequired($)
	{
	my ($self);
	($self) = @_;

	my %Result = ();
	tie(%Result, 'Tie::IxHash');
	%Result = &{$CheckRequired}($self->{'Params'}, $self->{'Result'})
		or return;
	return (wantarray ? %Result : \%Result);
	};

ReadAndCheck.pm  view on Meta::CPAN

		$@ = "Input dry up before 'EndOfSection' reached";
		return;
		};

	CheckRequired($self)
		or return;

	return (wantarray ? %{$self->{'Result'}} : $self->{'Result'});
	};

sub Parse($$)
	{
	my ($self, $Input) = @_;
	my $GetLine  = undef;
	my $RunIndex = 0;
	if    (!ref($Input))
		{
		my @tmpArray = split('\n', $Input);
		$Input = \@tmpArray;
		$GetLine = sub{return $Input->[$RunIndex++]};
		}

ReadAndCheck.pm  view on Meta::CPAN

		};

	my %Result = ();
	tie(%Result, 'Tie::IxHash');
	%Result = &{$ParseGetline}($self, $GetLine)
		or return;

	return (wantarray ? %Result : \%Result);
	};

sub ParseFile($$)
	{
	my ($self, $FileName) = @_;

	my $File = IO::File->new("< $FileName");
	if (!$File)
		{
		$@ = "Can not open file \"$FileName\" for read";
		return;
		};

ReadAndCheck.pm  view on Meta::CPAN

		{
		tie(%{$Result}, 'Tie::IxHash', %{$Result});
		$_[2] = $Result;
		};

	unshift(@{$self->{'SecStack'}}, {'Params' => $Params, 'Result' => $Result});

	return $Params;
	};

sub ParseIncremental($$)
	{
	my ($self, $Str) = @_;

	my ($Name, $P1, $P2);

	my $Params = undef;
	while($Params = $self->{'SecStack'}->[0]->{'Params'})
		{
		(!(($Name, $P1, $P2) = &{$ParseLine}($self, $Str, $Params)))
			or last;



( run in 0.268 second using v1.01-cache-2.11-cpan-1f129e94a17 )