- Timestamp:
- 04/03/14 21:46:38 (11 years ago)
- Location:
- cpp/frams/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/sstringutils.cpp
r197 r210 288 288 return true; 289 289 } 290 291 bool matchWildcard(const SString& word,const SString& pattern) 292 { 293 if (pattern.len()==0) 294 return word.len()==0; 295 int aster=pattern.indexOf('*'); 296 if (aster>=0) 297 { 298 SString before=pattern.substr(0,aster); 299 SString after=pattern.substr(aster+1); 300 int pos=0; 301 if (!word.len()) return false; 302 if (before.len()) if (!word.startsWith(before)) return false; 303 if (after.len()) 304 if ((word.len()<after.len()) 305 ||(strcmp((const char*)after,((const char*)word)+word.len()-after.len()))) 306 return false; 307 return true; 308 } 309 else 310 return word==pattern; 311 } 312 313 bool matchWildcardList(const SString& word,const SString& patterns) 314 { 315 if (patterns.len()==0) 316 return word.len()==0; 317 int pos=0; 318 SString pattern; 319 while(patterns.getNextToken(pos,pattern,',')) 320 if (matchWildcard(word,pattern)) 321 return true; 322 return false; 323 } 324 -
cpp/frams/util/sstringutils.h
r197 r210 26 26 void strSetField(SString& txt,const SString& name,const SString& value); 27 27 28 SString trim(SString& s); //remove leading/trailing whitespace 29 bool removeCR(SString& s); //remove '\r' return true if changed 28 SString trim(SString& s); ///< remove leading/trailing whitespace 29 bool removeCR(SString& s); ///< remove '\r' return true if changed 30 bool matchWildcard(const SString& word,const SString& pattern);///< '*' in pattern matches any substring 31 bool matchWildcardList(const SString& word,const SString& patterns);///< patterns is a list of patterns (separated by ',') 30 32 31 33 #endif
Note: See TracChangeset
for help on using the changeset viewer.