* @brief ConfigParser::ConfigParser - Read the config file. * @param ConfigFile - The config file to parse. */
| 5 | * @param ConfigFile - The config file to parse. |
| 6 | */ |
| 7 | ConfigParser::ConfigParser(std::string ConfigFile) |
| 8 | { |
| 9 | std::ifstream configFile(ConfigFile); |
| 10 | std::string currentLine; |
| 11 | |
| 12 | size_t findIndex; |
| 13 | std::string currentPropertyName; |
| 14 | std::string currentPropertyValue; |
| 15 | |
| 16 | if(configFile.is_open() == FALSE) |
| 17 | { |
| 18 | printf("Failed to open config file."); |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | while(std::getline(configFile, currentLine)) |
| 23 | { |
| 24 | // |
| 25 | // Check if the current line is a comment. |
| 26 | // |
| 27 | if(currentLine[0] == '#') |
| 28 | { |
| 29 | continue; |
| 30 | } |
| 31 | // |
| 32 | // Check if there is anything on the current line. |
| 33 | // |
| 34 | if(currentLine.length() == 0) |
| 35 | { |
| 36 | continue; |
| 37 | } |
| 38 | |
| 39 | findIndex = currentLine.find("="); |
| 40 | currentPropertyName = currentLine.substr(0, findIndex); |
| 41 | currentPropertyValue = currentLine.substr(findIndex + 1); |
| 42 | configMap[currentPropertyName] = currentPropertyValue; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @brief ConfigParser::GetConfigFalsePositives - Parse false positive strings from the config. |
nothing calls this directly
no outgoing calls
no test coverage detected