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
21 /** Functions of use to citation and bibtex GUI controllers and views */
25 class CiteEngine_enum;
27 CiteEngine_enum getEngine(Buffer const &);
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.
58 std::string const asValidLatexCommand(std::string const & input,
59 CiteEngine_enum const & engine);
61 /// First entry is the bibliography key, second the data
62 typedef std::map<std::string, std::string> InfoMap;
64 /// Returns a vector of bibliography keys
65 std::vector<std::string> const getKeys(InfoMap const &);
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 &);
71 // rturn the year from the bibtex data record
72 std::string const getYear(InfoMap const & map, std::string const & key);
74 /// return the short form of an authorlist
75 std::string const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
77 // return only the family name
78 std::string const familyName(std::string const & name);
80 /** Search a BibTeX info field for the given key and return the
82 std::string const parseBibTeX(std::string data, std::string const & findkey);
84 /** Returns an iterator to the first key that meets the search
85 criterion, or end() if unsuccessful.
88 the InfoMap of bibkeys info,
89 the vector of keys to be searched,
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.
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,
103 bool caseSensitive=false);
106 class CitationStyle {
109 CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
110 : style(s), full(f), forceUCase(force) {}
111 /// \param latex_str a LaTeX command, "cite", "Citep*", etc
112 CitationStyle(std::string const & latex_str);
114 std::string const asLatexStr() const;
124 /// Returns a vector of available Citation styles.
125 std::vector<CiteStyle> const getCiteStyles(CiteEngine_enum const &);
128 "Translates" the available Citation Styles into strings for this key.
129 The returned string is displayed by the GUI.
132 [XX] is used in place of the actual reference
133 Eg, the vector will contain: [XX], Jones et al. [XX], ...
137 the InfoMap of bibkeys info,
138 the available citation styles
140 std::vector<std::string> const
141 getNumericalStrings(std::string const & key,
143 std::vector<CiteStyle> const & styles);
146 "Translates" the available Citation Styles into strings for this key.
147 The returned string is displayed by the GUI.
149 Eg, the vector will contain:
150 Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
154 the InfoMap of bibkeys info,
155 the available citation styles
157 std::vector<std::string> const
158 getAuthorYearStrings(std::string const & key,
160 std::vector<CiteStyle> const & styles);
162 } // namespace biblio
165 #endif // BIBLIOHELPERS_H