31 namespace StringListImp
33 bool inList( StringArray::const_iterator begin , StringArray::const_iterator end ,
34 const std::string & s ,
bool i ) ;
35 bool notInList( StringArray::const_iterator begin , StringArray::const_iterator end ,
36 const std::string & s ,
bool i ) ;
37 bool match(
const std::string & a ,
const std::string & b ,
bool ignore_case ) ;
41bool G::StringListImp::inList( StringArray::const_iterator begin , StringArray::const_iterator end ,
42 const std::string & s ,
bool ignore )
44 using namespace std::placeholders ;
45 return std::any_of( begin , end , std::bind(match,_1,std::cref(s),ignore) ) ;
48bool G::StringListImp::notInList( StringArray::const_iterator begin , StringArray::const_iterator end ,
49 const std::string & s ,
bool ignore_case )
51 return !inList( begin , end , s , ignore_case ) ;
54bool G::StringListImp::match(
const std::string & a ,
const std::string & b ,
bool ignore_case )
56 return ignore_case ? sv_imatch(std::string_view(a),std::string_view(b)) : (a==b) ;
61 using namespace std::placeholders ;
62 if( !match_list.empty() )
64 std::remove_if( list.begin() , list.end() ,
65 std::bind(StringListImp::notInList,match_list.begin(),match_list.end(),_1,ignore==Ignore::Case) ) ,
71 using namespace std::placeholders ;
73 std::remove_if( list.begin() , list.end() ,
74 std::bind(StringListImp::inList,deny_list.begin(),deny_list.end(),_1,ignore==Ignore::Case) ) ,
80 return std::any_of( in.begin() , in.end() ,
81 [&head](
const std::string &x){return Str::headMatch(x,head);} ) ;
87 return std::any_of( in.begin() , in.end() ,
88 [&tail](
const std::string &x){return Str::tailMatch(x,tail);} ) ;
94 const auto end = in.end() ;
95 for(
auto p = in.begin() ; p != end ; ++p )
98 return (*p).substr( head.size() ) ;
105 return std::find( a.begin() , a.end() , b ) != a.end() ;
110 using namespace std::placeholders ;
111 std::string_view b_sv( b ) ;
112 return std::any_of( a.begin() , a.end() ,
113 [b_sv](
const std::string & a_str){ return Str::imatch(a_str,b_sv) ; } ) ;
void keepMatch(StringArray &list, const StringArray &allow_list, Ignore=Ignore::Nothing)
Removes items in the list that do not match any entry in the allow list.
bool match(const StringArray &, const std::string &)
Returns true if any string in the array matches the given string.
bool tailMatch(const StringArray &list, std::string_view ending)
Returns true if any string in the array has the given ending (or the given ending is empty).
bool headMatch(const StringArray &list, std::string_view head)
Returns true if any string in the array has the given start (or 'head' is empty).
bool imatch(const StringArray &, const std::string &)
Returns true if any string in the array matches the given string, ignoring case.
void removeMatch(StringArray &list, const StringArray &deny_list, Ignore=Ignore::Nothing)
Removes items in the list that match an entry in the deny list.
std::string headMatchResidue(const StringArray &list, std::string_view head)
Returns the unmatched part of the first string in the array that has the given start.
std::vector< std::string > StringArray
A std::vector of std::strings.