votca 2024.2-dev
Loading...
Searching...
No Matches
tokenizer.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18// Local VOTCA includes
20
21namespace votca {
22namespace tools {
23
24int wildcmp(const std::string &wild, const std::string &string) {
25 return wildcmp(wild.c_str(), string.c_str());
26}
27
28int wildcmp(const char *wild, const char *string) {
29 // Written by Jack Handy - jakkhandy@hotmail.com
30 const char *cp = nullptr, *mp = nullptr;
31
32 while ((*string) && (*wild != '*')) {
33 if ((*wild != *string) && (*wild != '?')) {
34 return 0;
35 }
36 wild++;
37 string++;
38 }
39
40 while (*string) {
41 if (*wild == '*') {
42 if (!*++wild) {
43 return 1;
44 }
45 mp = wild;
46 cp = string + 1;
47 } else if ((*wild == *string) || (*wild == '?')) {
48 wild++;
49 string++;
50 } else {
51 wild = mp;
52 string = cp++;
53 }
54 }
55
56 while (*wild == '*') {
57 wild++;
58 }
59 return !*wild;
60}
61
62} // namespace tools
63} // namespace votca
int wildcmp(const char *wild, const char *string)
Definition tokenizer.cc:28
base class for all analysis tools
Definition basebead.h:33