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
16 #include "support/std_string.h"
20 /** Functions of use to citation and bibtex GUI controllers and views */
51 /// First entry is the bibliography key, second the data
52 typedef std::map<string, string> InfoMap;
54 /// Returns a vector of bibliography keys
55 std::vector<string> const getKeys(InfoMap const &);
57 /** Returns the BibTeX data associated with a given key.
58 Empty if no info exists. */
59 string const getInfo(InfoMap const &, string const &);
61 // rturn the year from the bibtex data record
62 string const getYear(InfoMap const & map, string const & key);
64 /// return the short form of an authorlist
65 string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
67 // return only the family name
68 string const familyName(string const & name);
70 /** Search a BibTeX info field for the given key and return the
72 string const parseBibTeX(string data, string const & findkey);
74 /** Returns an iterator to the first key that meets the search
75 criterion, or end() if unsuccessful.
78 the InfoMap of bibkeys info,
79 the vector of keys to be searched,
81 an iterator defining the starting point of the search,
82 an enum defining a Simple or Regex search,
83 an enum defining the search direction.
86 std::vector<string>::const_iterator
87 searchKeys(InfoMap const & map,
88 std::vector<string> const & keys_to_search,
89 string const & search_expression,
90 std::vector<string>::const_iterator start,
93 bool caseSensitive=false);
95 /// Type returned by getCitationStyle, below
96 struct CitationStyle {
98 CitationStyle() : style(CITE), full(false), forceUCase(false) {}
107 /// Given the LaTeX command, return the appropriate CitationStyle
108 CitationStyle const getCitationStyle(string const & command);
110 /** Returns the LaTeX citation command
114 a flag forcing the full author list,
115 a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
117 string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
119 /// Returns a vector of available Citation styles.
120 std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
123 "Translates" the available Citation Styles into strings for this key.
124 The returned string is displayed by the GUI.
127 [XX] is used in place of the actual reference
128 Eg, the vector will contain: [XX], Jones et al. [XX], ...
132 the InfoMap of bibkeys info,
133 the available citation styles
135 std::vector<string> const
136 getNumericalStrings(string const & key,
138 std::vector<CiteStyle> const & styles);
141 "Translates" the available Citation Styles into strings for this key.
142 The returned string is displayed by the GUI.
144 Eg, the vector will contain:
145 Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
149 the InfoMap of bibkeys info,
150 the available citation styles
152 std::vector<string> const
153 getAuthorYearStrings(string const & key,
155 std::vector<CiteStyle> const & styles);
156 } // namespace biblio
158 #endif // BIBLIOHELPERS_H