4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
12 #ifndef BIBLIOHELPERS_H
13 #define BIBLIOHELPERS_H
15 #include "support/docstring.h"
22 /** Functions of use to citation and bibtex GUI controllers and views */
26 class CiteEngine_enum;
28 CiteEngine_enum getEngine(Buffer const &);
55 /** Each citation engine recognizes only a subset of all possible
56 * citation commands. Given a latex command \c input, this function
57 * returns an appropriate command, valid for \c engine.
59 std::string const asValidLatexCommand(std::string const & input,
60 CiteEngine_enum const & engine);
62 /// First entry is the bibliography key, second the data
63 typedef std::map<std::string, docstring> InfoMap;
65 /// Returns a vector of bibliography keys
66 std::vector<std::string> const getKeys(InfoMap const &);
68 /** Returns the BibTeX data associated with a given key.
69 Empty if no info exists. */
70 docstring const getInfo(InfoMap const &, std::string const & key);
72 /// return the year from the bibtex data record
73 docstring const getYear(InfoMap const & map, std::string const & key);
75 /// return the short form of an authorlist
76 docstring const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
78 // return only the family name
79 docstring const familyName(docstring const & name);
81 /** Search a BibTeX info field for the given key and return the
83 docstring const parseBibTeX(docstring data, std::string const & findkey);
85 /** Returns an iterator to the first key that meets the search
86 criterion, or end() if unsuccessful.
89 the InfoMap of bibkeys info,
90 the vector of keys to be searched,
92 an iterator defining the starting point of the search,
93 an enum defining a Simple or Regex search,
94 an enum defining the search direction.
97 std::vector<std::string>::const_iterator
98 searchKeys(InfoMap const & map,
99 std::vector<std::string> const & keys_to_search,
100 docstring const & search_expression,
101 std::vector<std::string>::const_iterator start,
104 bool caseSensitive=false);
107 class CitationStyle {
110 CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
111 : style(s), full(f), forceUCase(force) {}
112 /// \param latex_str a LaTeX command, "cite", "Citep*", etc
113 CitationStyle(std::string const & latex_str);
115 std::string const asLatexStr() const;
125 /// Returns a vector of available Citation styles.
126 std::vector<CiteStyle> const getCiteStyles(CiteEngine_enum const &);
129 "Translates" the available Citation Styles into strings for this key.
130 The returned string is displayed by the GUI.
133 [XX] is used in place of the actual reference
134 Eg, the vector will contain: [XX], Jones et al. [XX], ...
138 the InfoMap of bibkeys info,
139 the available citation styles
141 std::vector<docstring> const
142 getNumericalStrings(std::string const & key,
144 std::vector<CiteStyle> const & styles);
147 "Translates" the available Citation Styles into strings for this key.
148 The returned string is displayed by the GUI.
150 Eg, the vector will contain:
151 Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
155 the InfoMap of bibkeys info,
156 the available citation styles
158 std::vector<docstring> const
159 getAuthorYearStrings(std::string const & key,
161 std::vector<CiteStyle> const & styles);
163 } // namespace biblio
166 #endif // BIBLIOHELPERS_H