]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/biblio.h
Nothing but a changed email address (trying to factor my tree in in small steps)
[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 <leeming@lyx.org>
13  */
14
15 #ifndef BIBLIOHELPERS_H
16 #define BIBLIOHELPERS_H
17
18 #include <map>
19 #include <vector>
20
21 #ifdef __GNUG__
22 #pragma interface
23 #endif
24
25 /** Functions of use to citation and bibtex GUI controllers and views */
26 namespace biblio
27 {
28         ///
29         enum CiteStyle {
30                 CITE,
31                 CITET,
32                 CITEP,
33                 CITEALT,
34                 CITEALP,
35                 CITEAUTHOR,
36                 CITEYEAR,
37                 CITEYEARPAR
38         };
39         ///
40         enum Search {
41                 ///
42                 SIMPLE,
43                 ///
44                 REGEX
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         /// Given the LaTeX command, return the appropriate CitationStyle
110         CitationStyle const getCitationStyle(string const & command);
111
112         /** Returns the LaTeX citation command
113
114             User supplies :
115             The CiteStyle enum,
116             a flag forcing the full author list,
117             a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
118          */
119         string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
120
121         /// Returns a vector of available Citation styles.
122         std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
123
124         /**
125            "Translates" the available Citation Styles into strings for this key.
126            The returned string is displayed by the GUI.
127
128
129            [XX] is used in place of the actual reference
130            Eg, the vector will contain: [XX], Jones et al. [XX], ...
131
132            User supplies :
133            the key,
134            the InfoMap of bibkeys info,
135            the available citation styles
136          */
137         std::vector<string> const
138                 getNumericalStrings(string const & key,
139                                     InfoMap const & map,
140                                     std::vector<CiteStyle> const & styles);
141
142         /**
143            "Translates" the available Citation Styles into strings for this key.
144            The returned string is displayed by the GUI.
145
146            Eg, the vector will contain:
147            Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
148
149            User supplies :
150            the key,
151            the InfoMap of bibkeys info,
152            the available citation styles
153          */
154         std::vector<string> const
155                 getAuthorYearStrings(string const & key,
156                                      InfoMap const & map,
157                                      std::vector<CiteStyle> const & styles);
158 } // namespace biblio
159
160 #endif // BIBLIOHELPERS_H