Platform: Improve testability of platform file loading
This commit is contained in:
parent
0f00259a96
commit
03a222e926
|
@ -183,7 +183,12 @@ bool cppcheck::Platform::platformFile(const char exename[], const std::string &f
|
|||
return false;
|
||||
}
|
||||
|
||||
const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement();
|
||||
return loadFromXmlDocument(&doc);
|
||||
}
|
||||
|
||||
bool cppcheck::Platform::loadFromXmlDocument(const tinyxml2::XMLDocument *doc)
|
||||
{
|
||||
const tinyxml2::XMLElement * const rootnode = doc->FirstChildElement();
|
||||
|
||||
if (!rootnode || std::strcmp(rootnode->Name(), "platform") != 0)
|
||||
return false;
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
/// @addtogroup Core
|
||||
/// @{
|
||||
|
||||
namespace tinyxml2 {
|
||||
class XMLDocument;
|
||||
}
|
||||
|
||||
namespace cppcheck {
|
||||
|
||||
/**
|
||||
|
@ -99,6 +103,9 @@ namespace cppcheck {
|
|||
/** set the platform type for user specified platforms */
|
||||
bool platformFile(const char exename[], const std::string &filename);
|
||||
|
||||
/** load platform from xml document, primarily for testing */
|
||||
bool loadFromXmlDocument(const tinyxml2::XMLDocument *doc);
|
||||
|
||||
/**
|
||||
* @brief Returns true if platform type is Windows
|
||||
* @return true if Windows platform type.
|
||||
|
|
Loading…
Reference in New Issue