void RawGenBook::linkEntry(SWKey const & inkey) { TreeKeyIdx * key_ = ((TreeKeyIdx *)&(getTreeKey())); // see if we have a VerseKey * or decendant /// \bug Remove const_cast: TreeKeyIdx * srckey = const_cast<TreeKeyIdx *>(dynamic_cast<TreeKeyIdx const *>(&inkey)); // if we don't have a VerseKey * decendant, create our own if (!srckey) { srckey = static_cast<TreeKeyIdx *>(createKey().release()); srckey->positionFrom(inkey); } key_->setUserData(srckey->getUserData(), 8); key_->save(); if (&inkey != srckey) // free our key if we created a VerseKey delete srckey; }
void RawGenBook::linkEntry(const SWKey *inkey) { TreeKeyIdx *srckey = 0; TreeKeyIdx *key = ((TreeKeyIdx *)&(getTreeKey())); // see if we have a VerseKey * or decendant SWTRY { srckey = SWDYNAMIC_CAST(TreeKeyIdx, inkey); } SWCATCH ( ... ) {} // if we don't have a VerseKey * decendant, create our own if (!srckey) { srckey = (TreeKeyIdx *)createKey(); (*srckey) = *inkey; } key->setUserData(srckey->getUserData(), 8); key->save(); if (inkey != srckey) // free our key if we created a VerseKey delete srckey; }