X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2Fbiblio.h;h=b7f619d43e15d68436a676fb0a6ee7269d02389a;hb=b7c9ae49318e0167a46e7213c967280205db4cf6;hp=e0a58af84f0e38366890a7fa94b7efeb03b226b9;hpb=1eb8155fa0d2253d9504a8d660cb3d666c1224f6;p=lyx.git diff --git a/src/frontends/controllers/biblio.h b/src/frontends/controllers/biblio.h index e0a58af84f..b7f619d43e 100644 --- a/src/frontends/controllers/biblio.h +++ b/src/frontends/controllers/biblio.h @@ -12,146 +12,147 @@ #ifndef BIBLIOHELPERS_H #define BIBLIOHELPERS_H + +#include "LString.h" #include #include -#ifdef __GNUG__ -#pragma interface -#endif - /** Functions of use to citation and bibtex GUI controllers and views */ -namespace biblio -{ +namespace biblio { + +/// +enum CiteStyle { + CITE, + CITET, + CITEP, + CITEALT, + CITEALP, + CITEAUTHOR, + CITEYEAR, + CITEYEARPAR +}; + +/// +enum Search { + /// + SIMPLE, + /// + REGEX +}; + +/// +enum Direction { /// - enum CiteStyle { - CITE, - CITET, - CITEP, - CITEALT, - CITEALP, - CITEAUTHOR, - CITEYEAR, - CITEYEARPAR - }; + FORWARD, /// - enum Search { - /// - SIMPLE, - /// - REGEX - }; + BACKWARD +}; + +/// First entry is the bibliography key, second the data +typedef std::map InfoMap; + +/// Returns a vector of bibliography keys +std::vector const getKeys(InfoMap const &); + +/** Returns the BibTeX data associated with a given key. + Empty if no info exists. */ +string const getInfo(InfoMap const &, string const &); + +// rturn the year from the bibtex data record +string const getYear(InfoMap const & map, string const & key); + +/// return the short form of an authorlist +string const getAbbreviatedAuthor(InfoMap const & map, string const & key); + +// return only the family name +string const familyName(string const & name); + +/** Search a BibTeX info field for the given key and return the + associated field. */ +string const parseBibTeX(string data, string const & findkey); + +/** Returns an iterator to the first key that meets the search + criterion, or end() if unsuccessful. + + User supplies : + the InfoMap of bibkeys info, + the vector of keys to be searched, + the search criterion, + an iterator defining the starting point of the search, + an enum defining a Simple or Regex search, + an enum defining the search direction. +*/ + +std::vector::const_iterator +searchKeys(InfoMap const & map, + std::vector const & keys_to_search, + string const & search_expression, + std::vector::const_iterator start, + Search, + Direction, + bool caseSensitive=false); + +/// Type returned by getCitationStyle, below +struct CitationStyle { /// - enum Direction { - /// - FORWARD, - /// - BACKWARD - }; - - /// First entry is the bibliography key, second the data - typedef std::map InfoMap; - - /// Returns a vector of bibliography keys - std::vector const getKeys(InfoMap const &); - - /** Returns the BibTeX data associated with a given key. - Empty if no info exists. */ - string const getInfo(InfoMap const &, string const &); - - // rturn the year from the bibtex data record - string const getYear(InfoMap const & map, string const & key); - - /// return the short form of an authorlist - string const getAbbreviatedAuthor(InfoMap const & map, string const & key); - - // return only the family name - string const familyName(string const & name); - - /** Search a BibTeX info field for the given key and return the - associated field. */ - string const parseBibTeX(string data, string const & findkey); - - /** Returns an iterator to the first key that meets the search - criterion, or end() if unsuccessful. - - User supplies : - the InfoMap of bibkeys info, - the vector of keys to be searched, - the search criterion, - an iterator defining the starting point of the search, - an enum defining a Simple or Regex search, - an enum defining the search direction. - */ - - std::vector::const_iterator - searchKeys(InfoMap const & map, - std::vector const & keys_to_search, - string const & search_expression, - std::vector::const_iterator start, - Search, - Direction, - bool caseSensitive=false); - - /// Type returned by getCitationStyle, below - struct CitationStyle { - /// - CitationStyle() : style(CITE), full(false), forceUCase(false) {} - /// - CiteStyle style; - /// - bool full; - /// - bool forceUCase; - }; - /// Given the LaTeX command, return the appropriate CitationStyle - CitationStyle const getCitationStyle(string const & command); - - /** Returns the LaTeX citation command - - User supplies : - The CiteStyle enum, - a flag forcing the full author list, - a flag forcing upper case, e.g. "della Casa" becomes "Della Case" - */ - string const getCiteCommand(CiteStyle, bool full, bool forceUCase); - - /// Returns a vector of available Citation styles. - std::vector const getCiteStyles(bool usingNatbib); - - /** - "Translates" the available Citation Styles into strings for this key. - The returned string is displayed by the GUI. - - - [XX] is used in place of the actual reference - Eg, the vector will contain: [XX], Jones et al. [XX], ... - - User supplies : - the key, - the InfoMap of bibkeys info, - the available citation styles - */ - std::vector const - getNumericalStrings(string const & key, - InfoMap const & map, - std::vector const & styles); - - /** - "Translates" the available Citation Styles into strings for this key. - The returned string is displayed by the GUI. - - Eg, the vector will contain: - Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ... - - User supplies : - the key, - the InfoMap of bibkeys info, - the available citation styles - */ - std::vector const - getAuthorYearStrings(string const & key, - InfoMap const & map, - std::vector const & styles); + CitationStyle() : style(CITE), full(false), forceUCase(false) {} + /// + CiteStyle style; + /// + bool full; + /// + bool forceUCase; +}; + +/// Given the LaTeX command, return the appropriate CitationStyle +CitationStyle const getCitationStyle(string const & command); + +/** Returns the LaTeX citation command + +User supplies : +The CiteStyle enum, +a flag forcing the full author list, +a flag forcing upper case, e.g. "della Casa" becomes "Della Case" +*/ +string const getCiteCommand(CiteStyle, bool full, bool forceUCase); + +/// Returns a vector of available Citation styles. +std::vector const getCiteStyles(bool usingNatbib); + +/** + "Translates" the available Citation Styles into strings for this key. + The returned string is displayed by the GUI. + + + [XX] is used in place of the actual reference + Eg, the vector will contain: [XX], Jones et al. [XX], ... + + User supplies : + the key, + the InfoMap of bibkeys info, + the available citation styles +*/ +std::vector const +getNumericalStrings(string const & key, + InfoMap const & map, + std::vector const & styles); + +/** + "Translates" the available Citation Styles into strings for this key. + The returned string is displayed by the GUI. + + Eg, the vector will contain: + Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ... + + User supplies : + the key, + the InfoMap of bibkeys info, + the available citation styles +*/ +std::vector const +getAuthorYearStrings(string const & key, + InfoMap const & map, + std::vector const & styles); } // namespace biblio #endif // BIBLIOHELPERS_H