X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCiteEnginesList.cpp;h=6a1cef1a1185c97421f6a9750ad33003c74fafef;hb=4a7a19352cabb401052ca9467cf849da78f82f1a;hp=209c8bc840d3a3f7ecb1b327f7f7c5a0171cf74b;hpb=59a4f263a44ca3a1f5a37a652c8df154788f72d1;p=lyx.git diff --git a/src/CiteEnginesList.cpp b/src/CiteEnginesList.cpp index 209c8bc840..6a1cef1a11 100644 --- a/src/CiteEnginesList.cpp +++ b/src/CiteEnginesList.cpp @@ -4,7 +4,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Richard Heck + * \author Richard Kimberly Heck * \author Jürgen Spitzmüller * * Full author contact details are available in file CREDITS. @@ -14,7 +14,6 @@ #include "CiteEnginesList.h" -#include "Citation.h" #include "LaTeXFeatures.h" #include "Lexer.h" @@ -38,12 +37,11 @@ CiteEnginesList theCiteEnginesList; LyXCiteEngine::LyXCiteEngine(string const & n, string const & i, - vector const & cet, string const & d, - vector const & p, - vector const & r, vector const & e): - name_(n), id_(i), engine_types_(cet), description_(d), package_list_(p), - required_engines_(r), excluded_engines_(e), - checked_(false), available_(false) + vector const & cet, string const & cfm, + vector const & dbs, + string const & d, vector const & p): + name_(n), id_(i), engine_types_(cet), cite_framework_(cfm), default_biblios_(dbs), + description_(d), package_list_(p), checked_(false), available_(false) { filename_ = id_ + ".citeengine"; } @@ -85,36 +83,35 @@ bool LyXCiteEngine::hasEngineType(CiteEngineType const & et) const } -bool LyXCiteEngine::isCompatible(string const & cename) const +string LyXCiteEngine::getDefaultBiblio(CiteEngineType const & cet) const { - // do we exclude it? - if (find(excluded_engines_.begin(), excluded_engines_.end(), cename) != - excluded_engines_.end()) - return false; + string res; + string const etp = theCiteEnginesList.getTypeAsString(cet) + ":"; + //check whether all of the required packages are available + for (string const &s: default_biblios_) { + if (prefixIs(s, etp)) + res = split(s, ':'); + else if (!contains(s, ':') && res.empty()) + res = s; + } + return res; +} - LyXCiteEngine const * const lm = theCiteEnginesList[cename]; - if (!lm) - return true; - // does it exclude us? - vector const excengs = lm->getExcludedEngines(); - if (find(excengs.begin(), excengs.end(), id_) != excengs.end()) - return false; +bool LyXCiteEngine::isDefaultBiblio(string const & bf) const +{ + string const bfs = ":" + bf; + for (string const & s: default_biblios_) + if (suffixIs(s, bfs) || bf == s) + return true; - return true; + return false; } -bool LyXCiteEngine::areCompatible(string const & eng1, string const & eng2) +bool LyXCiteEngine::required(string const & p) const { - LyXCiteEngine const * const lm1 = theCiteEnginesList[eng1]; - if (lm1) - return lm1->isCompatible(eng2); - LyXCiteEngine const * const lm2 = theCiteEnginesList[eng2]; - if (lm2) - return lm2->isCompatible(eng1); - // Can't check it either way. - return true; + return find(package_list_.begin(), package_list_.end(), p) != package_list_.end(); } @@ -150,7 +147,7 @@ CiteEngineTypeTranslator const & citeenginetypetranslator() return translator; } -} // namespace anon +} // namespace string CiteEnginesList::getTypeAsString(CiteEngineType const & et) const @@ -217,6 +214,20 @@ bool CiteEnginesList::read() cet = split(cet, p, '|'); cets.push_back(p); } + if (!lex.next(true)) + break; + string const citeframework = lex.getString(); + LYXERR(Debug::TCLASS, "CiteFramework: " << citeframework); + if (!lex.next(true)) + break; + string db = lex.getString(); + LYXERR(Debug::TCLASS, "Default Biblio: " << db); + vector dbs; + while (!db.empty()) { + string p; + db = split(db, p, '|'); + dbs.push_back(p); + } if (!lex.next(true)) break; string const desc = lex.getString(); @@ -232,29 +243,9 @@ bool CiteEnginesList::read() str = split(str, p, ','); pkgs.push_back(p); } - if (!lex.next()) - break; - str = lex.getString(); - LYXERR(Debug::TCLASS, "Required: " << str); - vector req; - while (!str.empty()) { - string p; - str = split(str, p, '|'); - req.push_back(p); - } - if (!lex.next()) - break; - str = lex.getString(); - LYXERR(Debug::TCLASS, "Excluded: " << str); - vector exc; - while (!str.empty()) { - string p; - str = split(str, p, '|'); - exc.push_back(p); - } // This code is run when we have - // cename, fname, desc, pkgs, req and exc - addCiteEngine(cename, fname, cets, desc, pkgs, req, exc); + // cename, fname, cets, citeframework, dbs, desc, pkgs + addCiteEngine(cename, fname, cets, citeframework, dbs, desc, pkgs); } // end switch } //end while @@ -267,11 +258,11 @@ bool CiteEnginesList::read() void CiteEnginesList::addCiteEngine(string const & cename, - string const & filename, vector const & cets, string const & description, - vector const & pkgs, vector const & req, - vector const & exc) + string const & filename, vector const & cets, + string const & citeframework, vector const & dbs, + string const & description, vector const & pkgs) { - LyXCiteEngine ce(cename, filename, cets, description, pkgs, req, exc); + LyXCiteEngine ce(cename, filename, cets, citeframework, dbs, description, pkgs); englist_.push_back(ce); } @@ -302,25 +293,21 @@ LyXCiteEnginesList::iterator CiteEnginesList::end() LyXCiteEngine const * CiteEnginesList::operator[](string const & str) const { - LyXCiteEnginesList::const_iterator it = englist_.begin(); - for (; it != englist_.end(); ++it) - if (it->getID() == str) { - LyXCiteEngine const & eng = *it; + for (auto const & eng : englist_) + if (eng.getID() == str) { return ŋ } - return 0; + return nullptr; } LyXCiteEngine * CiteEnginesList::operator[](string const & str) { - LyXCiteEnginesList::iterator it = englist_.begin(); - for (; it != englist_.end(); ++it) - if (it->getID() == str) { - LyXCiteEngine & eng = *it; + for (auto & eng : englist_) + if (eng.getID() == str) { return ŋ } - return 0; + return nullptr; } } // namespace lyx