src: Project Refactoring
* Added language specific Project and ProjectSettings * moved project specific code from Application to Project * made Application a singleton * added handleDialog method to Application which displays a dialog window and waits for user input * Added ScopedFunctor that executes a function when deleted
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings()
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings(const FilePath& projectFilePath)
|
||||
: ProjectSettings(projectFilePath)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::CxxProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
: ProjectSettings(projectName, projectFileLocation)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
CxxProjectSettings::~CxxProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
{
|
||||
const CxxProjectSettings* typedOther = dynamic_cast<const CxxProjectSettings*>(&other);
|
||||
return(
|
||||
ProjectSettings::equalsExceptNameAndLocation(other)// &&
|
||||
// utility::isPermutation<FilePath>(getClasspaths(), typedOther->getClasspaths())
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/header_search_paths/header_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getAbsoluteHeaderSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getHeaderSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/framework_search_paths/framework_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> CxxProjectSettings::getAbsoluteFrameworkSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getFrameworkSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxProjectSettings::getCompilerFlags() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/compiler_flags/compiler_flag", defaultValues);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setCompilerFlags(const std::vector<std::string>& compilerFlags)
|
||||
{
|
||||
return setValues("source/compiler_flags/compiler_flag", compilerFlags);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::getUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return getValue<bool>("source/use_source_paths_for_header_search", false);
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch)
|
||||
{
|
||||
return setValue<bool>("source/use_source_paths_for_header_search", useSourcePathsForHeaderSearch);
|
||||
}
|
||||
|
||||
FilePath CxxProjectSettings::getVisualStudioSolutionPath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/vs_solution_path", ""));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/vs_solution_path", visualStudioSolutionPath.str());
|
||||
}
|
||||
|
||||
FilePath CxxProjectSettings::getCompilationDatabasePath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/compilation_db_path", ""));
|
||||
}
|
||||
|
||||
bool CxxProjectSettings::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/compilation_db_path", compilationDatabasePath.str());
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".c");
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
return defaultValues;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef CXX_PROJECT_SETTINGS_H
|
||||
#define CXX_PROJECT_SETTINGS_H
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class CxxProjectSettings: public ProjectSettings
|
||||
{
|
||||
public:
|
||||
CxxProjectSettings();
|
||||
CxxProjectSettings(const FilePath& projectFilePath);
|
||||
CxxProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~CxxProjectSettings();
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteHeaderSearchPaths() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteFrameworkSearchPaths() const;
|
||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
bool setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
bool setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
|
||||
FilePath getVisualStudioSolutionPath() const;
|
||||
bool setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath);
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
bool setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
};
|
||||
|
||||
#endif // CXX_PROJECT_SETTINGS_H
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings()
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings(const FilePath& projectFilePath)
|
||||
: ProjectSettings(projectFilePath)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::JavaProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
: ProjectSettings(projectName, projectFileLocation)
|
||||
{
|
||||
// setlanguage...
|
||||
}
|
||||
|
||||
JavaProjectSettings::~JavaProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
if (other.getLanguage() == getLanguage())
|
||||
{
|
||||
const JavaProjectSettings* typedOther = dynamic_cast<const JavaProjectSettings*>(&other);
|
||||
return(
|
||||
ProjectSettings::equalsExceptNameAndLocation(other) &&
|
||||
utility::isPermutation<FilePath>(getClasspaths(), typedOther->getClasspaths())
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<FilePath> JavaProjectSettings::getClasspaths() const
|
||||
{
|
||||
return getPathValues("source/class_paths/class_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> JavaProjectSettings::getAbsoluteClasspaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getClasspaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool JavaProjectSettings::setClasspaths(const std::vector<FilePath>& paths)
|
||||
{
|
||||
return setPathValues("source/class_paths/class_path", paths);
|
||||
}
|
||||
|
||||
std::vector<std::string> JavaProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".java");
|
||||
return defaultValues;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef JAVA_PROJECT_SETTINGS_H
|
||||
#define JAVA_PROJECT_SETTINGS_H
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class JavaProjectSettings: public ProjectSettings
|
||||
{
|
||||
public:
|
||||
JavaProjectSettings();
|
||||
JavaProjectSettings(const FilePath& projectFilePath);
|
||||
JavaProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~JavaProjectSettings();
|
||||
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
std::vector<FilePath> getClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteClasspaths() const;
|
||||
bool setClasspaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
};
|
||||
|
||||
#endif // JAVA_PROJECT_SETTINGS_H
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "settings/LanguageType.h"
|
||||
|
||||
std::string languageTypeToString(LanguageType t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
return "C";
|
||||
case LANGUAGE_CPP:
|
||||
return "C++";
|
||||
case LANGUAGE_JAVA:
|
||||
return "Java";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
LanguageType stringToLanguageType(std::string s)
|
||||
{
|
||||
if (s == "C")
|
||||
{
|
||||
return LANGUAGE_C;
|
||||
}
|
||||
else if (s == "C++")
|
||||
{
|
||||
return LANGUAGE_CPP;
|
||||
}
|
||||
else if (s == "Java")
|
||||
{
|
||||
return LANGUAGE_JAVA;
|
||||
}
|
||||
return LANGUAGE_UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef LANGUAGE_TYPE_H
|
||||
#define LANGUAGE_TYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum LanguageType
|
||||
{
|
||||
LANGUAGE_C,
|
||||
LANGUAGE_CPP,
|
||||
LANGUAGE_JAVA,
|
||||
LANGUAGE_UNKNOWN
|
||||
};
|
||||
|
||||
std::string languageTypeToString(LanguageType t);
|
||||
LanguageType stringToLanguageType(std::string s);
|
||||
|
||||
#endif // LANGUAGE_TYPE_H
|
||||
@@ -1,75 +1,83 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/JavaProjectSettings.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultSourceExtensions()
|
||||
LanguageType ProjectSettings::getLanguageOfProject(FilePath projectFilePath)
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".c");
|
||||
defaultValues.push_back(".cpp");
|
||||
defaultValues.push_back(".cxx");
|
||||
defaultValues.push_back(".cc");
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::s_instance;
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::getInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<ProjectSettings>(new ProjectSettings());
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
ProjectSettings tempSettings(projectFilePath);
|
||||
tempSettings.load();
|
||||
return tempSettings.getLanguage();
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings(const FilePath& projectFilePath)
|
||||
{
|
||||
setFilePath(projectFilePath);
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings(std::string projectName, const FilePath& projectFileLocation)
|
||||
{
|
||||
setFilePath(FilePath(projectFileLocation.str() + "/" + projectName + ".coatiproject"));
|
||||
}
|
||||
|
||||
ProjectSettings::~ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProjectSettings::operator==(const ProjectSettings& other) const
|
||||
bool ProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) const
|
||||
{
|
||||
return
|
||||
getFilePath() == other.getFilePath() &&
|
||||
return (
|
||||
getLanguage() == other.getLanguage() &&
|
||||
getStandard() == other.getStandard() &&
|
||||
getVisualStudioSolutionPath() == other.getVisualStudioSolutionPath() &&
|
||||
getCompilationDatabasePath() == other.getCompilationDatabasePath() &&
|
||||
getUseSourcePathsForHeaderSearch() == other.getUseSourcePathsForHeaderSearch() &&
|
||||
utility::isPermutation<FilePath>(getSourcePaths(), other.getSourcePaths()) &&
|
||||
utility::isPermutation<FilePath>(getHeaderSearchPaths(), other.getHeaderSearchPaths()) &&
|
||||
utility::isPermutation<FilePath>(getFrameworkSearchPaths(), other.getFrameworkSearchPaths()) &&
|
||||
utility::isPermutation<FilePath>(getExcludePaths(), other.getExcludePaths()) &&
|
||||
utility::isPermutation<std::string>(getCompilerFlags(), other.getCompilerFlags()) &&
|
||||
utility::isPermutation<std::string>(getSourceExtensions(), other.getSourceExtensions());
|
||||
utility::isPermutation<std::string>(getSourceExtensions(), other.getSourceExtensions())
|
||||
);
|
||||
}
|
||||
|
||||
bool ProjectSettings::operator!=(const ProjectSettings& other) const
|
||||
bool ProjectSettings::load()
|
||||
{
|
||||
return !(*this == other);
|
||||
return Settings::load(getFilePath());
|
||||
}
|
||||
|
||||
void ProjectSettings::save(const FilePath& filePath)
|
||||
std::string ProjectSettings::getProjectName() const
|
||||
{
|
||||
m_projectName = "";
|
||||
m_projectFileLocation = "";
|
||||
|
||||
Settings::save(filePath);
|
||||
return getFilePath().withoutExtension().fileName();
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getLanguage() const
|
||||
void ProjectSettings::setProjectName(const std::string& name)
|
||||
{
|
||||
return getValue<std::string>("language_settings/language", "C++");
|
||||
setFilePath(FilePath(getProjectFileLocation().str() + "/" + name + ".coatiproject"));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setLanguage(const std::string& language)
|
||||
FilePath ProjectSettings::getProjectFileLocation() const
|
||||
{
|
||||
return setValue<std::string>("language_settings/language", language);
|
||||
return getFilePath().parentDirectory();
|
||||
}
|
||||
|
||||
void ProjectSettings::setProjectFileLocation(const FilePath& location)
|
||||
{
|
||||
setFilePath(FilePath(location.str() + "/" + getProjectName() + ".coatiproject"));
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getDescription() const
|
||||
{
|
||||
return getValue<std::string>("info/description", "");
|
||||
}
|
||||
|
||||
LanguageType ProjectSettings::getLanguage() const
|
||||
{
|
||||
return stringToLanguageType(getValue<std::string>("language_settings/language", languageTypeToString(LANGUAGE_UNKNOWN)));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setLanguage(LanguageType language)
|
||||
{
|
||||
return setValue<std::string>("language_settings/language", languageTypeToString(language));
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getStandard() const
|
||||
@@ -82,19 +90,6 @@ bool ProjectSettings::setStandard(const std::string& standard)
|
||||
return setValue<std::string>("language_settings/standard", standard);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getJavaClasspaths() const
|
||||
{
|
||||
return getPathValues("source/class_paths/class_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteJavaClasspaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getJavaClasspaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getSourcePaths() const
|
||||
{
|
||||
return getPathValues("source/source_paths/source_path");
|
||||
@@ -113,73 +108,6 @@ bool ProjectSettings::setSourcePaths(const std::vector<FilePath>& sourcePaths)
|
||||
return setPathValues("source/source_paths/source_path", sourcePaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/header_search_paths/header_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteHeaderSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getHeaderSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ProjectSettings::setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths)
|
||||
{
|
||||
return setPathValues("source/header_search_paths/header_search_path", headerSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
return getPathValues("source/framework_search_paths/framework_search_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteFrameworkSearchPaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getFrameworkSearchPaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ProjectSettings::setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths)
|
||||
{
|
||||
return setPathValues("source/framework_search_paths/framework_search_path", frameworkSearchPaths);
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getCompilerFlags() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/compiler_flags/compiler_flag", defaultValues);
|
||||
}
|
||||
|
||||
bool ProjectSettings::setCompilerFlags(const std::vector<std::string>& compilerFlags)
|
||||
{
|
||||
return setValues("source/compiler_flags/compiler_flag", compilerFlags);
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getSourceExtensions() const
|
||||
{
|
||||
return getValues("source/extensions/source_extensions", getDefaultSourceExtensions());
|
||||
}
|
||||
|
||||
bool ProjectSettings::setSourceExtensions(const std::vector<std::string> &sourceExtensions)
|
||||
{
|
||||
return setValues("source/extensions/source_extensions", sourceExtensions);
|
||||
}
|
||||
|
||||
bool ProjectSettings::getUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return getValue<bool>("source/use_source_paths_for_header_search", false);
|
||||
}
|
||||
|
||||
bool ProjectSettings::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch)
|
||||
{
|
||||
return setValue<bool>("source/use_source_paths_for_header_search", useSourcePathsForHeaderSearch);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getExcludePaths() const
|
||||
{
|
||||
return getPathValues("source/exclude_paths/exclude_path");
|
||||
@@ -198,59 +126,14 @@ bool ProjectSettings::setExcludePaths(const std::vector<FilePath>& excludePaths)
|
||||
return setPathValues("source/exclude_paths/exclude_path", excludePaths);
|
||||
}
|
||||
|
||||
FilePath ProjectSettings::getVisualStudioSolutionPath() const
|
||||
std::vector<std::string> ProjectSettings::getSourceExtensions() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/vs_solution_path", ""));
|
||||
return getValues("source/extensions/source_extensions", getDefaultSourceExtensions());
|
||||
}
|
||||
|
||||
bool ProjectSettings::setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath)
|
||||
bool ProjectSettings::setSourceExtensions(const std::vector<std::string> &sourceExtensions)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/vs_solution_path", visualStudioSolutionPath.str());
|
||||
}
|
||||
|
||||
FilePath ProjectSettings::getCompilationDatabasePath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/compilation_db_path", ""));
|
||||
}
|
||||
|
||||
bool ProjectSettings::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
return setValue<std::string>("source/build_file_path/compilation_db_path", compilationDatabasePath.str());
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getDescription() const
|
||||
{
|
||||
return getValue<std::string>("info/description", "");
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getProjectName() const
|
||||
{
|
||||
if (m_projectName.size())
|
||||
{
|
||||
return m_projectName;
|
||||
}
|
||||
|
||||
return getFilePath().withoutExtension().fileName();
|
||||
}
|
||||
|
||||
void ProjectSettings::setProjectName(const std::string& name)
|
||||
{
|
||||
m_projectName = name;
|
||||
}
|
||||
|
||||
FilePath ProjectSettings::getProjectFileLocation() const
|
||||
{
|
||||
if (!m_projectFileLocation.empty())
|
||||
{
|
||||
return m_projectFileLocation;
|
||||
}
|
||||
|
||||
return getFilePath().parentDirectory();
|
||||
}
|
||||
|
||||
void ProjectSettings::setProjectFileLocation(const FilePath& location)
|
||||
{
|
||||
m_projectFileLocation = location;
|
||||
return setValues("source/extensions/source_extensions", sourceExtensions);
|
||||
}
|
||||
|
||||
void ProjectSettings::makePathsAbsolute(std::vector<FilePath>& paths) const
|
||||
@@ -264,3 +147,8 @@ void ProjectSettings::makePathsAbsolute(std::vector<FilePath>& paths) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultSourceExtensions() const
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
@@ -5,82 +5,53 @@
|
||||
#include <vector>
|
||||
|
||||
#include "settings/Settings.h"
|
||||
#include "settings/LanguageType.h"
|
||||
|
||||
class ProjectSettings
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getDefaultSourceExtensions();
|
||||
static LanguageType getLanguageOfProject(FilePath projectFilePath);
|
||||
|
||||
static std::shared_ptr<ProjectSettings> getInstance();
|
||||
ProjectSettings();
|
||||
~ProjectSettings();
|
||||
ProjectSettings(const FilePath& projectFilePath);
|
||||
ProjectSettings(std::string projectName, const FilePath& projectFileLocation);
|
||||
virtual ~ProjectSettings();
|
||||
|
||||
bool operator==(const ProjectSettings& other) const;
|
||||
bool operator!=(const ProjectSettings& other) const;
|
||||
virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const;
|
||||
|
||||
virtual void save(const FilePath& filePath);
|
||||
virtual bool load();
|
||||
|
||||
// language settings
|
||||
std::string getLanguage() const;
|
||||
bool setLanguage(const std::string& language);
|
||||
|
||||
std::string getStandard() const;
|
||||
bool setStandard(const std::string& standard);
|
||||
|
||||
// java... todo: move this
|
||||
std::vector<FilePath> getJavaClasspaths() const;
|
||||
std::vector<FilePath> getAbsoluteJavaClasspaths() const;
|
||||
|
||||
// source
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
std::vector<FilePath> getAbsoluteSourcePaths() const;
|
||||
bool setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
std::vector<FilePath> getHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteHeaderSearchPaths() const;
|
||||
bool setHeaderSearchPaths(const std::vector<FilePath>& headerSearchPaths);
|
||||
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<FilePath> getAbsoluteFrameworkSearchPaths() const;
|
||||
bool setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
bool setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
bool setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getAbsoluteExcludePaths() const;
|
||||
bool setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
FilePath getVisualStudioSolutionPath() const;
|
||||
bool setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath);
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
bool setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
// info
|
||||
std::string getDescription() const;
|
||||
|
||||
// used in project wizzard
|
||||
std::string getProjectName() const;
|
||||
void setProjectName(const std::string& name);
|
||||
|
||||
FilePath getProjectFileLocation() const;
|
||||
void setProjectFileLocation(const FilePath& location);
|
||||
|
||||
private:
|
||||
std::string getDescription() const;
|
||||
|
||||
LanguageType getLanguage() const;
|
||||
bool setLanguage(LanguageType language);
|
||||
|
||||
std::string getStandard() const;
|
||||
bool setStandard(const std::string& standard);
|
||||
|
||||
std::vector<FilePath> getSourcePaths() const;
|
||||
std::vector<FilePath> getAbsoluteSourcePaths() const;
|
||||
bool setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getAbsoluteExcludePaths() const;
|
||||
bool setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
|
||||
protected:
|
||||
void makePathsAbsolute(std::vector<FilePath>& paths) const;
|
||||
|
||||
std::string m_projectName;
|
||||
FilePath m_projectFileLocation;
|
||||
|
||||
static std::shared_ptr<ProjectSettings> s_instance;
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
};
|
||||
|
||||
#endif // PROJECT_SETTINGS_H
|
||||
|
||||
@@ -15,12 +15,13 @@ public:
|
||||
Settings& operator=(const Settings& other);
|
||||
virtual ~Settings();
|
||||
|
||||
bool load(const FilePath& filePath);
|
||||
void save();
|
||||
virtual bool load(const FilePath& filePath);
|
||||
virtual void save();
|
||||
virtual void save(const FilePath& filePath);
|
||||
|
||||
void clear();
|
||||
|
||||
const FilePath& getFilePath() const;
|
||||
virtual const FilePath& getFilePath() const;
|
||||
|
||||
protected:
|
||||
Settings();
|
||||
|
||||
Reference in New Issue
Block a user