]> git.lyx.org Git - lyx.git/blob - src/BiblioInfo.h
* src/frontends/GuiDocument.{cpp,h}:
[lyx.git] / src / BiblioInfo.h
1 // -*- C++ -*-
2 /**
3  * \file BiblioInfo.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author Herbert Voß
9  * \author Richard Heck
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef BIBLIO_H
15 #define BIBLIO_H
16
17 #include "support/docstring.h"
18
19 #include <vector>
20 #include <map>
21 #include <set>
22
23
24 namespace lyx {
25         
26 class Buffer;
27
28 namespace biblio {
29
30 enum CiteEngine {
31         ENGINE_BASIC,
32         ENGINE_NATBIB_AUTHORYEAR,
33         ENGINE_NATBIB_NUMERICAL,
34         ENGINE_JURABIB
35 };
36
37 enum CiteStyle {
38         CITE,
39         NOCITE,
40         CITET,
41         CITEP,
42         CITEALT,
43         CITEALP,
44         CITEAUTHOR,
45         CITEYEAR,
46         CITEYEARPAR
47 };
48
49
50 class CitationStyle {
51 public:
52         ///
53         CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
54                 : style(s), full(f), forceUCase(force) {}
55         /// \param latex_str a LaTeX command, "cite", "Citep*", etc
56         CitationStyle(std::string const & latex_str);
57         ///
58         std::string const asLatexStr() const;
59         ///
60         CiteStyle style;
61         ///
62         bool full;
63         ///
64         bool forceUCase;
65 };
66
67 /// Returns a vector of available Citation styles.
68 std::vector<CiteStyle> const getCiteStyles(CiteEngine const );
69
70 } // namespace biblio
71
72 /// Class to represent information about a BibTeX or
73 /// bibliography entry.
74 /// The keys are BibTeX fields (e.g., author, title, etc), 
75 /// and the values are the associated field values.
76 class BibTeXInfo : public std::map<docstring, docstring> {
77 public:
78         ///
79         BibTeXInfo();
80         ///Search for the given field and return the associated info.
81         ///The point of this is that BibTeXInfo::operator[] has no const
82         ///form.
83         docstring const & getValueForField(docstring const & field) const;
84         ///
85         docstring const & getValueForField(std::string const & field) const;
86         ///
87         bool hasField(docstring const & field) const;
88         /// return the short form of an authorlist
89         docstring const getAbbreviatedAuthor() const;
90         /// 
91         docstring const getYear() const;
92         /// Returns formatted BibTeX data suitable for framing.
93         docstring const getInfo() const;
94         /// the BibTeX key for this entry
95         docstring bibKey;
96         /// a single string containing all BibTeX data associated with this key
97         docstring allData;
98         /// the BibTeX entry type (article, book, incollection, ...)
99         docstring entryType;
100         /// true if from BibTeX; false if from bibliography environment
101         bool isBibTeX;
102 };
103
104
105 /// Class to represent a collection of bibliographical data, whether
106 /// from BibTeX or from bibliography environments.
107 /// BiblioInfo.first is the bibliography key
108 /// BiblioInfo.second is the data for that key
109 class BiblioInfo : public std::map<docstring, BibTeXInfo> {
110 public:
111         /// Returns a sorted vector of bibliography keys
112         std::vector<docstring> const getKeys() const;
113         /// Returns a sorted vector of present BibTeX fields
114         std::vector<docstring> const getFields() const;
115         /// Returns a sorted vector of BibTeX entry types in use
116         std::vector<docstring> const getEntries() const;
117         /// Fills keys with BibTeX information derived from the various insets
118         /// in a given buffer, in its master document.
119         void fillWithBibKeys(Buffer const * const buf);
120         /// return the short form of an authorlist
121         docstring const getAbbreviatedAuthor(docstring const & key) const;
122         /// return the year from the bibtex data record
123         docstring const getYear(docstring const & key) const;
124         /// Returns formatted BibTeX data associated with a given key.
125         /// Empty if no info exists. 
126         docstring const getInfo(docstring const & key) const;
127         
128         /**
129           * "Translates the available Citation Styles into strings for a given key,
130           * either numerical or author-year depending upon the active engine. (See
131           * below for those methods.)
132           */
133         std::vector<docstring> const
134                         getCiteStrings(docstring const & key, Buffer const & buf) const;
135         /**
136                 * "Translates" the available Citation Styles into strings for a given key.
137                 * The returned string is displayed by the GUI.
138                 * [XX] is used in place of the actual reference
139                 * Eg, the vector will contain: [XX], Jones et al. [XX], ...
140                 * User supplies :
141                 *  the key,
142                 *  the buffer
143                 */
144         std::vector<docstring> const
145                         getNumericalStrings(docstring const & key, Buffer const & buf) const;
146         /**
147                 * "Translates" the available Citation Styles into strings for a given key.
148                 * The returned string is displayed by the GUI.
149                 * Eg, the vector will contain:
150                 *  Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
151                 * User supplies :
152                 *  the key,
153                 *  the buffer
154                 */
155         std::vector<docstring> const
156                         getAuthorYearStrings(docstring const & key, Buffer const & buf) const;
157
158         std::set<docstring> fieldNames;
159         std::set<docstring> entryTypes;
160 };
161
162 } // namespace lyx
163 #endif