aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Archive.hpp15
-rw-r--r--include/GlobalLib.hpp8
-rw-r--r--include/Result.hpp26
-rw-r--r--include/curl.hpp15
-rw-r--r--include/env.hpp4
-rwxr-xr-xinclude/utils.hpp1
6 files changed, 62 insertions, 7 deletions
diff --git a/include/Archive.hpp b/include/Archive.hpp
new file mode 100644
index 0000000..6d6a55d
--- /dev/null
+++ b/include/Archive.hpp
@@ -0,0 +1,15 @@
+#ifndef SIBS_ZLIB_HPP
+#define SIBS_ZLIB_HPP
+
+#include "Result.hpp"
+
+namespace sibs
+{
+ class Archive
+ {
+ public:
+ static Result<bool> extract(const char *source, const char *destination);
+ };
+}
+
+#endif //SIBS_ZLIB_HPP
diff --git a/include/GlobalLib.hpp b/include/GlobalLib.hpp
index d5e21d1..ca542f9 100644
--- a/include/GlobalLib.hpp
+++ b/include/GlobalLib.hpp
@@ -3,14 +3,22 @@
#include "Result.hpp"
#include "Linker.hpp"
+#include "Dependency.hpp"
namespace sibs
{
class GlobalLib
{
public:
+ enum DependencyError
+ {
+ DEPENDENCY_NOT_FOUND = 10,
+ DEPENDENCY_VERSION_NO_MATCH = 20
+ };
+
static Result<bool> validatePackageExists(const std::string &globalLibRootDir, const std::string &name);
static Result<std::string> getStaticLibsLinkerFlags(const std::string &globalLibRootDir, const std::string &name, const std::string &version, LinkerFlagCallbackFunc linkerFlagCallbackFunc);
+ static Result<bool> downloadDependency(const Dependency &dependency);
};
}
diff --git a/include/Result.hpp b/include/Result.hpp
index f755b15..eb0aa01 100644
--- a/include/Result.hpp
+++ b/include/Result.hpp
@@ -13,20 +13,29 @@ namespace sibs
static Result Ok(const T &value)
{
Result result(value);
- result.error = false;
+ result.errorCode = 0;
return result;
}
- static Result Err(const std::string &errMsg)
+ template <typename OtherType>
+ static Result Err(const Result<OtherType> &other)
+ {
+ Result result;
+ result.errMsg = other.getErrMsg();
+ result.errorCode = other.getErrorCode();
+ return result;
+ }
+
+ static Result Err(const std::string &errMsg, int errorCode = 1)
{
Result result;
result.errMsg = errMsg;
- result.error = true;
+ result.errorCode = errorCode;
return result;
}
- bool isOk() const { return !error; }
- bool isErr() const { return error; }
+ bool isOk() const { return !errorCode; }
+ bool isErr() const { return errorCode; }
T& unwrap()
{
@@ -39,12 +48,17 @@ namespace sibs
assert(isErr());
return errMsg;
}
+
+ int getErrorCode() const
+ {
+ return errorCode;
+ }
private:
Result(const T &_value = T()) : value(_value) {}
private:
T value;
std::string errMsg;
- bool error;
+ int errorCode;
};
}
diff --git a/include/curl.hpp b/include/curl.hpp
new file mode 100644
index 0000000..49dfe12
--- /dev/null
+++ b/include/curl.hpp
@@ -0,0 +1,15 @@
+#ifndef SIBS_CURL_HPP
+#define SIBS_CURL_HPP
+
+#include "Result.hpp"
+
+namespace sibs
+{
+ class curl
+ {
+ public:
+ static Result<bool> downloadFile(const char *url, const char *filepath);
+ };
+}
+
+#endif //SIBS_CURL_HPP
diff --git a/include/env.hpp b/include/env.hpp
index 325db6e..f5b1213 100644
--- a/include/env.hpp
+++ b/include/env.hpp
@@ -33,4 +33,8 @@
#error "System not support. Only Windows and Posix systems support"
#endif
+#if !defined(DEBUG) && !defined(NDEBUG)
+#define DEBUG
+#endif
+
#endif // SIBS_ENV_HPP
diff --git a/include/utils.hpp b/include/utils.hpp
index 9ad9d97..926749d 100755
--- a/include/utils.hpp
+++ b/include/utils.hpp
@@ -4,7 +4,6 @@
// Disable copying for a class or struct
#define DISABLE_COPY(ClassName) \
ClassName(ClassName&) = delete; \
- ClassName(ClassName&&) = delete; \
ClassName& operator = (ClassName&) = delete;
#endif // SIBS_UTILS_HPP