From 0cf81a4421f9a4d267245a3041508b617a01d68d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 28 Dec 2017 01:02:16 +0100 Subject: Add curl get, add packages file --- include/PackageVersion.hpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++ include/curl.hpp | 12 +++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 include/PackageVersion.hpp (limited to 'include') diff --git a/include/PackageVersion.hpp b/include/PackageVersion.hpp new file mode 100644 index 0000000..99f8342 --- /dev/null +++ b/include/PackageVersion.hpp @@ -0,0 +1,56 @@ +#ifndef SIBS_PACKAGEVERSION_HPP +#define SIBS_PACKAGEVERSION_HPP + +#include + +namespace sibs +{ + /* + * Different package version syntax: + * ANY: "major.minor.patch" (xxx.xxx.xxx) + * Checks for package in several different places. First pkg-config, then local lib dir (~/.sibs/lib), then git/server. + * Example: "2.1.002" + * GIT: "branch:revision" + * Checks for package in any of the configures git servers (default: github). + * Example: "master:HEAD" + * LATEST: "latest" + * Checks for package in several different places. First git/server then pkg-config then local lib dir (~/.sibs/lib). + * + * + * GIT and LATEST first check if local lib (~/.sibs/lib) contains latest version by comparing the revision to remote revision. + */ + class PackageVersion + { + public: + enum class Type + { + ANY, + GIT, + LATEST + }; + + PackageVersion(int _major, int _minor, int _patch) : type(Type::ANY), major(_major), minor(_minor), patch(_patch) {} + PackageVersion(const std::string &&_gitBranch, const std::string &&_gitRevision) : + type(Type::GIT), + gitBranch(_gitBranch), + gitRevision(_gitRevision) + { + + } + + static PackageVersion latest() { return PackageVersion(Type::LATEST); } + private: + PackageVersion(Type _type) : type(_type) {} + private: + Type type; + + int major; + int minor; + int patch; + + std::string gitBranch; + std::string gitRevision; + }; +} + +#endif //SIBS_PACKAGEVERSION_HPP diff --git a/include/curl.hpp b/include/curl.hpp index 49dfe12..7c0ddbe 100644 --- a/include/curl.hpp +++ b/include/curl.hpp @@ -2,13 +2,23 @@ #define SIBS_CURL_HPP #include "Result.hpp" +#include namespace sibs { + class HttpResult + { + public: + long httpCode; + bool success; + std::string str; + }; + class curl { public: - static Result downloadFile(const char *url, const char *filepath); + static sibs::Result downloadFile(const char *url, const char *filepath); + static HttpResult get(const char *url); }; } -- cgit v1.2.3