mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
Bump default godot version for search
- Change error code from `NONE` TO `IGNORE` - Added format function to utils - Implement version functions
This commit is contained in:
parent
d9a9ea6426
commit
d2a77fe28f
6 changed files with 46 additions and 15 deletions
|
|
@ -11,7 +11,7 @@
|
||||||
namespace gdpm::constants::error{
|
namespace gdpm::constants::error{
|
||||||
|
|
||||||
enum class ec{
|
enum class ec{
|
||||||
NONE = 0,
|
IGNORE = 0,
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
UNKNOWN_COMMAND,
|
UNKNOWN_COMMAND,
|
||||||
UNKNOWN_ARGUMENT,
|
UNKNOWN_ARGUMENT,
|
||||||
|
|
@ -93,7 +93,7 @@ namespace gdpm{
|
||||||
namespace ce = constants::error;
|
namespace ce = constants::error;
|
||||||
class error {
|
class error {
|
||||||
public:
|
public:
|
||||||
constexpr explicit error(ec code = ec::NONE, const string& message = "{default}"):
|
constexpr explicit error(ec code = ec::IGNORE, const string& message = "{default}"):
|
||||||
m_code(code),
|
m_code(code),
|
||||||
m_message(utils::replace_all(message, "{default}", ce::get_message(code)))
|
m_message(utils::replace_all(message, "{default}", ce::get_message(code)))
|
||||||
{}
|
{}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace gdpm::rest_api{
|
||||||
int support;
|
int support;
|
||||||
string user = "";
|
string user = "";
|
||||||
string cost = "";
|
string cost = "";
|
||||||
string godot_version = "4.0";
|
string godot_version = "4.3";
|
||||||
int max_results = 500;
|
int max_results = 500;
|
||||||
int page;
|
int page;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,11 @@ namespace gdpm::utils {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename...Args>
|
||||||
|
std::string format(std::string_view fmt, Args&&...args){
|
||||||
|
return std::vformat(fmt, std::make_format_args(args...));
|
||||||
|
}
|
||||||
|
|
||||||
bool to_bool(const std::string& s);
|
bool to_bool(const std::string& s);
|
||||||
std::vector<std::string> split_lines(const std::string& contents);
|
std::vector<std::string> split_lines(const std::string& contents);
|
||||||
std::string readfile(const std::string& path);
|
std::string readfile(const std::string& path);
|
||||||
|
|
@ -97,6 +102,7 @@ namespace gdpm::utils {
|
||||||
std::string join(const std::vector<std::string>& target, const std::string& delimiter = ", ");
|
std::string join(const std::vector<std::string>& target, const std::string& delimiter = ", ");
|
||||||
std::string join(const std::unordered_map<std::string, std::string>& target, const std::string& prefix = "", const std::string& delimiter = "\n");
|
std::string join(const std::unordered_map<std::string, std::string>& target, const std::string& prefix = "", const std::string& delimiter = "\n");
|
||||||
std::string convert_size(long size);
|
std::string convert_size(long size);
|
||||||
|
|
||||||
// TODO: Add function to get size of decompressed zip
|
// TODO: Add function to get size of decompressed zip
|
||||||
|
|
||||||
namespace json {
|
namespace json {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "error.hpp"
|
||||||
|
#include "result.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
namespace gdpm::version{
|
namespace gdpm::version{
|
||||||
struct version_context{
|
struct context{
|
||||||
int major;
|
int major = 0;
|
||||||
int minor;
|
int minor = 0;
|
||||||
int patch;
|
int patch = 0;
|
||||||
|
string commit = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string to_string(const version_context& context);
|
std::string to_string(const context& context);
|
||||||
version_context to_version(const std::string& version);
|
result_t<context> to_version(const std::string& version);
|
||||||
|
bool is_valid_version_string(const std::string& version);
|
||||||
}
|
}
|
||||||
|
|
@ -343,7 +343,7 @@ namespace gdpm::config{
|
||||||
error.set_message("Key `remote_sources` is not a JSON object.");
|
error.set_message("Key `remote_sources` is not a JSON object.");
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
error.set_code(ec::NONE);
|
error.set_code(ec::IGNORE);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,35 @@
|
||||||
|
|
||||||
|
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
|
||||||
namespace gdpm::version{
|
namespace gdpm::version{
|
||||||
|
|
||||||
|
void print(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::string to_string(const version_context& context){
|
string to_string(const context& c){
|
||||||
return std::string();
|
return utils::format("{}.{}.{}", c.major, c.minor, c.patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
version_context to_version(const std::string& version){
|
result_t<context> to_version(const string& version){
|
||||||
version_context v;
|
context v;
|
||||||
|
|
||||||
return v;
|
// check if string is valid
|
||||||
|
if(!is_valid_version_string(version)){
|
||||||
|
return result_t(context(), error(ec::IGNORE, "invalid version string"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert string to version context
|
||||||
|
|
||||||
|
|
||||||
|
return result_t(v, error());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_valid_version_string(const string &version){
|
||||||
|
return std::regex_match(version, std::regex("^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue