+=back
+
+When C<set> is present, the classes given as its value replace the current object options. Then the C<add> classes are added, and the C<rem> classes removed.
+
+Passing a sole scalar C<$what> is equivalent as passing C<< set => $what >>.
+No argument means C<< set => [ ] >>.
+
+ $rw->do(set => 'jokers'); # Only translate jokers.
+ $rw->do('jokers'); # Same.
+ $rw->do(add => [ qw/sql commas/ ]); # Translate also SQL and commas.
+ $rw->do(rem => 'jokers'); # Specifying both 'sql' and 'jokers' is useless.
+ $rw->do(); # Translate nothing.
+
+=head2 C<type $type>
+
+Notifies to convert the metacharacters that corresponds to the predefined type C<$type>. C<$type> can be any of C<'jokers'>, C<'sql'>, C<'commas'>, C<'brackets'>, C<'win32'> or C<'unix'>. An unknown or undefined value defaults to C<'unix'>, except for C<'dos'>, C<'os2'>, C<'MSWin32'> and C<'cygwin'> that default to C<'win32'>. This means that you can pass C<$^O> as the C<$type> and get the corresponding shell behaviour. Returns the object.
+
+ $rw->type('win32'); # Set type to win32.
+ $rw->type(); # Set type to unix.
+
+=head2 C<< capture [ $captures E<verbar> set => $c1, add => $c2, rem => $c3 ] >>
+
+Specifies the list of atoms to capture.
+This method works like L</do>, except that the classes are different :
+
+=over 4
+
+=item *
+
+C<'single'> will capture all unescaped I<"exactly one"> metacharacters, i.e. C<?> for wildcards or C<_> for SQL ;
+
+ 'a???b\\??' ==> 'a(.)(.)(.)b\\?(.)'
+ 'a___b\\__' ==> 'a(.)(.)(.)b\\_(.)'
+
+=item *
+
+C<'any'> will capture all unescaped I<"any"> metacharacters, i.e. C<*> for wildcards or C<%> for SQL ;
+
+ 'a***b\\**' ==> 'a(.*)b\\*(.*)'
+ 'a%%%b\\%%' ==> 'a(.*)b\\%(.*)'
+
+=item *
+
+C<'greedy'>, when used in conjunction with C<'any'>, will make the C<'any'> captures greedy (by default they are not) ;
+
+ 'a***b\\**' ==> 'a(.*?)b\\*(.*?)'
+ 'a%%%b\\%%' ==> 'a(.*?)b\\%(.*?)'
+
+=item *
+
+C<'brackets'> will capture matching C<{ ... , ... }> alternations.
+
+ 'a{b\\},\\{c}' ==> 'a(b\\}|\\{c)'
+
+=back
+
+ $rw->capture(set => 'single'); # Only capture "exactly one" metacharacters.
+ $rw->capture('single'); # Same.
+ $rw->capture(add => [ qw/any greedy/ ]); # Also greedily capture "any" metacharacters.
+ $rw->capture(rem => 'greedy'); # No more greed please.
+ $rw->capture(); # Capture nothing.
+
+=head2 C<convert $wc [ , $type ]>
+
+Converts the wildcard expression C<$wc> into a regular expression according to the options stored into the L<Regexp::Wildcards> object, or to C<$type> if it's supplied. It successively escapes all unprotected regexp special characters that doesn't hold any meaning for wildcards, then replace C<'jokers'> or C<'sql'> and C<'commas'> or C<'brackets'> (depending on the L</do> or L</type> options), all of this by applying the C<'capture'> rules specified in the constructor or by L</capture>.
+
+=cut
+
+sub convert {
+ my ($self, $wc, $type) = @_;
+ _check_self $self;
+ my $config;
+ if (defined $type) {
+ $config = $self->_type($type);
+ } else {
+ $config = $self;
+ }
+ return unless defined $wc;
+ my $do = $config->{do};
+ my $e = $config->{escape};
+ $wc =~ s/(?<!\\)((?:\\\\)*[^\w\s\\$e])/\\$1/g;
+ if ($do->{jokers}) {
+ $wc = $self->_jokers($wc);
+ } elsif ($do->{sql}) {
+ $wc = $self->_sql($wc);
+ }
+ if ($do->{brackets}) {
+ $wc = $self->_bracketed($wc);
+ } elsif ($do->{commas}) {
+ if ($wc =~ /(?<!\\)(?:\\\\)*,/) { # win32 allows comma-separated lists
+ $wc = $self->{'c_brackets'} . $self->_commas($wc) . ')';
+ }
+ }
+ return $wc;
+}
+
+=head1 EXPORT
+
+An object module shouldn't export any function, and so does this one.
+
+=head1 DEPENDENCIES
+
+L<Carp> (core module since perl 5), L<Text::Balanced> (since 5.7.3).
+
+=head1 CAVEATS
+
+This module does not implement the strange behaviours of Windows shell that result from the special handling of the three last characters (for the file extension). For example, Windows XP shell matches C<*a> like C<.*a>, C<*a?> like C<.*a.?>, C<*a??> like C<.*a.{0,2}> and so on.