Major refactor and API changes

- Updated `.gitignore` file
- Updated `CMakeLists.txt` to build static exectuable
- Changed some `Doxyfile` configurations to build more robust and complete documentation (WIP)
- Changed how `remote` works to better reflect `git`'s API (WIP)
- Changed how error handling works
- Improved `bin/compile.sh` script
- Improved `bin/lines.sh` script (kinda)
- Removed some instances of `fmt` in favor of `std` string functions
- Restructed style for better readibility
This commit is contained in:
David Allen 2023-05-22 17:54:45 -06:00
parent ba23299777
commit 5a73651ad1
29 changed files with 1836 additions and 1140 deletions

View file

@ -2,27 +2,31 @@
#pragma once
#include "constants.hpp"
#include "package.hpp"
#include "error.hpp"
#include "result.hpp"
#include <sqlite3.h>
#include <vector>
#include <string>
namespace gdpm::package_manager{
struct package_info;
}
namespace gdpm::cache{
using namespace package_manager;
int create_package_database(const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int insert_package_info(const std::vector<package_info>& package, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
std::vector<package_info> get_package_info_by_id(const std::vector<size_t>& package_ids, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
std::vector<package_info> get_package_info_by_title(const std::vector<std::string>& package_titles, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
std::vector<package_info> get_installed_packages(const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int update_package_info(const std::vector<package_info>& packages, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int update_sync_info(const std::vector<std::string>& download_urls, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int delete_packages(const std::vector<std::string>& package_titles, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int delete_packages(const std::vector<size_t>& package_ids, const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
int drop_package_database(const std::string& cache_path = GDPM_PACKAGE_CACHE_PATH, const std::string& table_name = GDPM_PACKAGE_CACHE_TABLENAME);
namespace gdpm::cache {
struct params {
std::string cache_path = GDPM_PACKAGE_CACHE_PATH;
std::string table_name = GDPM_PACKAGE_CACHE_TABLENAME;
};
std::string to_values(const package_info& package);
std::string to_values(const std::vector<package_info>& packages);
error create_package_database(bool overwrite = false, const params& = params());
error insert_package_info(const package::info_list& packages, const params& = params());
result_t<package::info_list> get_package_info_by_id(const package::id_list& package_ids, const params& = params());
result_t<package::info_list> get_package_info_by_title(const package::title_list& package_titles, const params& params = cache::params());
result_t<package::info_list> get_installed_packages(const params& = params());
error update_package_info(const package::info_list& packages, const params& = params());
error update_sync_info(const std::vector<std::string>& download_urls, const params& = params());
error delete_packages(const package::title_list& package_titles, const params& = params());
error delete_packages(const package::id_list& package_ids, const params& = params());
error drop_package_database(const params& = params());
result_t<std::string> to_values(const package::info& package);
result_t<std::string> to_values(const package::info_list& packages);
}

View file

@ -3,32 +3,33 @@
#include "constants.hpp"
#include "error.hpp"
#include <rapidjson/document.h>
#include <string>
#include <filesystem>
#include <vector>
#include <set>
#include <unordered_map>
namespace gdpm::config{
struct context{
std::string username;
std::string password;
std::string path;
std::string token;
std::string godot_version;
std::string packages_dir;
std::string tmp_dir;
std::set<std::string> remote_sources;
string username;
string password;
string path;
string token;
string godot_version;
string packages_dir;
string tmp_dir;
string_map remote_sources;
size_t threads;
size_t timeout;
bool enable_sync;
bool enable_file_logging;
int verbose;
};
std::string to_json(const context& params);
gdpm::error load(std::filesystem::path path, context& config, int verbose = 0);
gdpm::error save(std::filesystem::path path, const context& config, int verbose = 0);
context make_context(const std::string& username = GDPM_CONFIG_USERNAME, const std::string& password = GDPM_CONFIG_PASSWORD, const std::string& path = GDPM_CONFIG_PATH, const std::string& token = GDPM_CONFIG_TOKEN, const std::string& godot_version = GDPM_CONFIG_GODOT_VERSION, const std::string& packages_dir = GDPM_CONFIG_LOCAL_PACKAGES_DIR, const std::string& tmp_dir = GDPM_CONFIG_LOCAL_TMP_DIR, const std::set<std::string>& remote_sources = {GDPM_CONFIG_REMOTE_SOURCES}, size_t threads = GDPM_CONFIG_THREADS, size_t timeout = 0, bool enable_sync = GDPM_CONFIG_ENABLE_SYNC, bool enable_file_logging = GDPM_CONFIG_ENABLE_FILE_LOGGING, int verbose = GDPM_CONFIG_VERBOSE);
string to_json(const context& params);
error load(std::filesystem::path path, context& config, int verbose = 0);
error save(std::filesystem::path path, const context& config, int verbose = 0);
context make_context(const std::string& username = GDPM_CONFIG_USERNAME, const string& password = GDPM_CONFIG_PASSWORD, const string& path = GDPM_CONFIG_PATH, const string& token = GDPM_CONFIG_TOKEN, const string& godot_version = GDPM_CONFIG_GODOT_VERSION, const string& packages_dir = GDPM_CONFIG_LOCAL_PACKAGES_DIR, const string& tmp_dir = GDPM_CONFIG_LOCAL_TMP_DIR, const string_map& remote_sources = {GDPM_CONFIG_REMOTE_SOURCES}, size_t threads = GDPM_CONFIG_THREADS, size_t timeout = 0, bool enable_sync = GDPM_CONFIG_ENABLE_SYNC, bool enable_file_logging = GDPM_CONFIG_ENABLE_FILE_LOGGING, int verbose = GDPM_CONFIG_VERBOSE);
error validate(const rapidjson::Document& doc);
extern context config;
}

View file

@ -5,6 +5,7 @@
#include <string_view>
namespace gdpm::constants{
const std::string RemoteName(std::string("origin"));
const std::string HomePath(std::string(std::getenv("HOME")) + "/");
const std::string TestPath(HomePath + ".config/gdpm/tests");
const std::string ConfigPath(HomePath + ".config/gdpm/config.json");
@ -24,7 +25,7 @@ namespace gdpm::constants{
#define GDPM_CONFIG_GODOT_VERSION "3.4"
#define GDPM_CONFIG_LOCAL_PACKAGES_DIR gdpm::constants::LocalPackagesDir
#define GDPM_CONFIG_LOCAL_TMP_DIR gdpm::constants::TemporaryPath
#define GDPM_CONFIG_REMOTE_SOURCES constants::HostUrl
#define GDPM_CONFIG_REMOTE_SOURCES std::pair<std::string, std::string>(constants::RemoteName, constants::HostUrl)
#define GDPM_CONFIG_THREADS 1
#define GDPM_CONFIG_TIMEOUT_MS 30000
#define GDPM_CONFIG_ENABLE_SYNC 1

View file

@ -1,43 +1,90 @@
#pragma once
#include <fmt/core.h>
#include <string>
#include "log.hpp"
#include "types.hpp"
#include <fmt/core.h>
#include <new>
#include <string>
#include <functional>
namespace gdpm::constants::error{
namespace gdpm::error_codes{
enum {
NONE = 0,
UNKNOWN = 1,
NOT_FOUND = 2,
FILE_EXISTS = 3,
HOST_UNREACHABLE = 4,
NONE = 0,
UNKNOWN,
UNKNOWN_COMMAND,
NOT_FOUND,
NOT_DEFINED,
NOT_IMPLEMENTED,
NO_PACKAGE_FOUND,
PATH_NOT_DEFINED,
FILE_EXISTS,
FILE_NOT_FOUND,
DIRECTORY_EXISTS,
DIRECTORY_NOT_FOULD,
HOST_UNREACHABLE,
EMPTY_RESPONSE,
INVALID_ARGS,
INVALID_CONFIG,
INVALID_KEY,
HTTP_RESPONSE_ERROR,
STD_ERROR
};
inline std::string to_string(int error_code) {
return "";
const string_list messages {
"",
"An unknown error has occurred.",
"Unknown command.",
"Resource not found.",
"Function not defined.",
"Function not implemented.",
"No package found.",
"Path is not well-defined",
"File found.",
"File does not exist.",
"Directory exists.",
"Directory not found.",
"No response from host. Host is unreacheable",
"Empty response from host.",
"Invalid arguments.",
"Invalid configuration.",
"Invalid key.",
"An HTTP response error has occurred.",
"An error has occurred."
};
inline string get_message(int error_code) {
string message{};
try{ message = messages[error_code]; }
catch(const std::bad_alloc& e){
log::error("No default message for error code.");
}
return message;
}
};
namespace gdpm{
class error {
public:
error(int code = 0, const std::string& message = "", bool print_message = false):
m_code(code), m_message(message)
{
if(print_message)
print();
}
constexpr explicit error(int code = 0, const string& message = "{code}"):
m_code(code), m_message(message == "{code}" ? constants::error::get_message(code): message)
{}
void set_code(int code) { m_code = code; }
void set_message(const std::string& message) { m_message = message; }
void set_message(const string& message) { m_message = message; }
int get_code() const { return m_code; }
std::string get_message() const { return m_message; }
bool has_error() const { return m_code != 0; }
void print(){ log::println(GDPM_COLOR_LOG_ERROR "ERROR: {}" GDPM_COLOR_LOG_RESET, m_message); }
string get_message() const { return m_message; }
bool has_occurred() const { return m_code != 0; }
bool operator()(){
return has_occurred();
}
private:
int m_code;
std::string m_message;
string m_message;
};
// Add logging function that can handle error objects

View file

@ -1,18 +1,31 @@
#pragma once
#include "constants.hpp"
#include "types.hpp"
#include <unordered_map>
namespace gdpm::http{
using headers_t = std::unordered_map<string, string>;
enum response_code{
OK = 200,
NOT_FOUND = 400
};
struct response{
long code = 0;
std::string body{};
std::unordered_map<std::string, std::string> headers{};
string body{};
headers_t headers{};
error error();
};
response request_get(const std::string& url, size_t timeout = GDPM_CONFIG_TIMEOUT_MS, int verbose = 0);
response request_post(const std::string& url, const char *post_fields="", size_t timeout = GDPM_CONFIG_TIMEOUT_MS, int verbose = 0);
response download_file(const std::string& url, const std::string& storage_path, size_t timeout = GDPM_CONFIG_TIMEOUT_MS, int verbose = 0);
struct params {
size_t timeout = GDPM_CONFIG_TIMEOUT_MS;
int verbose = 0;
};
string url_escape(const string& url);
response request_get(const string& url, const http::params& params = http::params());
response request_post(const string& url, const char *post_fields="", const http::params& params = http::params());
response download_file(const string& url, const string& storage_path, const http::params& params = http::params());
}

View file

@ -3,14 +3,14 @@
#include "utils.hpp"
#include "colors.hpp"
#include <fmt/core.h>
// #include <fmt/core.h>
#if __cplusplus > 201703L
// #include <format>
#else
#endif
#include <fmt/printf.h>
#include <fmt/format.h>
// #include <fmt/printf.h>
// #include <fmt/format.h>
/*
TODO: Allow setting the logging *prefix*

113
include/package.hpp Normal file
View file

@ -0,0 +1,113 @@
#pragma once
#include "constants.hpp"
#include "error.hpp"
#include "package.hpp"
#include "types.hpp"
#include "result.hpp"
#include "config.hpp"
#include <cstdio>
#include <filesystem>
#include <string>
#include <vector>
#include <rapidjson/document.h>
namespace gdpm::package {
struct info {
size_t asset_id;
string type;
string title;
string author;
size_t author_id;
string version;
string godot_version;
string cost;
string description;
string modify_date;
string support_level;
string category;
string remote_source;
string download_url;
string download_hash;
bool is_installed;
string install_path;
std::vector<info> dependencies;
};
struct params {
enum install_method_e{
GLOBAL_LINK_LOCAL,
GLOBAL_CLONE_LOCAL,
GLOBAL_ONLY,
LOCAL_ONLY
};
bool parallel_jobs = 1;
bool use_cache = true;
bool use_remote = true;
bool skip_prompt = false;
std::string remote_source = "";
install_method_e install_method = GLOBAL_LINK_LOCAL;
};
using info_list = std::vector<info>;
using title_list = std::vector<string>;
using id_list = std::vector<size_t>;
using path = std::string;
using path_list = std::vector<path>;
/*!
@brief Install a Godot package from the Asset Library in the current project.
By default, packages are stored in a global directory and linked to the project
where the tool is executed. Use the `--jobs` option to install packages in
parallel. Specify which remote source to use by passing the `--remote` option.
By default, the first remote source will by used. Alternatively, if the
`--use-remote=false` option is passed, then the tool will only attempt to fetch the
package from cache. Use the `--use-cache=false` option to fetch package only from
remote source.
`gdpm install "super cool example package"
To only install a package global without linking to the project, use the
`--global-only` option.
`gdpm install --global-only "super cool example package"
To install a package to a local project only, use the `--local-only` option.
This will extract the package contents to the project location instead of the
global install location. Use the `--path` option to specify an alternative
path.
`gdpm install --local-only "super cool example package" --path addons/example
To copy the package to a project instead of linking, use the `--clone` option.
`gdpm install --clone "super cool examle package"
*/
GDPM_DLL_EXPORT error install(const config::context& config, const title_list& package_titles, const params& params = package::params());
/*!
@brief Remove's package and contents from local database.
*/
GDPM_DLL_EXPORT error remove(const config::context& config, const title_list& package_titles, const params& params = package::params());
GDPM_DLL_EXPORT error remove_all(const config::context& config, const params& params = package::params());
GDPM_DLL_EXPORT error update(const config::context& config, const title_list& package_titles, const params& params = package::params());
GDPM_DLL_EXPORT error search(const config::context& config, const title_list& package_titles, const params& params = package::params());
GDPM_DLL_EXPORT error list(const config::context& config, const args_t& args, const opts_t& opts);
GDPM_DLL_EXPORT error export_to(const path_list& paths);
GDPM_DLL_EXPORT error link(const config::context& config, const title_list& package_titles, const opts_t& opts);
GDPM_DLL_EXPORT error clone(const config::context& config, const title_list& package_titles, const opts_t& opts);
GDPM_DLL_EXPORT void print_list(const rapidjson::Document& json);
GDPM_DLL_EXPORT void print_list(const info_list& packages);
GDPM_DLL_EXPORT result_t<info_list> get_package_info(const opts_t& opts);
GDPM_DLL_EXPORT result_t<title_list> get_package_titles(const info_list& packages);
GDPM_DLL_EXPORT void clean_temporary(const config::context& config, const title_list& package_titles);
/* Dependency Management API */
GDPM_DLL_EXPORT result_t<info_list> synchronize_database(const config::context& config, const title_list& package_titles);
GDPM_DLL_EXPORT result_t<info_list> resolve_dependencies(const config::context& config, const title_list& package_titles);
}

View file

@ -1,7 +1,10 @@
#pragma once
#include "config.hpp"
#include "package.hpp"
#include "package_manager.hpp"
#include "remote.hpp"
#include "result.hpp"
#include <cstdio>
#include <cxxopts.hpp>
#include <memory>
@ -12,39 +15,23 @@
#include <rapidjson/document.h>
#include <curl/curl.h>
namespace gdpm::package_manager{
extern std::vector<std::string> repo_sources;
namespace gdpm::package_manager {
extern remote::repository_map repo_sources;
extern CURL *curl;
extern CURLcode res;
extern config::context config;
struct package_info{
size_t asset_id;
std::string type;
std::string title;
std::string author;
size_t author_id;
std::string version;
std::string godot_version;
std::string cost;
std::string description;
std::string modify_date;
std::string support_level;
std::string category;
std::string remote_source;
std::string download_url;
std::string download_hash;
bool is_installed;
std::string install_path;
std::vector<package_info> dependencies;
};
struct cxxargs{
cxxopts::ParseResult result;
cxxopts::Options options;
};
enum command_e{
struct exec_args{
args_t args;
opts_t opts;
};
enum class action_e{
install,
remove,
update,
@ -60,45 +47,12 @@ namespace gdpm::package_manager{
none
};
using package_list = std::vector<package_info>;
using package_titles = std::vector<std::string>;
using cl_arg = std::variant<int, bool, float, std::string>;
using cl_args = std::vector<cl_arg>;
using cl_opts = std::unordered_map<std::string, cl_args>;
GDPM_DLL_EXPORT int initialize(int argc, char **argv);
GDPM_DLL_EXPORT int execute();
GDPM_DLL_EXPORT result_t<exec_args> initialize(int argc, char **argv);
GDPM_DLL_EXPORT int execute(const args_t& args, const opts_t& opts);
GDPM_DLL_EXPORT void finalize();
/* Package management API */
GDPM_DLL_EXPORT error install_packages(const std::vector<std::string>& package_titles, bool skip_prompt = false);
GDPM_DLL_EXPORT error remove_packages(const std::vector<std::string>& package_titles, bool skip_prompt = false);
GDPM_DLL_EXPORT error remove_all_packages();
GDPM_DLL_EXPORT error update_packages(const std::vector<std::string>& package_titles, bool skip_prompt = false);
GDPM_DLL_EXPORT error search_for_packages(const std::vector<std::string>& package_titles, bool skip_prompt = false);
GDPM_DLL_EXPORT error export_packages(const std::vector<std::string>& paths);
GDPM_DLL_EXPORT std::vector<std::string> list_information(const std::vector<std::string>& opts, bool print_list = true);
GDPM_DLL_EXPORT void clean_temporary(const std::vector<std::string>& package_titles);
GDPM_DLL_EXPORT void link_packages(const std::vector<std::string>& package_titles, const std::vector<std::string>& paths);
GDPM_DLL_EXPORT void clone_packages(const std::vector<std::string>& package_titles, const std::vector<std::string>& paths);
/* Remote API */
GDPM_DLL_EXPORT error _handle_remote(const std::vector<std::string>& args, const std::vector<std::string>& opts);
GDPM_DLL_EXPORT void remote_add_repository(const std::vector<std::string>& repositories);
GDPM_DLL_EXPORT void remote_remove_respository(const std::vector<std::string>& repositories);
GDPM_DLL_EXPORT void remote_remove_respository(ssize_t index);
GDPM_DLL_EXPORT void remote_move_repository(int old_position, int new_position);
/* Auxiliary Functions */
GDPM_DLL_EXPORT cxxargs _parse_arguments(int argc, char **argv);
GDPM_DLL_EXPORT void _handle_arguments(const cxxargs& args);
GDPM_DLL_EXPORT void run_command(command_e command, const std::vector<std::string>& package_titles, const std::vector<std::string>& opts);
GDPM_DLL_EXPORT void print_package_list(const rapidjson::Document& json);
GDPM_DLL_EXPORT void print_package_list(const std::vector<package_info>& packages);
GDPM_DLL_EXPORT void print_remote_sources();
GDPM_DLL_EXPORT std::vector<std::string> get_package_titles(const std::vector<package_info>& packages);
/* Dependency Management API */
GDPM_DLL_EXPORT std::vector<package_info> synchronize_database(const std::vector<std::string>& package_titles);
GDPM_DLL_EXPORT std::vector<std::string> resolve_dependencies(const std::vector<std::string>& package_titles);
GDPM_DLL_EXPORT result_t<exec_args> _handle_arguments(const cxxargs& args);
GDPM_DLL_EXPORT void run_command(action_e command, const package::title_list& package_titles, const opts_t& opts);
}

View file

@ -2,7 +2,7 @@
#include <string>
namespace towk::plugin{
namespace gdpm::plugin{
struct info{
std::string name;
std::string description;

21
include/remote.hpp Normal file
View file

@ -0,0 +1,21 @@
#pragma once
#include "constants.hpp"
#include "error.hpp"
#include "types.hpp"
#include <fmt/core.h>
#include <unordered_map>
#include "config.hpp"
namespace gdpm::remote{
using repo_names = string_list;
using repo_urls = string_list;
using repository_map = string_map;
GDPM_DLL_EXPORT error _handle_remote(config::context& config, const args_t& args, const opts_t& opts);
GDPM_DLL_EXPORT void set_repositories(config::context& context, const repository_map& repos);
GDPM_DLL_EXPORT void add_repositories(config::context& context, const repository_map& repos);
GDPM_DLL_EXPORT void remove_respositories(config::context& context, const repo_names& name);
GDPM_DLL_EXPORT void move_repository(config::context& context, int old_position, int new_position);
GDPM_DLL_EXPORT void print_repositories(const config::context& context);
}

View file

@ -1,5 +1,6 @@
#include "constants.hpp"
#include "config.hpp"
#include <rapidjson/document.h>
#include <rapidjson/writer.h>
#include <rapidjson/stringbuffer.h>
@ -47,6 +48,7 @@ namespace gdpm::rest_api{
int verbose;
};
context make_from_config(const config::context& config);
context make_context(type_e type = GDPM_DEFAULT_ASSET_TYPE, int category = GDPM_DEFAULT_ASSET_CATEGORY, support_e support = GDPM_DEFAULT_ASSET_SUPPORT, const std::string& filter = GDPM_DEFAULT_ASSET_FILTER, const std::string& user = GDPM_DEFAULT_ASSET_USER, const std::string& godot_version = GDPM_DEFAULT_ASSET_GODOT_VERSION, int max_results = GDPM_DEFAULT_ASSET_MAX_RESULTS, int page = GDPM_DEFAULT_ASSET_PAGE, sort_e sort = GDPM_DEFAULT_ASSET_SORT, bool reverse = GDPM_DEFAULT_ASSET_REVERSE, int verbose = GDPM_DEFAULT_ASSET_VERBOSE);
std::string to_string(type_e type);

73
include/result.hpp Normal file
View file

@ -0,0 +1,73 @@
#pragma once
#include "log.hpp"
#include "error.hpp"
#include "types.hpp"
#include <functional>
#include <type_traits>
namespace gdpm{
template <class T, error_t U = error>
class result_t {
public:
result_t() = delete;
result_t(
std::tuple<T, U> tuple,
std::function<T()> ok = []() -> T{},
std::function<void()> error = [](){}
): data(tuple), fn_ok(ok), fn_error(error)
{ }
result_t(
T target,
U error,
std::function<std::unique_ptr<T>()> _fn_ok = []() -> std::unique_ptr<T>{ return nullptr; },
std::function<void()> _fn_error = [](){}
): data(std::make_tuple(target, error)), fn_ok(_fn_ok), fn_error(_fn_error)
{}
void define(
std::function<T()> ok,
std::function<U()> error
){
fn_ok = ok;
fn_error = error;
}
constexpr std::unique_ptr<T> unwrap() const {
/* First, check if ok() and error() are defined. */
if(!fn_error || !fn_ok){
error error(
constants::error::NOT_DEFINED
);
log::error(error);
return nullptr;
}
/* Then, attempt unwrap the data. */
U err = std::get<U>(data);
if (err.has_occurred())
if(fn_error){
fn_error();
return nullptr;
}
return fn_ok();
}
constexpr T unwrap_or(T default_value) const {
U err = std::get<U>(data);
if(err.has_occurred())
return default_value;
return fn_ok();
}
constexpr T unwrap_unsafe() const {
return std::get<T>(data);
}
private:
std::tuple<T, U> data;
std::function<std::unique_ptr<T>()> fn_ok;
std::function<void()> fn_error;
};
}

View file

@ -1,6 +1,14 @@
#pragma once
#include <tuple>
#include <functional>
#include <type_traits>
#include <string>
#include <variant>
namespace gdpm{
class error;
/*
Base class to prevent derived class from creating copies.
*/
@ -20,4 +28,20 @@ namespace gdpm{
non_movable(const non_movable&) = delete;
non_movable(non_movable&&) = delete;
};
template <typename T>
concept error_t = requires{ std::is_same<error, T>::value; };
using string = std::string;
using string_list = std::vector<string>;
using string_map = std::unordered_map<string, string>;
using string_pair = std::pair<string, string>;
using var = std::variant<int, bool, float, std::string>;
template <typename T = var>
using _args_t = std::vector<T>;
using args_t = _args_t<string>;
template <typename Key = std::string, class Value = _args_t<var>>
using _opts_t = std::unordered_map<Key, Value>;
using opts_t = _opts_t<string, string_list>;
}

View file

@ -102,21 +102,6 @@ namespace gdpm::utils{
std::string prompt_user(const char *message);
bool prompt_user_yn(const char *message);
void delay(std::chrono::milliseconds milliseconds = GDPM_REQUEST_DELAY);
std::string join(const std::vector<std::string>& target, const std::string& delimiter = ", ");
// TODO: Add function to get size of decompressed zip
}
namespace gdpm{
class non_copyable{
public:
non_copyable(){}
private:
non_copyable(const non_copyable&);
non_copyable& operator=(const non_copyable&);
};
class non_movable{
non_movable(const non_movable&) = delete;
non_movable(non_movable&&) = delete;
};
}