NAME

Data::Semantic::RegexpAdapter - Adapter for Regexp::Common patterns

SYNOPSIS

Data::Semantic::RegexpAdapter->new;

DESCRIPTION

This class is an adapter (wrapper) that turns Regexp::Common patterns into Data::Semantic objects.

METHODS

clear_keep
$obj->clear_keep;

Clears the boolean value by setting it to 0.

clear_kept
$obj->clear_kept;

Deletes all keys and values from the hash.

clear_re
$obj->clear_re;

Clears the value.

delete_kept
$obj->delete_kept(@keys);

Takes a list of keys and deletes those keys from the hash.

exists_kept
if ($obj->exists_kept($key)) { ... }

Takes a key and returns a true value if the key exists in the hash, and a false value otherwise.

keep
$obj->keep($value);
my $value = $obj->keep;

If called without an argument, returns the boolean value (0 or 1). If called with an argument, it normalizes it to the boolean value. That is, the values 0, undef and the empty string become 0; everything else becomes 1.

keep_clear
$obj->keep_clear;

Clears the boolean value by setting it to 0.

keep_set
$obj->keep_set;

Sets the boolean value to 1.

kept
my %hash     = $obj->kept;
my $hash_ref = $obj->kept;
my $value    = $obj->kept($key);
my @values   = $obj->kept([ qw(foo bar) ]);
$obj->kept(%other_hash);
$obj->kept(foo => 23, bar => 42);

Get or set the hash values. If called without arguments, it returns the hash in list context, or a reference to the hash in scalar context. If called with a list of key/value pairs, it sets each key to its corresponding value, then returns the hash as described before.

If called with exactly one key, it returns the corresponding value.

If called with exactly one array reference, it returns an array whose elements are the values corresponding to the keys in the argument array, in the same order. The resulting list is returned as an array in list context, or a reference to the array in scalar context.

If called with exactly one hash reference, it updates the hash with the given key/value pairs, then returns the hash in list context, or a reference to the hash in scalar context.

kept_clear
$obj->kept_clear;

Deletes all keys and values from the hash.

kept_delete
$obj->kept_delete(@keys);

Takes a list of keys and deletes those keys from the hash.

kept_exists
if ($obj->kept_exists($key)) { ... }

Takes a key and returns a true value if the key exists in the hash, and a false value otherwise.

kept_keys
my @keys = $obj->kept_keys;

Returns a list of all hash keys in no particular order.

kept_values
my @values = $obj->kept_values;

Returns a list of all hash values in no particular order.

keys_kept
my @keys = $obj->keys_kept;

Returns a list of all hash keys in no particular order.

re
my $value = $obj->re;
$obj->re($value);

A basic getter/setter method. If called without an argument, it returns the value. If called with a single argument, it sets the value.

re_clear
$obj->re_clear;

Clears the value.

set_keep
$obj->set_keep;

Sets the boolean value to 1.

values_kept
my @values = $obj->values_kept;

Returns a list of all hash values in no particular order.

LOAD
use constant LOAD => 'AT::NICAT';

This is the optional name of the Regexp::Common module to load. For example, if you use a pattern from Regexp::Common::AT::NICAT, you would set this to AT::NICAT. If you use patterns bundled in the same distribution as Regexp::Common you can leave it empty.

REGEXP_KEYS
use constant REGEXP_KEYS => qw(URI file);

These is the list of keys that you would pass to Regexp::Common's $RE. For example, if you wanted to match HTTP URIs, you would use qw(URI HTTP). Compare with Regexp::Common::URI::http. See Regexp::Common for more details on this mechanism.

KEEP_KEYS
use constant KEEP_KEYS => qw(scheme host port query);

This class supports Regexp::Common's -keep mechanism. kept() returns a hash of the patterns returned by Regexp::Common. In this list you can specify the hash keys that $1, $2 and so on are mapped to.

flags

Turns the object's settings into a list of flags to be passed to Regexp::Common's $RE. For example, Regexp::Common expects a {-keep} key, but this class has a keep() accessor. If you subclass this class and add more accessors that correspond to Regexp::Common keys, you need to override this method and map the attributes to the keys. Be sure to call SUPER::flags(). See Data::Semantic::URI::http for an example.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests through the web interface at http://rt.cpan.org.

INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

AVAILABILITY

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN site near you. Or see http://search.cpan.org/dist/Data-Semantic/.

AUTHORS

Marcel Grünauer, <marcel@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2007-2009 by the authors.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.