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