USBGuard
Software framework that protects your computer against rogue USB devices by implementing basic whitelisting and blacklisting capabilities.
KeyValueParser.hpp
1 //
2 // Copyright (C) 2015 Red Hat, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // Authors: Daniel Kopecek <dkopecek@redhat.com>
18 // Marek Tamaskovic <mtamasko@redhat.com>
19 // Radovan Sroka <rsroka@redhat.com>
20 //
21 #pragma once
22 
23 #include <iostream>
24 #include <vector>
25 #include <string>
26 #include <istream>
27 #include <map>
28 #include <memory>
29 #include <locale>
30 
31 #include "usbguard/Typedefs.hpp"
32 
33 namespace usbguard
34 {
35  class KeyValueParserPrivate;
36 
40  class DLL_PUBLIC KeyValueParser
41  {
42  public:
53  KeyValueParser(const std::vector<std::string>& v, bool case_sensitive, bool validate_keys);
54 
66  KeyValueParser(const std::vector<std::string>& v, const std::string& sep, bool case_sensitive, bool validate_keys);
67 
71  ~KeyValueParser();
72 
83  std::pair<std::string, std::string> parseLine(std::string& str);
84 
96  void parseStream(std::istream& stream);
97 
107  std::map<std::string, std::string> getMap();
108 
112  void viewConfig();
113 
114  private:
115  std::unique_ptr<KeyValueParserPrivate> d_pointer;
116  };
117 } /* namespace usbguard */
118 
119 /* vim: set ts=2 sw=2 et */
Serves as a config file parser.
Definition: KeyValueParser.hpp:40