| 2134 | } |
| 2135 | |
| 2136 | bool CmdLineParser::tryLoadLibrary(Library& destination, const std::string& basepath, const char* filename, bool debug) |
| 2137 | { |
| 2138 | const Library::Error err = destination.load(basepath.c_str(), filename, debug); |
| 2139 | |
| 2140 | if (err.errorcode == Library::ErrorCode::UNKNOWN_ELEMENT) |
| 2141 | mLogger.printMessage("Found unknown elements in configuration file '" + std::string(filename) + "': " + err.reason); // TODO: print as errors |
| 2142 | else if (err.errorcode != Library::ErrorCode::OK) { |
| 2143 | std::string msg = "Failed to load library configuration file '" + std::string(filename) + "'. "; |
| 2144 | switch (err.errorcode) { |
| 2145 | case Library::ErrorCode::OK: |
| 2146 | break; |
| 2147 | case Library::ErrorCode::FILE_NOT_FOUND: |
| 2148 | msg += "File not found"; |
| 2149 | break; |
| 2150 | case Library::ErrorCode::BAD_XML: |
| 2151 | msg += "Bad XML"; |
| 2152 | break; |
| 2153 | case Library::ErrorCode::UNKNOWN_ELEMENT: |
| 2154 | msg += "Unexpected element"; |
| 2155 | break; |
| 2156 | case Library::ErrorCode::MISSING_ATTRIBUTE: |
| 2157 | msg +="Missing attribute"; |
| 2158 | break; |
| 2159 | case Library::ErrorCode::BAD_ATTRIBUTE_VALUE: |
| 2160 | msg += "Bad attribute value"; |
| 2161 | break; |
| 2162 | case Library::ErrorCode::UNSUPPORTED_FORMAT: |
| 2163 | msg += "File is of unsupported format version"; |
| 2164 | break; |
| 2165 | case Library::ErrorCode::DUPLICATE_PLATFORM_TYPE: |
| 2166 | msg += "Duplicate platform type"; |
| 2167 | break; |
| 2168 | case Library::ErrorCode::PLATFORM_TYPE_REDEFINED: |
| 2169 | msg += "Platform type redefined"; |
| 2170 | break; |
| 2171 | case Library::ErrorCode::DUPLICATE_DEFINE: |
| 2172 | msg += "Duplicate define"; |
| 2173 | break; |
| 2174 | } |
| 2175 | if (!err.reason.empty()) |
| 2176 | msg += " '" + err.reason + "'"; |
| 2177 | mLogger.printMessage(msg); // TODO: print as errors |
| 2178 | return false; |
| 2179 | } |
| 2180 | return true; |
| 2181 | } |
| 2182 | |
| 2183 | bool CmdLineParser::loadLibraries(Settings& settings) |
| 2184 | { |
nothing calls this directly
no test coverage detected