Refactorization: Avoid creating a temporary string

This commit is contained in:
PKEuS 2020-05-13 19:05:15 +02:00
parent e92a95150a
commit e9318d7bfc
1 changed files with 11 additions and 11 deletions

View File

@ -1126,38 +1126,38 @@ bool CppCheckExecutor::tryLoadLibrary(Library& destination, const char* basepath
if (err.errorcode == Library::UNKNOWN_ELEMENT) if (err.errorcode == Library::UNKNOWN_ELEMENT)
std::cout << "cppcheck: Found unknown elements in configuration file '" << filename << "': " << err.reason << std::endl; std::cout << "cppcheck: Found unknown elements in configuration file '" << filename << "': " << err.reason << std::endl;
else if (err.errorcode != Library::OK) { else if (err.errorcode != Library::OK) {
std::string errmsg; std::cout << "cppcheck: Failed to load library configuration file '" << filename << "'. ";
switch (err.errorcode) { switch (err.errorcode) {
case Library::OK: case Library::OK:
break; break;
case Library::FILE_NOT_FOUND: case Library::FILE_NOT_FOUND:
errmsg = "File not found"; std::cout << "File not found";
break; break;
case Library::BAD_XML: case Library::BAD_XML:
errmsg = "Bad XML"; std::cout << "Bad XML";
break; break;
case Library::UNKNOWN_ELEMENT: case Library::UNKNOWN_ELEMENT:
errmsg = "Unexpected element"; std::cout << "Unexpected element";
break; break;
case Library::MISSING_ATTRIBUTE: case Library::MISSING_ATTRIBUTE:
errmsg = "Missing attribute"; std::cout << "Missing attribute";
break; break;
case Library::BAD_ATTRIBUTE_VALUE: case Library::BAD_ATTRIBUTE_VALUE:
errmsg = "Bad attribute value"; std::cout << "Bad attribute value";
break; break;
case Library::UNSUPPORTED_FORMAT: case Library::UNSUPPORTED_FORMAT:
errmsg = "File is of unsupported format version"; std::cout << "File is of unsupported format version";
break; break;
case Library::DUPLICATE_PLATFORM_TYPE: case Library::DUPLICATE_PLATFORM_TYPE:
errmsg = "Duplicate platform type"; std::cout << "Duplicate platform type";
break; break;
case Library::PLATFORM_TYPE_REDEFINED: case Library::PLATFORM_TYPE_REDEFINED:
errmsg = "Platform type redefined"; std::cout << "Platform type redefined";
break; break;
} }
if (!err.reason.empty()) if (!err.reason.empty())
errmsg += " '" + err.reason + "'"; std::cout << " '" + err.reason + "'";
std::cout << "cppcheck: Failed to load library configuration file '" << filename << "'. " << errmsg << std::endl; std::cout << std::endl;
return false; return false;
} }
return true; return true;