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