]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/biblio.h
Add support for the jurabib package (www.jurabib.org), a package for elegant BibTeX...
[lyx.git] / src / frontends / controllers / biblio.h
1 // -*- C++ -*-
2 /**
3  * \file biblio.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  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BIBLIOHELPERS_H
13 #define BIBLIOHELPERS_H
14
15 #include <map>
16 #include <string>
17 #include <vector>
18
19 /** Functions of use to citation and bibtex GUI controllers and views */
20 namespace biblio {
21
22 ///
23 enum CiteStyle {
24         CITE,
25         CITET,
26         CITEP,
27         CITEALT,
28         CITEALP,
29         CITEAUTHOR,
30         CITEYEAR,
31         CITEYEARPAR
32 };
33
34 ///
35 enum Search {
36         ///
37         SIMPLE,
38         ///
39         REGEX
40 };
41
42 ///
43 enum Direction {
44         ///
45         FORWARD,
46         ///
47         BACKWARD
48 };
49
50 /// First entry is the bibliography key, second the data
51 typedef std::map<std::string, std::string> InfoMap;
52
53 /// Returns a vector of bibliography keys
54 std::vector<std::string> const getKeys(InfoMap const &);
55
56 /** Returns the BibTeX data associated with a given key.
57     Empty if no info exists. */
58 std::string const getInfo(InfoMap const &, std::string const &);
59
60 // rturn the year from the bibtex data record
61 std::string const getYear(InfoMap const & map, std::string const & key);
62
63 /// return the short form of an authorlist
64 std::string const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
65
66 // return only the family name
67 std::string const familyName(std::string const & name);
68
69 /** Search a BibTeX info field for the given key and return the
70     associated field. */
71 std::string const parseBibTeX(std::string data, std::string const & findkey);
72
73 /** Returns an iterator to the first key that meets the search
74     criterion, or end() if unsuccessful.
75
76     User supplies :
77     the InfoMap of bibkeys info,
78     the vector of keys to be searched,
79     the search criterion,
80     an iterator defining the starting point of the search,
81     an enum defining a Simple or Regex search,
82     an enum defining the search direction.
83 */
84
85 std::vector<std::string>::const_iterator
86 searchKeys(InfoMap const & map,
87            std::vector<std::string> const & keys_to_search,
88            std::string const & search_expression,
89            std::vector<std::string>::const_iterator start,
90            Search,
91            Direction,
92            bool caseSensitive=false);
93
94 /// Type returned by getCitationStyle, below
95 struct CitationStyle {
96         ///
97         CitationStyle() : style(CITE), full(false), forceUCase(false) {}
98         ///
99         CiteStyle style;
100         ///
101         bool full;
102         ///
103         bool forceUCase;
104 };
105
106 /// Given the LaTeX command, return the appropriate CitationStyle
107 CitationStyle const getCitationStyle(std::string const & command);
108
109 /** Returns the LaTeX citation command
110
111 User supplies :
112 The CiteStyle enum,
113 a flag forcing the full author list,
114 a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
115 */
116 std::string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
117
118 /// Returns a vector of available Citation styles.
119 std::vector<CiteStyle> const getCiteStyles(bool usingNatbib, bool usingJurabib);
120
121 /**
122    "Translates" the available Citation Styles into strings for this key.
123    The returned string is displayed by the GUI.
124
125
126    [XX] is used in place of the actual reference
127    Eg, the vector will contain: [XX], Jones et al. [XX], ...
128
129    User supplies :
130    the key,
131    the InfoMap of bibkeys info,
132    the available citation styles
133 */
134 std::vector<std::string> const
135 getNumericalStrings(std::string const & key,
136                     InfoMap const & map,
137                     std::vector<CiteStyle> const & styles);
138
139 /**
140    "Translates" the available Citation Styles into strings for this key.
141    The returned string is displayed by the GUI.
142
143    Eg, the vector will contain:
144    Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
145
146    User supplies :
147    the key,
148    the InfoMap of bibkeys info,
149    the available citation styles
150 */
151 std::vector<std::string> const
152 getAuthorYearStrings(std::string const & key,
153                      InfoMap const & map,
154                      std::vector<CiteStyle> const & styles);
155 } // namespace biblio
156
157 #endif // BIBLIOHELPERS_H