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 */
24 class CiteEngine_enum;
26 CiteEngine_enum getEngine(Buffer const &);
52 /// First entry is the bibliography key, second the data
53 typedef std::map<std::string, std::string> InfoMap;
55 /// Returns a vector of bibliography keys
56 std::vector<std::string> const getKeys(InfoMap const &);
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 &);
62 // rturn the year from the bibtex data record
63 std::string const getYear(InfoMap const & map, std::string const & key);
65 /// return the short form of an authorlist
66 std::string const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
68 // return only the family name
69 std::string const familyName(std::string const & name);
71 /** Search a BibTeX info field for the given key and return the
73 std::string const parseBibTeX(std::string data, std::string const & findkey);
75 /** Returns an iterator to the first key that meets the search
76 criterion, or end() if unsuccessful.
79 the InfoMap of bibkeys info,
80 the vector of keys to be searched,
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.
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,
94 bool caseSensitive=false);
97 struct CitationStyle {
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);
104 std::string const asLatexStr() const;
114 /// Returns a vector of available Citation styles.
115 std::vector<CiteStyle> const getCiteStyles(CiteEngine_enum const &);
118 "Translates" the available Citation Styles into strings for this key.
119 The returned string is displayed by the GUI.
122 [XX] is used in place of the actual reference
123 Eg, the vector will contain: [XX], Jones et al. [XX], ...
127 the InfoMap of bibkeys info,
128 the available citation styles
130 std::vector<std::string> const
131 getNumericalStrings(std::string const & key,
133 std::vector<CiteStyle> const & styles);
136 "Translates" the available Citation Styles into strings for this key.
137 The returned string is displayed by the GUI.
139 Eg, the vector will contain:
140 Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
144 the InfoMap of bibkeys info,
145 the available citation styles
147 std::vector<std::string> const
148 getAuthorYearStrings(std::string const & key,
150 std::vector<CiteStyle> const & styles);
151 } // namespace biblio
153 #endif // BIBLIOHELPERS_H