X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fportability%2Fwildcard.hpp;fp=src%2Fstlplus%2Fportability%2Fwildcard.hpp;h=398c3dd43621951b89a7418cc7e6e3eda647d0be;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/portability/wildcard.hpp b/src/stlplus/portability/wildcard.hpp new file mode 100644 index 0000000..398c3dd --- /dev/null +++ b/src/stlplus/portability/wildcard.hpp @@ -0,0 +1,35 @@ +#ifndef STLPLUS_WILDCARD +#define STLPLUS_WILDCARD +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +// This is a portable interface to wildcard matching. + +// The problem: +// * matches any number of characters - this is achieved by matching 1 and seeing if the remainder matches +// if not, try 2 characters and see if the remainder matches etc. +// this must be recursive, not iterative, so that multiple *s can appear in the same wildcard expression +// ? matches exactly one character so doesn't need the what-if approach +// \ escapes special characters such as *, ? and [ +// [] matches exactly one character in the set - the difficulty is the set can contain ranges, e.g [a-zA-Z0-9] +// a set cannot be empty and the ] character can be included by making it the first character + +//////////////////////////////////////////////////////////////////////////////// +#include "portability_fixes.hpp" +#include + +namespace stlplus +{ + + // wild = the wildcard expression + // match = the string to test against that expression + // e.g. wildcard("[a-f]*", "fred") returns true + bool wildcard(const std::string& wild, const std::string& match); + +} + +#endif