Able to fetch a list of module names

This commit is contained in:
Greg Hellings
2025-02-24 20:55:06 -06:00
parent 1a6e51579b
commit 3e2cd701d0
8 changed files with 184 additions and 8 deletions
+18 -2
View File
@@ -1,8 +1,24 @@
#include "mgr.h"
#include <swmgr.h>
Mgr::Mgr() : mgr(new sword::SWMgr()) { }
Mgr::Mgr() { }
// Only the last argument is different from default - we want to limit this to ONLY the given directory
Mgr::Mgr(const char *path) : sword::SWMgr(path, true, 0, false, false) { }
rust::Vec<rust::String> Mgr::get_modules() const {
rust::Vec<rust::String> v;
v.reserve(this->getModules().size());
for (sword::ModMap::const_iterator it = this->getModules().begin(); it != this->getModules().end(); ++it) {
v.push_back(rust::String(it->first.c_str()));
}
return v;
}
std::unique_ptr<Mgr> new_mgr() {
return std::unique_ptr<Mgr>(new Mgr());
}
std::unique_ptr<Mgr> new_mgr_with_path(const rust::String &path) {
std::string cpath(path);
return std::unique_ptr<Mgr>(new Mgr(cpath.c_str()));
}
+6 -4
View File
@@ -1,14 +1,16 @@
#pragma once
#include <memory>
#include <string>
#include <sword/swmgr.h>
#include "rust/cxx.h"
class Mgr {
class Mgr : public sword::SWMgr {
public:
Mgr();
private:
sword::SWMgr* mgr;
Mgr(const char*);
rust::Vec<rust::String> get_modules() const;
};
std::unique_ptr<Mgr> new_mgr();
std::unique_ptr<Mgr> new_mgr_with_path(const rust::String &path);