OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
wildcards.hpp
1// Copyright (C) 1996 - 2002 Florian Schintke
2//
3// This is free software; you can redistribute it and/or modify it under
4// the terms of the GNU General Public License as published by the Free
5// Software Foundation; either version 2, or (at your option) any later
6// version.
7//
8// Thanks to the E.S.O. - ACS project that has done this C++ interface
9// to the wildcards pttern matching algorithm
10
11#ifndef WILDCARD_H_INCLUDED
12#define WILDCARD_H_INCLUDED
13
14// #ifndef __cplusplus
15// #error This is a C++ include file and cannot be used from plain C
16// #endif
17
18// Implementation of the UN*X wildcards
19// Supported wild-characters: '*', '?'; sets: [a-z], '!' negation
20// Examples:
21// '[a-g]l*i?n' matches 'florian'
22// '[!abc]*e' matches 'smile'
23// '[-z] matches 'a'
24
25class Wildcard {
26public:
27 // This function implements the UN*X wildcards and returns:
28 // 0 - if *wildcard does not match *test
29 // 1 - if *wildcard matches *test
30 static int wildcardfit(const char* wildcard, const char* test);
31
32private:
33 // Scans a set of characters and returns 0 if the set mismatches at this
34 // position in the teststring and 1 if it is matching
35 // wildcard is set to the closing ] and test is unmodified if mismatched
36 // and otherwise the char pointer is pointing to the next character
37 static int set(const char** wildcard, const char** test);
38
39 // Scans an asterisk
40 static int asterisk(const char** wildcard, const char** test);
41};
42
43#endif