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