|
||||
File indexing completed on 2025-01-30 09:15:21
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #include "Acts/Plugins/TGeo/TGeoPrimitivesHelper.hpp" 0010 0011 bool Acts::TGeoPrimitivesHelper::match(const char* first, const char* second) { 0012 // If we reach at the end of both strings, we are done 0013 if (*first == '\0' && *second == '\0') { 0014 return true; 0015 } 0016 0017 // Make sure that the characters after '*' are present 0018 // in second string. This function assumes that the first 0019 // string will not contain two consecutive '*' 0020 if (*first == '*' && *(first + 1) != '\0' && *second == '\0') { 0021 return false; 0022 } 0023 0024 // If the first string contains '?', or current characters 0025 // of both strings match 0026 if (*first == '?' || *first == *second) { 0027 return match(first + 1, second + 1); 0028 } 0029 0030 // If there is *, then there are two possibilities 0031 // a) We consider current character of second string 0032 // b) We ignore current character of second string. 0033 if (*first == '*') { 0034 return match(first + 1, second) || match(first, second + 1); 0035 } 0036 return false; 0037 } 0038 0039 bool Acts::TGeoPrimitivesHelper::match(const std::vector<std::string>& first, 0040 const char* second) { 0041 for (const auto& f : first) { 0042 if (match(f.c_str(), second)) { 0043 return true; 0044 } 0045 } 0046 return false; 0047 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |