Files
sword_rs/src/cxx/module.cc
T
Greg Hellings c8dd1ce0f0 With a little help, we now have VerseKey
Went with a basic wrapper that cxx is able to handle for the bridge
between the languages, along with simple wrapper methods
2025-06-25 02:30:42 -05:00

56 lines
1.4 KiB
C++

#include "module.h"
namespace sword_rs {
Module::Module(sword::SWModule* module) : module(module) { }
void Module::decrement() {
this->module->decrement();
}
rust::String Module::get_name() const {
return rust::String(this->module->getName());
}
rust::String Module::get_type() const {
return rust::String(this->module->getType());
}
VerseKey* Module::get_verse_key() const {
sword::VerseKey* key = dynamic_cast<sword::VerseKey*>(this->module->getKey());
if (key) {
// Create a borrowed VerseKey on the heap - caller must delete but not the inner ptr
VerseKey* result = new VerseKey{key, false};
return result;
}
return nullptr;
}
void Module::increment() {
this->module->increment();
}
bool Module::is_skip_consecutive_links() const {
return this->module->isSkipConsecutiveLinks();
}
rust::String Module::render_text() {
return std::string(
(const char*) this->module->renderText()
);
}
void Module::set_key_text(const rust::String& keyText) {
this->module->setKeyText(std::string(keyText).c_str());
}
void Module::set_skip_consecutive_links(bool skip) {
this->module->setSkipConsecutiveLinks(skip);
}
rust::String Module::strip_text() {
return std::string(
(const char*) this->module->stripText()
);
}
}