void writeEntry(SWModule & module, std::string const & key, std::string const & entry, bool const replace) { if (key.size() && entry.size()) { std::cout << "from file: " << key << std::endl; VerseKey *vkey = (VerseKey *)module.getKey(); std::unique_ptr<VerseKey> linkMaster( static_cast<VerseKey *>(module.createKey().release())); ListKey listKey = vkey->parseVerseList(key.c_str(), "Gen1:1", true); bool first = true; for (listKey.positionToTop(); !listKey.popError(); listKey.increment()) { vkey->positionFrom(listKey); if (first) { *linkMaster = *vkey; std::string text; if (!replace) text = module.getRawEntry(); text += entry; std::cout << "adding entry: " << vkey->getText() << " length " << entry.size() << "/" << (unsigned short)text.size() << std::endl; module.setEntry(text.c_str()); first = false; } else { std::cout << "linking entry: " << vkey->getText() << " to " << linkMaster->getText() << std::endl; module.linkEntry(*linkMaster); } } } }