Handler for debugfilter unset
| 957 | |
| 958 | //! Handler for debugfilter unset |
| 959 | static command_result unsetFilter(color_ostream& out, |
| 960 | std::vector<std::string>& parameters) |
| 961 | { |
| 962 | std::set<DebugCategory*> modified; |
| 963 | std::vector<FilterManager::iterator> toErase; |
| 964 | return applyFilterIds(out,parameters,"unset", |
| 965 | // Per item |
| 966 | [&modified, &toErase](FilterManager::iterator& iter) -> bool { |
| 967 | Filter& filter = iter->second; |
| 968 | if (filter.enabled()) { |
| 969 | auto& catMan = DebugManager::getInstance(); |
| 970 | for (DebugCategory* cat: catMan) { |
| 971 | if (filter.remove(*cat)) |
| 972 | modified.emplace(cat); |
| 973 | } |
| 974 | } |
| 975 | toErase.emplace_back(iter); |
| 976 | return false; |
| 977 | }, |
| 978 | // After list |
| 979 | [&modified,&toErase,&out]() { |
| 980 | auto& filMan = FilterManager::getInstance(); |
| 981 | bool mustSave = false; |
| 982 | for (auto iter: toErase) { |
| 983 | mustSave = mustSave || iter->second.persistent(); |
| 984 | filMan.erase(iter); |
| 985 | } |
| 986 | |
| 987 | for (DebugCategory* cat: modified) { |
| 988 | // Reset filtering back to default |
| 989 | cat->allowed(DebugCategory::LWARNING); |
| 990 | // Reapply all remaining filters |
| 991 | for (auto& filterPair: filMan) |
| 992 | filterPair.second.applyAgain(*cat); |
| 993 | } |
| 994 | if (mustSave) |
| 995 | return FilterManager::getInstance().saveConfig(out); |
| 996 | return CR_OK; |
| 997 | }); |
| 998 | } |
| 999 | |
| 1000 | static const int welement = 16; |
| 1001 | static const int wsetting = 12; |
nothing calls this directly
no test coverage detected