Boost logo

Boost :

From: Jan Langer (jan_at_[hidden])
Date: 2002-04-01 14:58:46


On Mon, 1 Apr 2002, Stewart, Robert wrote:
>> I also think that reg. exp. matching should be done through a
>> predicate, if
>> nothing else to avoid the dependency of the filesystem
>> library the on reg. exp.
>> library.
>
>That's an excellent reason to rely on a predicate to handle the RE pattern
>matching. A standard predicate that uses an RE can be supplied in a
>separate header. (Obviously, an overload of the function could be supplied
>in that separate header, too.)

i am also in favour of this. using predicates is more general. perhaps
we need only the predicate version which uses a return_true predicate as
default argument. this would also solve the RE forward decl. header
problem because you only need the regexp header in the implementation of
this predicate.

probably it is possible to drop some of the options in favour of proper
predicates. for example using
        remove ("dirpath", optional);
with a functor optional
        class optional ...
          bool operator () (std::string const &path)
          {
                  return exsts (path);
          }
          ...
        };

and a class non_optional with
        bool operator () (std::string const &path)
        {
                if (!exists (path))
                {
                        throw ...;
                }
                return true;
        }
which is the default argument.

this could be a easy to use, extendible system which decouples the
options from the actual filesystem operation itself. the implementation
of remove has not to care for combinations of certain options a user
probably uses.

-- 
jan langer ... jan_at_[hidden]
"pi ist genau drei"

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk