]> git.lyx.org Git - lyx.git/blob - src/CiteEnginesList.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / CiteEnginesList.h
1 // -*- C++ -*-
2 /**
3  * \file CiteEnginesList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Richard Kimberly Heck
8  * \author Jürgen Spitzmüller
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef CITEENGINESLIST_H
14 #define CITEENGINESLIST_H
15
16 #include "Citation.h"
17
18 #include <string>
19 #include <vector>
20
21 namespace lyx {
22
23 /**
24  *  This class represents a particular LyX "cite engine", which defines the features
25  *  of a particular citation backend such as natbib or biblatex.
26  *
27  *  In general, a given cite engine can be used with any document class. That said,
28  *  one cite engine may `require' another, or it may `exclude' some other cite engine.
29  *  The requires and excludes are given in comments within the cite engine file,
30  *  which must begin roughly so:
31  *  # \DeclareLyXCiteEngine[natbib.sty]{Natbib}
32  *  # DescriptionBegin
33  *  #   Natbib supports a range of both author-year and numerical styles mainly
34  *  #   aimed at the Humanities. It features automatic sorting and merging of
35  *  #   numerical citations, annotations, capitalization of the `van' part of
36  *  #   author names, shortened and full author lists, and more.
37  *  # DescriptionEnd
38  *  # Excludes: basic | jurabib
39  *  The description will be used in the gui to give information to the user. The
40  *  Requires and Excludes lines are read by the configuration script
41  *  and written to a file citeengines.lst in the user configuration directory.
42  *  That file is then read on startup to populate the CiteEnginesList, below.
43  *
44  *  Engines can also be "provided" or "excluded" by document classes, using
45  *  the ProvidesEngine and ExcludesEngine tags.
46  */
47
48 class LyXCiteEngine {
49 public:
50         ///
51         LyXCiteEngine(std::string const & name, std::string const & id,
52                       std::vector<std::string> const & enginetypes,
53                       std::string const & cfm,
54                       std::vector<std::string> const & defaultbiblios,
55                       std::string const & description,
56                       std::vector<std::string> const & packagelist);
57         /// whether the required packages are available
58         bool isAvailable() const;
59         /// the missing prerequisites, if any
60         std::vector<std::string> prerequisites() const;
61         ///
62         std::string const & getName() const { return name_; }
63         ///
64         std::string const & getID() const { return id_; }
65         ///
66         std::string const & getFilename() const { return filename_; }
67         ///
68         std::string const & getCiteFramework() const { return cite_framework_; }
69         ///
70         std::vector<std::string> const & getEngineType() const { return engine_types_; }
71         ///
72         bool hasEngineType(CiteEngineType const &) const;
73         ///
74         std::string getDefaultBiblio(CiteEngineType const &) const;
75         ///
76         bool isDefaultBiblio(std::string const &) const;
77         ///
78         std::string const & getDescription() const { return description_; }
79         ///
80         std::vector<std::string> const & getPackageList() const
81                 { return package_list_; }
82         ///
83         bool required(std::string const & p) const;
84 private:
85         /// what appears in the ui
86         std::string name_;
87         /// the engine's unique identifier
88         /// at present, this is the filename, without the extension
89         std::string id_;
90         /// the filename
91         std::string filename_;
92         /// the engine type(s)
93         std::vector<std::string> engine_types_;
94         /// cite framework (bibtex, biblatex)
95         std::string cite_framework_;
96         /// default bibliography styles
97         std::vector<std::string> default_biblios_;
98         /// a short description for use in the ui
99         std::string description_;
100         /// the LaTeX packages on which this depends, if any
101         std::vector<std::string> package_list_;
102         // these are mutable because they are used to cache the results
103         // of an otherwise const operation.
104         ///
105         mutable bool checked_;
106         ///
107         mutable bool available_;
108         ///
109         mutable std::vector<std::string> prerequisites_;
110 };
111
112 typedef std::vector<LyXCiteEngine> LyXCiteEnginesList;
113
114 /**
115  *  The CiteEnginesList represents the various LyXCiteEngine's that are available at
116  *  present.
117  */
118 class CiteEnginesList {
119 public:
120         ///
121         CiteEnginesList() {}
122         ///
123         std::string getTypeAsString(CiteEngineType const &) const;
124         ///
125         CiteEngineType getType(std::string const &) const;
126         /// reads the engines from a file generated by configure.py
127         bool read();
128         ///
129         LyXCiteEnginesList::const_iterator begin() const;
130         ///
131         LyXCiteEnginesList::iterator begin();
132         ///
133         LyXCiteEnginesList::const_iterator end() const;
134         ///
135         LyXCiteEnginesList::iterator end();
136         ///
137         bool empty() const { return englist_.empty(); }
138         /// Returns a pointer to the LyXCiteEngine with filename str.
139         /// Returns a null pointer if no such engine is found.
140         LyXCiteEngine const * operator[](std::string const & str) const;
141         ///
142         LyXCiteEngine * operator[](std::string const & str);
143         private:
144         /// noncopyable
145         CiteEnginesList(CiteEnginesList const &);
146         ///
147         void operator=(CiteEnginesList const &);
148         /// add an engine to the list
149         void addCiteEngine(std::string const &, std::string const &,
150                 std::vector<std::string> const &, std::string const &,
151                 std::vector<std::string> const &, std::string const &,
152                 std::vector<std::string> const &);
153         ///
154         std::vector<LyXCiteEngine> englist_;
155 };
156
157 extern CiteEnginesList theCiteEnginesList;
158 } // namespace lyx
159 #endif