3 * \file CiteEnginesList.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
13 #ifndef CITEENGINESLIST_H
14 #define CITEENGINESLIST_H
24 * This class represents a particular LyX "cite engine", which defines the features
25 * of a particular citation backend such as natbib or biblatex. In that sense, it is more like
26 * a LaTeX package, where a layout file corresponds to a LaTeX class.
28 * In general, a given cite engine can be used with any document class. That said,
29 * one cite engine may `require' another, or it may `exclude' some other cite engine.
30 * The requires and excludes are given in comments within the cite engine file,
31 * which must begin roughly so:
32 * # \DeclareLyXCiteEngine[natbib.sty]{Natbib}
34 * # Natbib supports a range of both author-year and numerical styles mainly
35 * # aimed at the Humanities. It features automatic sorting and merging of
36 * # numerical citations, annotations, capitalization of the `van' part of
37 * # author names, shortened and full author lists, and more.
39 * # Excludes: basic | jurabib
40 * The description will be used in the gui to give information to the user. The
41 * Requires and Excludes lines are read by the configuration script
42 * and written to a file citeengines.lst in the user configuration directory.
43 * That file is then read on startup to populate the CiteEnginesList, below.
45 * Engines can also be "provided" or "excluded" by document classes, using
46 * the ProvidesEngine and ExcludesEngine tags.
52 LyXCiteEngine(std::string const & name, std::string const & id,
53 std::vector<std::string> const & enginetypes,
54 std::string const & cfm,
55 std::vector<std::string> const & defaultbiblios,
56 std::string const & description,
57 std::vector<std::string> const & packagelist,
58 std::vector<std::string> const & requires,
59 std::vector<std::string> const & excludes);
60 /// whether the required packages are available
61 bool isAvailable() const;
62 /// the missing prerequisites, if any
63 std::vector<std::string> prerequisites() const;
65 std::string const & getName() const { return name_; }
67 std::string const & getID() const { return id_; }
69 std::string const & getFilename() const { return filename_; }
71 std::string const & getCiteFramework() const { return cite_framework_; }
73 std::vector<std::string> const & getEngineType() const { return engine_types_; }
75 bool hasEngineType(CiteEngineType const &) const;
77 std::string getDefaultBiblio(CiteEngineType const &) const;
79 bool isDefaultBiblio(std::string const &) const;
81 std::string const & getDescription() const { return description_; }
83 std::vector<std::string> const & getPackageList() const
84 { return package_list_; }
86 std::vector<std::string> const & getRequiredEngines() const
87 { return required_engines_; }
88 /// Engines this one excludes: the list should be treated disjunctively
89 std::vector<std::string> const & getExcludedEngines() const
90 { return excluded_engines_; }
91 /// \return true if the engine is compatible with this one, i.e.,
92 /// it does not exclude us and we do not exclude it.
93 /// this will also return true if cename is unknown and we do not
94 /// exclude it, since in that case we cannot check its exclusions.
95 bool isCompatible(std::string const & cename) const;
97 static bool areCompatible(std::string const & eng1, std::string const & eng2);
99 /// what appears in the ui
101 /// the engine's unique identifier
102 /// at present, this is the filename, without the extension
105 std::string filename_;
106 /// the engine type(s)
107 std::vector<std::string> engine_types_;
108 /// cite framework (bibtex, biblatex)
109 std::string cite_framework_;
110 /// default bibliography styles
111 std::vector<std::string> default_biblios_;
112 /// a short description for use in the ui
113 std::string description_;
114 /// the LaTeX packages on which this depends, if any
115 std::vector<std::string> package_list_;
116 /// Engines this one requires: at least one
117 std::vector<std::string> required_engines_;
118 /// Engines this one excludes: none of these
119 std::vector<std::string> excluded_engines_;
120 // these are mutable because they are used to cache the results
121 // or an otherwise const operation.
123 mutable bool checked_;
125 mutable bool available_;
127 mutable std::vector<std::string> prerequisites_;
130 typedef std::vector<LyXCiteEngine> LyXCiteEnginesList;
133 * The CiteEnginesList represents the various LyXCiteEngine's that are available at
136 class CiteEnginesList {
141 std::string getTypeAsString(CiteEngineType const &) const;
143 CiteEngineType getType(std::string const &) const;
144 /// reads the engines from a file generated by configure.py
147 LyXCiteEnginesList::const_iterator begin() const;
149 LyXCiteEnginesList::iterator begin();
151 LyXCiteEnginesList::const_iterator end() const;
153 LyXCiteEnginesList::iterator end();
155 bool empty() const { return englist_.empty(); }
156 /// Returns a pointer to the LyXCiteEngine with filename str.
157 /// Returns a null pointer if no such engine is found.
158 LyXCiteEngine const * operator[](std::string const & str) const;
160 LyXCiteEngine * operator[](std::string const & str);
163 CiteEnginesList(CiteEnginesList const &);
165 void operator=(CiteEnginesList const &);
166 /// add an engine to the list
167 void addCiteEngine(std::string const &, std::string const &,
168 std::vector<std::string> const &, std::string const &,
169 std::vector<std::string> const &, std::string const &,
170 std::vector<std::string> const &, std::vector<std::string> const &,
171 std::vector<std::string> const &);
173 std::vector<LyXCiteEngine> englist_;
176 extern CiteEnginesList theCiteEnginesList;