Exemple #1
0
std::unique_ptr<Workspace> JsonImporter::ImportWorkspace(FileManager& fileManager, const filesystem::path& workspaceFile)
{
    auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), workspaceFile);

    if (internal::IsValidWorkspace(json))
    {
        auto workspace = std::make_unique<Workspace>();

        workspace->SetName(json["workspace"]);
        workspace->SetFile(workspaceFile);

        auto& projects = json["projects"];

        if (projects.is_array())
        {
            auto workspacePath = workspaceFile.parent_path();

            for (auto& project : projects)
            {
                workspace->AddProject(ImportProject(fileManager, workspacePath / project));
            }
        }

        return workspace;
    }

    return nullptr;
}
Exemple #2
0
std::unique_ptr<Project> JsonImporter::ImportProject(FileManager& fileManager, const filesystem::path& projectFile)
{
    auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), projectFile);

    if (internal::IsValidProject(json))
    {
        auto project = std::make_unique<Project>();

        project->SetName(json["project"]);
        project->SetFile(projectFile);

        for (auto& config : json["configs"])
        {
            project->AddConfiguration(internal::ImportConfig(config));
        }

        for (auto& filePath : json["files"])
        {
            project->AddFile(fileManager.GetOrCreateFile(filePath));
        }

        return project;
    }

    return nullptr;
}
Exemple #3
0
    void File::ReadDependencies(FileManager& fileManager, const filesystem::path& file)
    {
        auto dependencyFile = fileManager.GetOrCreateFile(file);
        auto dependencyFileStream = fileManager.GetFileSystem().OpenStream(file);

        if (dependencyFileStream)
        {
            std::string line;
            std::getline(*dependencyFileStream, line, ':');

            while (std::getline(*dependencyFileStream, line, '\\'))
            {
                AddDependency(fileManager.GetOrCreateFile(internal::Trim(line)));
            }
        }
    }