]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/biblio.h
e0a58af84f0e38366890a7fa94b7efeb03b226b9
[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 <vector>
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 /** Functions of use to citation and bibtex GUI controllers and views */
23 namespace biblio
24 {
25         ///
26         enum CiteStyle {
27                 CITE,
28                 CITET,
29                 CITEP,
30                 CITEALT,
31                 CITEALP,
32                 CITEAUTHOR,
33                 CITEYEAR,
34                 CITEYEARPAR
35         };
36         ///
37         enum Search {
38                 ///
39                 SIMPLE,
40                 ///
41                 REGEX
42         };
43         ///
44         enum Direction {
45                 ///
46                 FORWARD,
47                 ///
48                 BACKWARD
49         };
50
51         /// First entry is the bibliography key, second the data
52         typedef std::map<string, string> InfoMap;
53
54         /// Returns a vector of bibliography keys
55         std::vector<string> const getKeys(InfoMap const &);
56
57         /** Returns the BibTeX data associated with a given key.
58             Empty if no info exists. */
59         string const getInfo(InfoMap const &, string const &);
60
61         // rturn the year from the bibtex data record
62         string const getYear(InfoMap const & map, string const & key);
63
64         /// return the short form of an authorlist
65         string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
66
67         // return only the family name
68         string const familyName(string const & name);
69
70         /** Search a BibTeX info field for the given key and return the
71             associated field. */
72         string const parseBibTeX(string data, string const & findkey);
73
74         /** Returns an iterator to the first key that meets the search
75             criterion, or end() if unsuccessful.
76
77             User supplies :
78             the InfoMap of bibkeys info,
79             the vector of keys to be searched,
80             the search criterion,
81             an iterator defining the starting point of the search,
82             an enum defining a Simple or Regex search,
83             an enum defining the search direction.
84         */
85
86         std::vector<string>::const_iterator
87                 searchKeys(InfoMap const & map,
88                            std::vector<string> const & keys_to_search,
89                            string const & search_expression,
90                            std::vector<string>::const_iterator start,
91                            Search,
92                            Direction,
93                            bool caseSensitive=false);
94
95         /// Type returned by getCitationStyle, below
96         struct CitationStyle {
97                 ///
98                 CitationStyle() : style(CITE), full(false), forceUCase(false) {}
99                 ///
100                 CiteStyle style;
101                 ///
102                 bool full;
103                 ///
104                 bool forceUCase;
105         };
106         /// Given the LaTeX command, return the appropriate CitationStyle
107         CitationStyle const getCitationStyle(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         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);
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<string> const
135                 getNumericalStrings(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<string> const
152                 getAuthorYearStrings(string const & key,
153                                      InfoMap const & map,
154                                      std::vector<CiteStyle> const & styles);
155 } // namespace biblio
156
157 #endif // BIBLIOHELPERS_H