2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2001 The LyX Team.
9 * ======================================================
12 * \author Angus Leeming <a.leeming@ic.ac.uk>
15 #ifndef BIBLIOHELPERS_H
16 #define BIBLIOHELPERS_H
24 /** Functions of use to citation and bibtex GUI controllers and views */
53 /// First entry is the bibliography key, second the data
54 typedef std::map<string, string> InfoMap;
56 /// Returns a vector of bibliography keys
57 std::vector<string> const getKeys(InfoMap const &);
59 /** Returns the BibTeX data associated with a given key.
60 Empty if no info exists. */
61 string const getInfo(InfoMap const &, string const &);
63 // rturn the year from the bibtex data record
64 string const getYear(InfoMap const & map, string const & key);
66 /// return the short form of an authorlist
67 string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
69 // return only the family name
70 string const familyName(string const & name);
72 /** Search a BibTeX info field for the given key and return the
74 string const parseBibTeX(string data, string const & findkey);
76 /** Returns an iterator to the first key that meets the search
77 criterion, or end() if unsuccessful.
80 the InfoMap of bibkeys info,
81 the vector of keys to be searched,
83 an iterator defining the starting point of the search,
84 an enum defining a Simple or Regex search,
85 an enum defining the search direction.
88 std::vector<string>::const_iterator
89 searchKeys(InfoMap const & map,
90 std::vector<string> const & keys_to_search,
91 string const & search_expression,
92 std::vector<string>::const_iterator start,
95 bool caseSensitive=false);
97 /// Type returned by getCitationStyle, below
98 struct CitationStyle {
100 CitationStyle() : style(CITE), full(false), forceUCase(false) {}
108 /// Given the LaTeX command, return the appropriate CitationStyle
109 CitationStyle const getCitationStyle(string const & command);
111 /** Returns the LaTeX citation command
115 a flag forcing the full author list,
116 a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
118 string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
120 /// Returns a vector of available Citation styles.
121 std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
124 "Translates" the available Citation Styles into strings for this key.
125 The returned string is displayed by the GUI.
128 [XX] is used in place of the actual reference
129 Eg, the vector will contain: [XX], Jones et al. [XX], ...
133 the InfoMap of bibkeys info,
134 the available citation styles
136 std::vector<string> const
137 getNumericalStrings(string const & key,
139 std::vector<CiteStyle> const & styles);
142 "Translates" the available Citation Styles into strings for this key.
143 The returned string is displayed by the GUI.
145 Eg, the vector will contain:
146 Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
150 the InfoMap of bibkeys info,
151 the available citation styles
153 std::vector<string> const
154 getAuthorYearStrings(string const & key,
156 std::vector<CiteStyle> const & styles);
157 } // namespace biblio
159 #endif // BIBLIOHELPERS_H