const ObjPtrValue *
Reflection::New(const string &type_name) {
    char name[40];
   // cout << "Instantiation of type " << type_name << " requested." << endl;
   // cout << "CHANGE THIS: " << " currently hard-code to type AA." << endl;
    void *hh = dlsym(this->handle,"mi");
     if (hh == 0) {
        cerr << dlerror() << endl;
        abort();
    }
   else
    {
    //  cout << "\n Successful \n " ;
    }
    
    MetaInfo *minfo = *(MetaInfo **)hh;
    t_meta = minfo;
    const ObjPtrValue *ret_val = minfo->create();
    refl_tble[type_name] = minfo;
    refl_tble1[ret_val] = type_name;
    //cout << type_name;
    //cout << "\n typename :" << typeid().name() ;
 //   ObjPtrValue_tmpl<type_name> *opv = dynamic_cast<ObjPtrValue_tmpl<type_name> *>(ret_val);
    //const ObjPtrValue_tmpl<type_name> *obj = const new ObjPtrValue_tmpl<type_name>(new type_name);
 //   sprintf(name,"%s",typeid(opv->m_obj).name());
    //cout << "\n typename :" << typeid(obj->m_obj).name() ;
    //char temp[30];
   // cout << "\n name is : " << name << "\n";
    return ret_val;
    //return new ObjPtrValue_tmpl<AA>(new AA);
}
Esempio n. 2
0
//------------------------------------------------------------------------------
bool BibleQuoteModule::createIniFile(MetaInfo info)
{
    /// добавить обработку типа
    QString text =
            "////Module for QSopherim"
            "\nModuleName = " + info.name() +
            "\nModuleShortName = " + info.shortName() +
            "\nModuleLanguage = " + info.language +
            "\nBooksValue = " + m_bookCount +
            "\nModuleVerseSign = " + m_verseSign +
            "\nModuleChapterSign = " + m_chapterSign +
            "\nModuleChapterZero = " + m_chapterZero +
            "\nStrongNumber = " + m_strongOption +
            "\nTypeModule = " + m_typeModule;


    text.append(QString("\nPathToModule = %1/%2/module%3")
                .arg(m_typeModule.toLower())
                .arg(info.shortName())
                .arg(GL_FORMAT_MODULE));

    text.append("\nBookList = ");
    for(int i = 0; i < m_bookList.size(); i++)
    {
        text.append(m_bookList.at(i) + "[*:*]");
    }

    text.append("\nNumberChapter = ");
    for(int i = 0; i < m_bookList.size(); i++)
    {
        QString str = m_bookList.at(i) + "^" + QString::number(m_bookCountSize[i])
                + GL_SYMBOL_SPLIT_CHAPTER ;
        text.append(str);
    }

    //    myDebug() << m_bookPath;
    QString t_pathToIniFile = QString(QString(Config::configuration()->getDataPath() + GL_MODULE_PATH + "%1/" +
                                                                info.shortName() + "/module" + GL_FORMAT_MODULE).arg(m_typeModule.toLower()));

    if (QFile::exists(t_pathToIniFile))
    {
        QFile::remove(t_pathToIniFile);
    }



    QString r_str = QString(Config::configuration()->getDataPath() + GL_MODULE_PATH + "%1/" +
                           info.shortName() + "/module" + GL_FORMAT_MODULE)
                       .arg(m_typeModule.toLower());

    return createEmpty(r_str, text);

    return false;
}
Esempio n. 3
0
/**
  Reads the ini file and returns the dictionary name.
  */
