| 1054 | } |
| 1055 | |
| 1056 | std::vector<std::map<std::string, std::string>> Yolo::parseConfigFile(const std::string cfgFilePath) |
| 1057 | { |
| 1058 | assert(fileExists(cfgFilePath)); |
| 1059 | std::ifstream file(cfgFilePath); |
| 1060 | assert(file.good()); |
| 1061 | std::string line; |
| 1062 | std::vector<std::map<std::string, std::string>> blocks; |
| 1063 | std::map<std::string, std::string> block; |
| 1064 | |
| 1065 | while (getline(file, line)) |
| 1066 | { |
| 1067 | line = trim(line); |
| 1068 | if (line.empty() || line == "\r") |
| 1069 | continue; |
| 1070 | if (line.front() == '#') |
| 1071 | continue; |
| 1072 | if (line.front() == '[') |
| 1073 | { |
| 1074 | if (!block.empty()) |
| 1075 | { |
| 1076 | blocks.push_back(block); |
| 1077 | block.clear(); |
| 1078 | } |
| 1079 | std::string key = "type"; |
| 1080 | std::string value = trim(line.substr(1, line.size() - 2)); |
| 1081 | block.emplace(key, value); |
| 1082 | } |
| 1083 | else |
| 1084 | { |
| 1085 | size_t cpos = line.find('='); |
| 1086 | std::string key = trim(line.substr(0, cpos)); |
| 1087 | std::string value = trim(line.substr(cpos + 1)); |
| 1088 | block.emplace(key, value); |
| 1089 | } |
| 1090 | } |
| 1091 | blocks.push_back(block); |
| 1092 | return blocks; |
| 1093 | } |
| 1094 | |
| 1095 | void Yolo::parseConfigBlocks() |
| 1096 | { |