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