MetaInfo BibleQuoteDict::readInfo(QFile &file)
{
    const QString encoding = m_settings->encoding;
    QTextCodec *codec = QTextCodec::codecForName(encoding.toStdString().c_str());
    QTextDecoder *decoder = codec->makeDecoder();
    QByteArray byteline = file.readLine();
    QString line = decoder->toUnicode(byteline);
    file.close();
    MetaInfo info;
    info.setName(line.simplified());
    return info;
}
Esempio n. 4
0
//------------------------------------------------------------------------------
void BibleQuoteModule::parseModule(QString pathToModule)
{
    //    myDebug() << "Parse module: " << pathToModule;
    MetaInfo parseInfo = readInfo(pathToModule);
    loadBibleData(1, pathToModule);
    //    myDebug() << readInfo(pathToModule).name() << readInfo(pathToModule).shortName();

    QDir d;
    d = QDir(QString(Config::configuration()->getDataPath() + GL_MODULE_PATH +  "%1/" + parseInfo.shortName()).arg(m_typeModule.toLower()));

    if (!d.exists())
    {
        //        emit SIGNAL_CreateFolderForModule(parseInfo.shortName());
        QDir dir;
        dir.mkpath(QString(Config::configuration()->getDataPath() + GL_MODULE_PATH + "%1/" + parseInfo.shortName()).arg(m_typeModule.toLower()));

        if (createIniFile(parseInfo))
        {
            createBookFiles(pathToModule);

            if (!m_bibleType)
            {
                addToListBookModule(parseInfo.shortName());
            }
            else
            {
                addToListBibleModule(parseInfo.shortName());
            }
        }
        else
        {
            myWarning() << "this module is created";
        }
    }
    else
    {
        //        myDebug() << "This module is exist";
    }

}
Esempio n. 5
0
bool
Response::fromData(const Name& zone, const Data& data)
{
  label::MatchResult re;
  if (!matchName(data, zone, re))
    return false;

  m_rrLabel = re.rrLabel;
  m_rrType = re.rrType;
  m_version = re.version;

  m_zone = zone;
  size_t len = zone.size();
  m_queryType = data.getName().get(len);

  MetaInfo info = data.getMetaInfo();

  m_freshnessPeriod = time::duration_cast<time::seconds>(info.getFreshnessPeriod());
  m_contentType = NdnsContentType(data.getContentType());

  wireDecode(data.getContent());
  return true;
}
Esempio n. 6
0
//------------------------------------------------------------------------------
MetaInfo BibleQuoteModule::readInfo(QFile &file)
{
    bool useShortName = false;
    m_moduleName.clear();
    m_moduleShortName.clear();
    int countlines = 0;

    QString encoding = getEncodingFromFile(file.fileName());
    m_codec = QTextCodec::codecForName(encoding.toStdString().c_str());

    QTextDecoder *decoder = m_codec->makeDecoder();
    while(!file.atEnd())
    {
        /*if (countlines > 50) { //wenn eine ini datei ungueltig ist soll damit nicht zuviel zeit verguedet werden
            break;
        }*/
        QByteArray byteline = file.readLine();
        QString line = decoder->toUnicode(byteline);
        if(!line.startsWith("//"))
        {
            countlines++;
        }
        else
        {
            continue;
        }

        if(line.contains("BibleName", Qt::CaseInsensitive) and m_moduleName.isEmpty())
        {
            m_moduleName = formatFromIni(line.
                                         remove(QRegExp("BibleName(\\s*)=(\\s*)",
                                                        Qt::CaseInsensitive)));
            if(m_moduleName.isEmpty())
            {
                useShortName = true;
            }
            if(useShortName && !m_moduleShortName.isEmpty())
            {
                break;
            }
            /// what is ?
            //            else if(!useShortName)
            //            {
            //                break;
            //            }
        }
        if(line.contains("BibleShortName", Qt::CaseInsensitive) and m_moduleShortName.isEmpty())
        {
            m_moduleShortName = formatFromIni(line.
                                              remove(QRegExp("BibleShortName(\\s*)=(\\s*)",
                                                             Qt::CaseInsensitive)));
            if(useShortName)
                break;
        }
    }
    file.close();
    if(useShortName)
    {
        m_moduleName = m_moduleShortName;
    }
    if(m_moduleName.isEmpty())
    {
        myWarning() << "invalid ini File " << file.fileName();
    }

    MetaInfo ret;
    ret.setName(m_moduleName);
    ret.setShortName(m_moduleShortName);

    if (m_typeModule == "Apocrypha")
        ret.type = OBVCore::Type_BibleQuoteApocrypha;

    if (m_typeModule == "Comments")
        ret.type = OBVCore::Type_BibleQuoteComments;

    if (m_typeModule == "Bible")
        ret.type = OBVCore::Type_BibleQuoteModule;

    if (m_typeModule == "Book")
        ret.type = OBVCore::Type_BibleQuoteBook;

    return ret;
    return MetaInfo();
}
Esempio n. 7
0
MetaInfo ZefaniaLex::buildIndexFromXmlDoc(KoXmlDocument *xmldoc)
{
    try {

    MetaInfo info;
    int couldBe = 0;//1 = RMac

    Document indexdoc;
    const QString index = indexPath();
    QString fileTitle;
    QString uid;
    QString type;

    QDir dir("/");
    dir.mkpath(index);

    RefText refText;
    refText.setSettings(m_settings);

    IndexWriter* writer = NULL;
    const TCHAR* stop_words[] = { NULL };
    standard::StandardAnalyzer an(stop_words);

    if(IndexReader::indexExists(index.toStdString().c_str())) {
        if(IndexReader::isLocked(index.toStdString().c_str())) {
            myDebug() << "Index was locked... unlocking it.";
            IndexReader::unlock(index.toStdString().c_str());
        }
    }
    writer = new IndexWriter(index.toStdString().c_str() , &an, true);

    writer->setMaxFieldLength(0x7FFFFFFFL);
    writer->setUseCompoundFile(false);

    KoXmlNode item = xmldoc->documentElement().firstChild();
    type = xmldoc->documentElement().toElement().attribute("type", "");

    for(int c = 0; !item.isNull();) {
        QString key = "";
        QString title = "";
        QString trans = "";
        QString pron = "";
        QString desc = "";
        KoXmlElement e = item.toElement();
        if(e.tagName().compare("INFORMATION", Qt::CaseInsensitive) == 0) {
            KoXmlNode title = item.namedItem("subject");
            KoXmlNode identifer = item.namedItem("identifier");

            fileTitle = title.toElement().text();
            uid = identifer.toElement().text();

        } else if(e.tagName().compare("item", Qt::CaseInsensitive) == 0) {
            key = e.attribute("id");
            KoXmlNode details = item.firstChild();
            while(!details.isNull()) {
                KoXmlElement edetails = details.toElement();
                if(edetails.tagName().compare("title", Qt::CaseInsensitive) == 0) {
                    title = edetails.text();
                } else if(edetails.tagName().compare("transliteration", Qt::CaseInsensitive) == 0) {
                    trans = edetails.text();
                } else if(edetails.tagName().compare("pronunciation", Qt::CaseInsensitive) == 0) {
                    KoXmlNode em = details.firstChild();
                    while(!em.isNull()) {
                        if(em.toElement().tagName().compare("em", Qt::CaseInsensitive) == 0)
                            pron = "<em>" + em.toElement().text() + "</em>";
                        em = em.nextSibling();
                    }
                } else if(edetails.tagName().compare("description", Qt::CaseInsensitive) == 0) {
                    KoXmlNode descNode = details.firstChild();
                    while(!descNode.isNull()) {
                        if(descNode.nodeType() == 2) {
                            desc += descNode.toText().data();
                        } else if(descNode.nodeType() == 1) {
                            KoXmlElement descElement = descNode.toElement();
                            if(descElement.tagName().compare("reflink", Qt::CaseInsensitive) == 0) {
                                if(descElement.hasAttribute("mscope")) {
                                    const QString mscope = descElement.attribute("mscope", ";;;");

                                    VerseUrl url;
                                    url.fromMscope(mscope);

                                    desc += " <a href=\"" + url.toString() + "\">" + refText.toString(url) + "</a> ";
                                } else if(descElement.hasAttribute("target")) {
                                    desc += descElement.text();
                                }

                            } else if(descElement.tagName().compare("see", Qt::CaseInsensitive) == 0) {
                                const QString target = descElement.attribute("target", "");
                                //todo: currently we assume target = x-self
                                StrongUrl url;
                                bool ok = url.fromText(descElement.text());
                                if(ok)
                                    desc += " <a href=\"" + url.toString() + "\">" + descElement.text() + "</a> ";
                            }
                        }

                        descNode = descNode.nextSibling();
                    }
                    desc += "<hr />";
                }
                details = details.nextSibling();
            }
            if(couldBe == 0) {
                if(key.toUpper() == "A-APF" || key.toUpper() == "X-NSN" || key.toUpper() == "V-PAP-DPN") {
                    couldBe = 1;
                }
            }
            QString content = "<h3 class='strongTitle'>" + key + " - " + title + "</h3>";
            if(!trans.isEmpty()) {
                content += " (" + trans + ") ";
            }
            if(!pron.isEmpty()) {
                content += " [" + pron + "] ";
            }
            content += "<br />" + desc;
            indexdoc.clear();
#ifdef OBV_USE_WSTRING
            indexdoc.add(*_CLNEW Field(_T("key"), key.toStdWString().c_str(), Field::STORE_YES |  Field::INDEX_TOKENIZED));
            indexdoc.add(*_CLNEW Field(_T("content"), content.toStdWString().c_str(), Field::STORE_YES |  Field::INDEX_TOKENIZED));
#else
            indexdoc.add(*_CLNEW Field(_T("key"), reinterpret_cast<const wchar_t *>(key.utf16()), Field::STORE_YES |  Field::INDEX_TOKENIZED));
            indexdoc.add(*_CLNEW Field(_T("content"), reinterpret_cast<const wchar_t *>(content.utf16()), Field::STORE_YES |  Field::INDEX_TOKENIZED));
#endif
            writer->addDocument(&indexdoc);

        }
        item = item.nextSibling();
        c++;
    }
    writer->setUseCompoundFile(true);
    writer->optimize();

    writer->close();
    delete writer;
    info.setName(fileTitle);
    info.setUID(uid);
    if(type == "x-strong") {
        info.setDefaultModule(OBVCore::DefaultStrongDictModule);
        info.setContent(OBVCore::StrongsContent);
    } else if(type == "x-dictionary") {
        if(couldBe == 1) {
            info.setDefaultModule(OBVCore::DefaultRMACDictModule);
            info.setContent(OBVCore::RMacContent);
        } else {
            info.setDefaultModule(OBVCore::DefaultDictModule);
        }
    }
    return info;
    }
    catch(...) {
        return MetaInfo();
    }
}
Esempio n. 8
0
MetaInfo ZefaniaLex::readInfo(const QString &name)
{
    DEBUG_FUNC_NAME
    QFile file(name);
    int couldBe = 0;//1 = RMac
    QString uid = "";
    QString type;
    ZefaniaXmlReader reader(name);
    MetaInfo info = reader.readMetaInfo();

    //open the xml file
    if(!file.open(QFile::ReadOnly | QFile::Text))
        return MetaInfo();
    m_xml = new QXmlStreamReader(&file);


    if(m_xml->readNextStartElement()) {
        if(cmp(m_xml->name(), "dictionary")) {
            type = m_xml->attributes().value("type").toString();
            if(type != "x-dictionary") {
                couldBe = -1;// do not scan the keys
            }
            while(m_xml->readNextStartElement()) {
                if(cmp(m_xml->name(), "item")) {
                    const QString key = m_xml->attributes().value("id").toString();
                    if(couldBe == 0) {
                        if(key.toUpper() == "A-APF" || key.toUpper() == "X-NSN" || key.toUpper() == "V-PAP-DPN") {//todo: speed
                            couldBe = 1;
                        }
                    } else {
                        break;
                    }
                } else {
                    m_xml->skipCurrentElement();
                }
            }
        }
    }

    if(info.name().isEmpty() && !info.subject.isEmpty()) {
        info.setName(info.subject);
    }

    info.setUID(uid);
    if(type == "x-strong") {
        info.setDefaultModule(ModuleTools::DefaultStrongDictModule);
        info.setContent(ModuleTools::StrongsContent);
    } else if(type == "x-dictionary") {
        if(couldBe == 1) {
            info.setDefaultModule(ModuleTools::DefaultRMACDictModule);
            info.setContent(ModuleTools::RMACContent);
        } else {
            info.setDefaultModule(ModuleTools::DefaultDictModule);
            info.setContent(ModuleTools::DictionaryContent);
        }
    }


    file.close();
    delete m_xml;
    m_xml = nullptr;

    return info;
}