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
25 /** Functions of use to citation and bibtex GUI controllers and views */
54 /// First entry is the bibliography key, second the data
55 typedef std::map<string, string> InfoMap;
57 /// Returns a vector of bibliography keys
58 std::vector<string> const getKeys(InfoMap const &);
60 /** Returns the BibTeX data associated with a given key.
61 Empty if no info exists. */
62 string const getInfo(InfoMap const &, string const &);
64 // rturn the year from the bibtex data record
65 string const getYear(InfoMap const & map, string const & key);
67 /// return the short form of an authorlist
68 string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
70 // return only the family name
71 string const familyName(string const & name);
73 /** Search a BibTeX info field for the given key and return the
75 string const parseBibTeX(string data, string const & findkey);
77 /** Returns an iterator to the first key that meets the search
78 criterion, or end() if unsuccessful.
81 the InfoMap of bibkeys info,
82 the vector of keys to be searched,
84 an iterator defining the starting point of the search,
85 an enum defining a Simple or Regex search,
86 an enum defining the search direction.
89 std::vector<string>::const_iterator
90 searchKeys(InfoMap const & map,
91 std::vector<string> const & keys_to_search,
92 string const & search_expression,
93 std::vector<string>::const_iterator start,
96 bool caseSensitive=false);
98 /// Type returned by getCitationStyle, below
99 struct CitationStyle {
101 CitationStyle() : style(CITE), full(false), forceUCase(false) {}
109 /// Given the LaTeX command, return the appropriate CitationStyle
110 CitationStyle const getCitationStyle(string const & command);
112 /** Returns the LaTeX citation command
116 a flag forcing the full author list,
117 a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
119 string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
121 /// Returns a vector of available Citation styles.
122 std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
125 "Translates" the available Citation Styles into strings for this key.
126 The returned string is displayed by the GUI.
129 [XX] is used in place of the actual reference
130 Eg, the vector will contain: [XX], Jones et al. [XX], ...
134 the InfoMap of bibkeys info,
135 the available citation styles
137 std::vector<string> const
138 getNumericalStrings(string const & key,
140 std::vector<CiteStyle> const & styles);
143 "Translates" the available Citation Styles into strings for this key.
144 The returned string is displayed by the GUI.
146 Eg, the vector will contain:
147 Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
151 the InfoMap of bibkeys info,
152 the available citation styles
154 std::vector<string> const
155 getAuthorYearStrings(string const & key,
157 std::vector<CiteStyle> const & styles);
158 } // namespace biblio
160 #endif // BIBLIOHELPERS_H