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:
David Allen 2024-01-27 14:34:17 -07:00
parent d9a9ea6426
commit d2a77fe28f
6 changed files with 46 additions and 15 deletions

View file

@ -343,7 +343,7 @@ namespace gdpm::config{
error.set_message("Key `remote_sources` is not a JSON object.");
return error;
}
error.set_code(ec::NONE);
error.set_code(ec::IGNORE);
return error;
}

View file

@ -1,16 +1,35 @@
#include "version.hpp"
#include <regex>
namespace gdpm::version{
void print(){
}
std::string to_string(const version_context& context){
return std::string();
string to_string(const context& c){
return utils::format("{}.{}.{}", c.major, c.minor, c.patch);
}
version_context to_version(const std::string& version){
version_context v;
result_t<context> to_version(const string& version){
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+)$"));
}
}