FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
regexConfProvider.hpp
1 /*
2  * Copyright (C) 2015, Siemens AG
3  * Author: Maximilian Huber
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation.
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.
12  * See the 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, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef REGEXCONFPROVIDER_HPP_
20 #define REGEXCONFPROVIDER_HPP_
21 
22 #include <string>
23 #include <vector>
24 #include <map>
25 #include <sstream>
26 #include <fstream>
27 #include <iostream>
28 
29 #include "regexConfParser.hpp"
30 
31 std::string getRegexConfFile(const std::string& identity);
32 
38 {
39 public:
40  explicit RegexConfProvider(const bool isVerbosityDebug = false);
41 
42  void maybeLoad(const std::string& identity);
43  void maybeLoad(const std::string& identity,
44  std::istringstream& stream);
45 
46  const char* getRegexValue(const std::string& name,
47  const std::string& key);
48 
49 private:
50  static std::map<std::string,RegexMap> _regexMapMap;
51 
54  bool getRegexConfStream(const std::string& identity,
55  /*out*/ std::ifstream& stream);
56 };
57 
58 #endif /* REGEXCONFPROVIDER_HPP_ */
Provide regex using conf file.
RegexConfProvider(const bool isVerbosityDebug=false)
Constructor to set verbosity level.
static std::map< std::string, RegexMap > _regexMapMap
Map to store RegexMap with a string key.
const char * getRegexValue(const std::string &name, const std::string &key)
Get the regex as string from the RegexMap.
string getRegexConfFile(const string &identity)
Get the regex conf file.
bool getRegexConfStream(const std::string &identity, std::ifstream &stream)
Get file stream for regex conf file.
void maybeLoad(const std::string &identity)
Check if identity already loaded in RegexMap, if not load them.