File indexing completed on 2025-02-21 10:04:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef EXAMPLES_KEEPDROPSWITCH_H
0020 #define EXAMPLES_KEEPDROPSWITCH_H
0021
0022 #include <map>
0023 #include <string>
0024 #include <vector>
0025
0026 std::vector<std::string> split(const std::string& s, char delim);
0027
0028 int wildcmp(const char* wild, const char* string);
0029
0030 class KeepDropSwitch {
0031 public:
0032 enum Cmd { KEEP, DROP, UNKNOWN };
0033 typedef std::vector<std::string> CommandLines;
0034 KeepDropSwitch() {}
0035 explicit KeepDropSwitch(const CommandLines& cmds) { m_commandlines = cmds; }
0036 bool isOn(const std::string& astring) const;
0037
0038 private:
0039 bool getFlag(const std::string& astring) const;
0040 Cmd extractCommand(const std::string cmdLine) const;
0041 CommandLines m_commandlines;
0042 mutable std::map<std::string, bool> m_cache;
0043 };
0044
0045 #endif