]> git.lyx.org Git - lyx.git/blob - src/BiblioInfo.h
document my LFUN changes in the past
[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         CITET,
40         CITEP,
41         CITEALT,
42         CITEALP,
43         CITEAUTHOR,
44         CITEYEAR,
45         CITEYEARPAR
46 };
47
48
49 class CitationStyle {
50 public:
51         ///
52         CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
53                 : style(s), full(f), forceUCase(force) {}
54         /// \param latex_str a LaTeX command, "cite", "Citep*", etc
55         CitationStyle(std::string const & latex_str);
56         ///
57         std::string const asLatexStr() const;
58         ///
59         CiteStyle style;
60         ///
61         bool full;
62         ///
63         bool forceUCase;
64 };
65
66 /// Returns a vector of available Citation styles.
67 std::vector<CiteStyle> const getCiteStyles(CiteEngine const );
68
69 } // namespace biblio
70
71 /// Class to represent information about a BibTeX or
72 /// bibliography entry.
73 /// The keys are BibTeX fields (e.g., author, title, etc), 
74 /// and the values are the associated field values.
75 class BibTeXInfo : public std::map<docstring, docstring> {
76 public:
77         ///
78         BibTeXInfo();
79         ///Search for the given field and return the associated info.
80         ///The point of this is that BibTeXInfo::operator[] has no const
81         ///form.
82         docstring const & getValueForField(docstring const & field) const;
83         ///
84         docstring const & getValueForField(std::string const & field) const;
85         ///
86         bool hasField(docstring const & field) const;
87         /// return the short form of an authorlist
88         docstring const getAbbreviatedAuthor() const;
89         /// 
90         docstring const getYear() const;
91         /// Returns formatted BibTeX data suitable for framing.
92         docstring const getInfo() const;
93         /// the BibTeX key for this entry
94         docstring bibKey;
95         /// a single string containing all BibTeX data associated with this key
96         docstring allData;
97         /// the BibTeX entry type (article, book, incollection, ...)
98         docstring entryType;
99         /// true if from BibTeX; false if from bibliography environment
100         bool isBibTeX;
101 };
102
103
104 /// Class to represent a collection of bibliographical data, whether
105 /// from BibTeX or from bibliography environments.
106 /// BiblioInfo.first is the bibliography key
107 /// BiblioInfo.second is the data for that key
108 class BiblioInfo : public std::map<docstring, BibTeXInfo> {
109 public:
110         /// Returns a sorted vector of bibliography keys
111         std::vector<docstring> const getKeys() const;
112         /// Returns a sorted vector of present BibTeX fields
113         std::vector<docstring> const getFields() const;
114         /// Returns a sorted vector of BibTeX entry types in use
115         std::vector<docstring> const getEntries() const;
116         /// Fills keys with BibTeX information derived from the various insets
117         /// in a given buffer, in its master document.
118         void fillWithBibKeys(Buffer const * const buf);
119         /// return the short form of an authorlist
120         docstring const getAbbreviatedAuthor(docstring const & key) const;
121         /// return the year from the bibtex data record
122         docstring const getYear(docstring const & key) const;
123         /// Returns formatted BibTeX data associated with a given key.
124         /// Empty if no info exists. 
125         docstring const getInfo(docstring const & key) const;
126         
127         /**
128           * "Translates the available Citation Styles into strings for a given key,
129           * either numerical or author-year depending upon the active engine. (See
130           * below for those methods.)
131           */
132         std::vector<docstring> const
133                         getCiteStrings(docstring const & key, Buffer const & buf) const;
134         /**
135                 * "Translates" the available Citation Styles into strings for a given key.
136                 * The returned string is displayed by the GUI.
137                 * [XX] is used in place of the actual reference
138                 * Eg, the vector will contain: [XX], Jones et al. [XX], ...
139                 * User supplies :
140                 *  the key,
141                 *  the buffer
142                 */
143         std::vector<docstring> const
144                         getNumericalStrings(docstring const & key, Buffer const & buf) const;
145         /**
146                 * "Translates" the available Citation Styles into strings for a given key.
147                 * The returned string is displayed by the GUI.
148                 * Eg, the vector will contain:
149                 *  Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
150                 * User supplies :
151                 *  the key,
152                 *  the buffer
153                 */
154         std::vector<docstring> const
155                         getAuthorYearStrings(docstring const & key, Buffer const & buf) const;
156
157         std::set<docstring> fieldNames;
158         std::set<docstring> entryTypes;
159 };
160
161 } // namespace lyx
162 #endif