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