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