Refactorization: Avoid including path.h in (almost) every source file (via library.h)

This commit is contained in:
PKEuS 2015-03-11 22:12:17 +01:00
parent bc5132e0ac
commit 7f2b6881b3
4 changed files with 82 additions and 56 deletions

View File

@ -733,3 +733,74 @@ bool Library::isnotnoreturn(const Token *ftok) const
std::map<std::string, bool>::const_iterator it = _noreturn.find(ftok->str()); std::map<std::string, bool>::const_iterator it = _noreturn.find(ftok->str());
return (it != _noreturn.end() && !it->second); return (it != _noreturn.end() && !it->second);
} }
bool Library::markupFile(const std::string &path) const
{
return _markupExtensions.find(Path::getFilenameExtensionInLowerCase(path)) != _markupExtensions.end();
}
bool Library::processMarkupAfterCode(const std::string &path) const
{
const std::map<std::string, bool>::const_iterator it = _processAfterCode.find(Path::getFilenameExtensionInLowerCase(path));
return (it == _processAfterCode.end() || it->second);
}
bool Library::reportErrors(const std::string &path) const
{
const std::map<std::string, bool>::const_iterator it = _reporterrors.find(Path::getFilenameExtensionInLowerCase(path));
return (it == _reporterrors.end() || it->second);
}
bool Library::isexecutableblock(const std::string &file, const std::string &token) const
{
const std::map<std::string, CodeBlock>::const_iterator it = _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _executableblocks.end() && it->second.isBlock(token));
}
int Library::blockstartoffset(const std::string &file) const
{
int offset = -1;
const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) {
offset = map_it->second.offset();
}
return offset;
}
const std::string& Library::blockstart(const std::string &file) const
{
const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) {
return map_it->second.start();
}
return emptyString;
}
const std::string& Library::blockend(const std::string &file) const
{
const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) {
return map_it->second.end();
}
return emptyString;
}
bool Library::iskeyword(const std::string &file, const std::string &keyword) const
{
const std::map<std::string, std::set<std::string> >::const_iterator it =
_keywords.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _keywords.end() && it->second.count(keyword));
}
bool Library::isimporter(const std::string& file, const std::string &importer) const
{
const std::map<std::string, std::set<std::string> >::const_iterator it =
_importers.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _importers.end() && it->second.count(importer) > 0);
}

View File

@ -22,7 +22,6 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include "config.h" #include "config.h"
#include "path.h"
#include "mathlib.h" #include "mathlib.h"
#include "token.h" #include "token.h"
@ -259,69 +258,28 @@ public:
return arg ? &arg->minsizes : nullptr; return arg ? &arg->minsizes : nullptr;
} }
bool markupFile(const std::string &path) const { bool markupFile(const std::string &path) const;
return _markupExtensions.find(Path::getFilenameExtensionInLowerCase(path)) != _markupExtensions.end();
}
bool processMarkupAfterCode(const std::string &path) const { bool processMarkupAfterCode(const std::string &path) const;
const std::map<std::string, bool>::const_iterator it = _processAfterCode.find(Path::getFilenameExtensionInLowerCase(path));
return (it == _processAfterCode.end() || it->second);
}
const std::set<std::string> &markupExtensions() const { const std::set<std::string> &markupExtensions() const {
return _markupExtensions; return _markupExtensions;
} }
bool reportErrors(const std::string &path) const { bool reportErrors(const std::string &path) const;
const std::map<std::string, bool>::const_iterator it = _reporterrors.find(Path::getFilenameExtensionInLowerCase(path));
return (it == _reporterrors.end() || it->second);
}
bool ignorefunction(const std::string &function) const { bool ignorefunction(const std::string &function) const {
return (_ignorefunction.find(function) != _ignorefunction.end()); return (_ignorefunction.find(function) != _ignorefunction.end());
} }
bool isexecutableblock(const std::string &file, const std::string &token) const { bool isexecutableblock(const std::string &file, const std::string &token) const;
const std::map<std::string, CodeBlock>::const_iterator it = _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _executableblocks.end() && it->second.isBlock(token));
}
int blockstartoffset(const std::string &file) const { int blockstartoffset(const std::string &file) const;
int offset = -1;
const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) { const std::string& blockstart(const std::string &file) const;
offset = map_it->second.offset(); const std::string& blockend(const std::string &file) const;
}
return offset;
}
const std::string& blockstart(const std::string &file) const { bool iskeyword(const std::string &file, const std::string &keyword) const;
const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) {
return map_it->second.start();
}
return emptyString;
}
const std::string& blockend(const std::string &file) const {
const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) {
return map_it->second.end();
}
return emptyString;
}
bool iskeyword(const std::string &file, const std::string &keyword) const {
const std::map<std::string, std::set<std::string> >::const_iterator it =
_keywords.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _keywords.end() && it->second.count(keyword));
}
bool isexporter(const std::string &prefix) const { bool isexporter(const std::string &prefix) const {
return _exporters.find(prefix) != _exporters.end(); return _exporters.find(prefix) != _exporters.end();
@ -337,11 +295,7 @@ public:
return (it != _exporters.end() && it->second.isSuffix(token)); return (it != _exporters.end() && it->second.isSuffix(token));
} }
bool isimporter(const std::string& file, const std::string &importer) const { bool isimporter(const std::string& file, const std::string &importer) const;
const std::map<std::string, std::set<std::string> >::const_iterator it =
_importers.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _importers.end() && it->second.count(importer) > 0);
}
bool isreflection(const std::string &token) const { bool isreflection(const std::string &token) const {
const std::map<std::string,int>::const_iterator it const std::map<std::string,int>::const_iterator it

View File

@ -25,7 +25,7 @@
#include <ctime> #include <ctime>
#include "config.h" #include "config.h"
enum SHOWTIME_MODES { enum SHOWTIME_MODES {
SHOWTIME_NONE = 0, SHOWTIME_NONE = 0,
SHOWTIME_FILE, SHOWTIME_FILE,
SHOWTIME_SUMMARY, SHOWTIME_SUMMARY,

View File

@ -19,6 +19,7 @@
#include "filelister.h" #include "filelister.h"
#include "testsuite.h" #include "testsuite.h"
#include "cppcheckexecutor.h" #include "cppcheckexecutor.h"
#include "path.h"
#include <fstream> #include <fstream>
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>