2001-06-13 14:33:31 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file biblio.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-28 12:59:29 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
2001-03-28 12:59:29 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-28 12:59:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BIBLIOHELPERS_H
|
|
|
|
#define BIBLIOHELPERS_H
|
|
|
|
|
2002-09-24 12:43:01 +00:00
|
|
|
#include <map>
|
2003-10-07 06:45:25 +00:00
|
|
|
#include <string>
|
2002-09-24 12:43:01 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
/** Functions of use to citation and bibtex GUI controllers and views */
|
2002-10-21 17:38:09 +00:00
|
|
|
namespace biblio {
|
|
|
|
|
|
|
|
///
|
|
|
|
enum CiteStyle {
|
|
|
|
CITE,
|
|
|
|
CITET,
|
|
|
|
CITEP,
|
|
|
|
CITEALT,
|
|
|
|
CITEALP,
|
|
|
|
CITEAUTHOR,
|
|
|
|
CITEYEAR,
|
|
|
|
CITEYEARPAR
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
enum Search {
|
2001-07-19 14:12:37 +00:00
|
|
|
///
|
2002-10-21 17:38:09 +00:00
|
|
|
SIMPLE,
|
2001-03-28 12:59:29 +00:00
|
|
|
///
|
2002-10-21 17:38:09 +00:00
|
|
|
REGEX
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
enum Direction {
|
|
|
|
///
|
|
|
|
FORWARD,
|
|
|
|
///
|
|
|
|
BACKWARD
|
|
|
|
};
|
|
|
|
|
|
|
|
/// First entry is the bibliography key, second the data
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::map<std::string, std::string> InfoMap;
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
/// Returns a vector of bibliography keys
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> const getKeys(InfoMap const &);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
/** Returns the BibTeX data associated with a given key.
|
|
|
|
Empty if no info exists. */
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getInfo(InfoMap const &, std::string const &);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
// rturn the year from the bibtex data record
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getYear(InfoMap const & map, std::string const & key);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
/// return the short form of an authorlist
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
// return only the family name
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const familyName(std::string const & name);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
/** Search a BibTeX info field for the given key and return the
|
|
|
|
associated field. */
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const parseBibTeX(std::string data, std::string const & findkey);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
/** Returns an iterator to the first key that meets the search
|
|
|
|
criterion, or end() if unsuccessful.
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string>::const_iterator
|
2002-10-21 17:38:09 +00:00
|
|
|
searchKeys(InfoMap const & map,
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> const & keys_to_search,
|
|
|
|
std::string const & search_expression,
|
|
|
|
std::vector<std::string>::const_iterator start,
|
2002-10-21 17:38:09 +00:00
|
|
|
Search,
|
|
|
|
Direction,
|
|
|
|
bool caseSensitive=false);
|
|
|
|
|
|
|
|
/// Type returned by getCitationStyle, below
|
|
|
|
struct CitationStyle {
|
|
|
|
///
|
|
|
|
CitationStyle() : style(CITE), full(false), forceUCase(false) {}
|
2001-03-28 12:59:29 +00:00
|
|
|
///
|
2002-10-21 17:38:09 +00:00
|
|
|
CiteStyle style;
|
|
|
|
///
|
|
|
|
bool full;
|
|
|
|
///
|
|
|
|
bool forceUCase;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Given the LaTeX command, return the appropriate CitationStyle
|
2003-10-06 15:43:21 +00:00
|
|
|
CitationStyle const getCitationStyle(std::string const & command);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
/** Returns the LaTeX citation command
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
User supplies :
|
|
|
|
The CiteStyle enum,
|
|
|
|
a flag forcing the full author list,
|
|
|
|
a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
|
2002-10-21 17:38:09 +00:00
|
|
|
|
|
|
|
/// Returns a vector of available Citation styles.
|
|
|
|
std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
|
|
|
|
|
|
|
|
/**
|
|
|
|
"Translates" the available Citation Styles into strings for this key.
|
|
|
|
The returned string is displayed by the GUI.
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
[XX] is used in place of the actual reference
|
|
|
|
Eg, the vector will contain: [XX], Jones et al. [XX], ...
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
User supplies :
|
|
|
|
the key,
|
|
|
|
the InfoMap of bibkeys info,
|
|
|
|
the available citation styles
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> const
|
|
|
|
getNumericalStrings(std::string const & key,
|
2002-10-21 17:38:09 +00:00
|
|
|
InfoMap const & map,
|
|
|
|
std::vector<CiteStyle> const & styles);
|
|
|
|
|
|
|
|
/**
|
|
|
|
"Translates" the available Citation Styles into strings for this key.
|
|
|
|
The returned string is displayed by the GUI.
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
Eg, the vector will contain:
|
|
|
|
Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
User supplies :
|
|
|
|
the key,
|
|
|
|
the InfoMap of bibkeys info,
|
|
|
|
the available citation styles
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> const
|
|
|
|
getAuthorYearStrings(std::string const & key,
|
2002-10-21 17:38:09 +00:00
|
|
|
InfoMap const & map,
|
|
|
|
std::vector<CiteStyle> const & styles);
|
2002-03-21 21:21:28 +00:00
|
|
|
} // namespace biblio
|
2001-03-28 12:59:29 +00:00
|
|
|
|
|
|
|
#endif // BIBLIOHELPERS_H
|