MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / tryLoadLibrary

Method tryLoadLibrary

cli/cmdlineparser.cpp:2136–2181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2134}
2135
2136bool 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
2183bool CmdLineParser::loadLibraries(Settings& settings)
2184{

Callers

nothing calls this directly

Calls 3

loadMethod · 0.45
printMessageMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected