]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/biblio.h
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / biblio.h
1 // -*- C++ -*-
2 /**
3  * \file biblio.h
4  * See the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #ifndef BIBLIOHELPERS_H
12 #define BIBLIOHELPERS_H
13
14 #include <map>
15 #include <vector>
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 /** Functions of use to citation and bibtex GUI controllers and views */
22 namespace biblio
23 {
24         ///
25         enum CiteStyle {
26                 CITE,
27                 CITET,
28                 CITEP,
29                 CITEALT,
30                 CITEALP,
31                 CITEAUTHOR,
32                 CITEYEAR,
33                 CITEYEARPAR
34         };
35         ///
36         enum Search {
37                 ///
38                 SIMPLE,
39                 ///
40                 REGEX
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<string, string> InfoMap;
52
53         /// Returns a vector of bibliography keys
54         std::vector<string> const getKeys(InfoMap const &);
55
56         /** Returns the BibTeX data associated with a given key.
57             Empty if no info exists. */
58         string const getInfo(InfoMap const &, string const &);
59
60         // rturn the year from the bibtex data record
61         string const getYear(InfoMap const & map, string const & key);
62
63         /// return the short form of an authorlist
64         string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
65
66         // return only the family name
67         string const familyName(string const & name);
68
69         /** Search a BibTeX info field for the given key and return the
70             associated field. */
71         string const parseBibTeX(string data, 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<string>::const_iterator
86                 searchKeys(InfoMap const & map,
87                            std::vector<string> const & keys_to_search,
88                            string const & search_expression,
89                            std::vector<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         /// Given the LaTeX command, return the appropriate CitationStyle
106         CitationStyle const getCitationStyle(string const & command);
107
108         /** Returns the LaTeX citation command
109
110             User supplies :
111             The CiteStyle enum,
112             a flag forcing the full author list,
113             a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
114          */
115         string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
116
117         /// Returns a vector of available Citation styles.
118         std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
119
120         /**
121            "Translates" the available Citation Styles into strings for this key.
122            The returned string is displayed by the GUI.
123
124
125            [XX] is used in place of the actual reference
126            Eg, the vector will contain: [XX], Jones et al. [XX], ...
127
128            User supplies :
129            the key,
130            the InfoMap of bibkeys info,
131            the available citation styles
132          */
133         std::vector<string> const
134                 getNumericalStrings(string const & key,
135                                     InfoMap const & map,
136                                     std::vector<CiteStyle> const & styles);
137
138         /**
139            "Translates" the available Citation Styles into strings for this key.
140            The returned string is displayed by the GUI.
141
142            Eg, the vector will contain:
143            Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
144
145            User supplies :
146            the key,
147            the InfoMap of bibkeys info,
148            the available citation styles
149          */
150         std::vector<string> const
151                 getAuthorYearStrings(string const & key,
152                                      InfoMap const & map,
153                                      std::vector<CiteStyle> const & styles);
154 } // namespace biblio
155
156 #endif // BIBLIOHELPERS_H