stringListOpsTemplates.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "labelList.H"
00028 #include "regExp.H"
00029
00030
00031
00032
00033 template<class StringType>
00034 Foam::labelList Foam::findStrings
00035 (
00036 const char* pattern,
00037 const UList<StringType>& lst
00038 )
00039 {
00040 regExp re(pattern);
00041 labelList matched(lst.size());
00042
00043 label matchI = 0;
00044 forAll(lst, elemI)
00045 {
00046 if (re.match(lst[elemI]))
00047 {
00048 matched[matchI++] = elemI;
00049 }
00050 }
00051 matched.setSize(matchI);
00052
00053 return matched;
00054 }
00055
00056
00057 template<class StringType>
00058 Foam::labelList Foam::findStrings
00059 (
00060 const std::string& pattern,
00061 const UList<StringType>& lst
00062 )
00063 {
00064 regExp re(pattern);
00065 labelList matched(lst.size());
00066
00067 label matchI = 0;
00068 forAll(lst, elemI)
00069 {
00070 if (re.match(lst[elemI]))
00071 {
00072 matched[matchI++] = elemI;
00073 }
00074 }
00075 matched.setSize(matchI);
00076
00077 return matched;
00078 }
00079
00080
00081 template<class StringType>
00082 Foam::labelList Foam::findStrings
00083 (
00084 const wordRe& wre,
00085 const UList<StringType>& lst
00086 )
00087 {
00088 labelList matched(lst.size());
00089
00090 label matchI = 0;
00091 forAll(lst, elemI)
00092 {
00093 if (wre.match(lst[elemI]))
00094 {
00095 matched[matchI++] = elemI;
00096 }
00097 }
00098 matched.setSize(matchI);
00099
00100 return matched;
00101 }
00102
00103
00104 template<class StringType>
00105 Foam::labelList Foam::findStrings
00106 (
00107 const UList<wordRe>& wreLst,
00108 const UList<StringType>& lst
00109 )
00110 {
00111 labelList matched(lst.size());
00112
00113 label matchI = 0;
00114 forAll(lst, elemI)
00115 {
00116 forAll(wreLst, reI)
00117 {
00118 if (wreLst[reI].match(lst[elemI]))
00119 {
00120 matched[matchI++] = elemI;
00121 break;
00122 }
00123 }
00124 }
00125 matched.setSize(matchI);
00126
00127 return matched;
00128 }
00129
00130
00131 template<class StringType>
00132 bool Foam::findStrings
00133 (
00134 const UList<wordRe>& wreLst,
00135 const StringType& str
00136 )
00137 {
00138 forAll(wreLst, reI)
00139 {
00140 if (wreLst[reI].match(str))
00141 {
00142 return true;
00143 }
00144 }
00145
00146 return false;
00147 }
00148
00149
00150
Copyright © 2000-2009 OpenCFD Ltd