Blame lib/importproject.h

Packit 2035a7
/*
Packit 2035a7
 * Cppcheck - A tool for static C/C++ code analysis
Packit 2035a7
 * Copyright (C) 2007-2017 Cppcheck team.
Packit 2035a7
 *
Packit 2035a7
 * This program is free software: you can redistribute it and/or modify
Packit 2035a7
 * it under the terms of the GNU General Public License as published by
Packit 2035a7
 * the Free Software Foundation, either version 3 of the License, or
Packit 2035a7
 * (at your option) any later version.
Packit 2035a7
 *
Packit 2035a7
 * This program is distributed in the hope that it will be useful,
Packit 2035a7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 2035a7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 2035a7
 * GNU General Public License for more details.
Packit 2035a7
 *
Packit 2035a7
 * You should have received a copy of the GNU General Public License
Packit 2035a7
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 2035a7
 */
Packit 2035a7
Packit 2035a7
//---------------------------------------------------------------------------
Packit 2035a7
#ifndef importprojectH
Packit 2035a7
#define importprojectH
Packit 2035a7
//---------------------------------------------------------------------------
Packit 2035a7
Packit 2035a7
#include "config.h"
Packit 2035a7
#include "platform.h"
Packit 2035a7
#include "utils.h"
Packit 2035a7
Packit 2035a7
#include <list>
Packit 2035a7
#include <map>
Packit 2035a7
#include <set>
Packit 2035a7
#include <string>
Packit 2035a7
#include <vector>
Packit 2035a7
Packit 2035a7
/// @addtogroup Core
Packit 2035a7
/// @{
Packit 2035a7
Packit 2035a7
namespace cppcheck {
Packit 2035a7
    struct stricmp {
Packit 2035a7
        bool operator()(const std::string &lhs, const std::string &rhs) const {
Packit 2035a7
            return caseInsensitiveStringCompare(lhs,rhs) < 0;
Packit 2035a7
        }
Packit 2035a7
    };
Packit 2035a7
}
Packit 2035a7
Packit 2035a7
/**
Packit 2035a7
 * @brief Importing project settings.
Packit 2035a7
 */
Packit 2035a7
class CPPCHECKLIB ImportProject {
Packit 2035a7
public:
Packit 2035a7
    /** File settings. Multiple configurations for a file is allowed. */
Packit 2035a7
    struct CPPCHECKLIB FileSettings {
Packit 2035a7
        FileSettings() : platformType(cppcheck::Platform::Unspecified), msc(false), useMfc(false) {}
Packit 2035a7
        std::string cfg;
Packit 2035a7
        std::string filename;
Packit 2035a7
        std::string defines;
Packit 2035a7
        std::string cppcheckDefines() const {
Packit 2035a7
            return defines + (msc ? ";_MSC_VER=1900" : "") + (useMfc ? ";__AFXWIN_H__=1" : "");
Packit 2035a7
        }
Packit 2035a7
        std::set<std::string> undefs;
Packit 2035a7
        std::list<std::string> includePaths;
Packit 2035a7
        std::list<std::string> systemIncludePaths;
Packit 2035a7
        std::string standard;
Packit 2035a7
        cppcheck::Platform::PlatformType platformType;
Packit 2035a7
        bool msc;
Packit 2035a7
        bool useMfc;
Packit 2035a7
Packit 2035a7
        void setDefines(std::string defs);
Packit 2035a7
        void setIncludePaths(const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string, cppcheck::stricmp> &variables);
Packit 2035a7
    };
Packit 2035a7
    std::list<FileSettings> fileSettings;
Packit 2035a7
Packit 2035a7
    void ignorePaths(const std::vector<std::string> &ipaths);
Packit 2035a7
    void ignoreOtherConfigs(const std::string &cfg;;
Packit 2035a7
    void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType);
Packit 2035a7
Packit 2035a7
    void import(const std::string &filename);
Packit 2035a7
protected:
Packit 2035a7
    void importCompileCommands(std::istream &istr);
Packit 2035a7
private:
Packit 2035a7
    void importSln(std::istream &istr, const std::string &path);
Packit 2035a7
    void importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories);
Packit 2035a7
};
Packit 2035a7
Packit 2035a7
/// @}
Packit 2035a7
//---------------------------------------------------------------------------
Packit 2035a7
#endif // importprojectH