mason/src/dependency.h

42 lines
952 B
C
Raw Normal View History

2023-08-31 20:06:02 +00:00
#pragma once
#include <string>
#include <optional>
2023-09-01 21:39:24 +00:00
#include <filesystem>
#include <curl/curl.h>
#include <stdio.h>
2023-08-31 20:06:02 +00:00
class Dependency {
public:
enum class Type {
automatic,
simple,
mason
};
Dependency(
const std::string& path,
Type type = Type::automatic,
const std::optional<std::string>& name = std::nullopt,
const std::optional<std::string>& version = std::nullopt
);
Type getType() const;
std::optional<std::string> getName() const;
std::optional<std::string> getVersion() const;
2023-09-01 21:39:24 +00:00
bool prepare(const std::filesystem::path& source, const std::filesystem::path& destination);
2023-08-31 20:06:02 +00:00
const std::string path;
2023-09-01 21:39:24 +00:00
private:
static size_t write(void *file, size_t size, size_t nmemb, void *stream);
bool download(const std::filesystem::path& destination);
2023-08-31 20:06:02 +00:00
private:
Type type;
std::optional<std::string> name;
std::optional<std::string> version;
};