X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fstlplus%2Fportability%2Fwildcard.hpp;fp=src%2Fstlplus%2Fportability%2Fwildcard.hpp;h=07adba4b84a439f3de9dfa54b06ec9620bfcb857;hp=585a7868067eda49c9883bf15d44a41581baee0f;hb=4f6e4488a55f7e3ba3f7485d78177f793c0eab9a;hpb=574af38ed616d1adfa5e6ce35f67cda1f707f89d diff --git a/src/stlplus/portability/wildcard.hpp b/src/stlplus/portability/wildcard.hpp index 585a786..07adba4 100644 --- a/src/stlplus/portability/wildcard.hpp +++ b/src/stlplus/portability/wildcard.hpp @@ -1,35 +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 +#ifndef STLPLUS_WILDCARD +#define STLPLUS_WILDCARD +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004 onwards +// 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