2001-06-13 14:33:31 +00:00
|
|
|
// -*- C++ -*-
|
2001-03-28 12:59:29 +00:00
|
|
|
/* This file is part of
|
2002-03-21 21:21:28 +00:00
|
|
|
* ======================================================
|
2001-03-28 12:59:29 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file biblio.h
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BIBLIOHELPERS_H
|
|
|
|
#define BIBLIOHELPERS_H
|
|
|
|
|
|
|
|
#include <map>
|
2002-05-25 00:19:56 +00:00
|
|
|
#include <vector>
|
2001-03-28 12:59:29 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Functions of use to citation and bibtex GUI controllers and views */
|
2002-03-21 21:21:28 +00:00
|
|
|
namespace biblio
|
2001-03-28 12:59:29 +00:00
|
|
|
{
|
2001-07-19 14:12:37 +00:00
|
|
|
///
|
|
|
|
enum CiteStyle {
|
|
|
|
CITE,
|
|
|
|
CITET,
|
|
|
|
CITEP,
|
|
|
|
CITEALT,
|
|
|
|
CITEALP,
|
|
|
|
CITEAUTHOR,
|
|
|
|
CITEYEAR,
|
|
|
|
CITEYEARPAR
|
|
|
|
};
|
2001-03-28 12:59:29 +00:00
|
|
|
///
|
|
|
|
enum Search {
|
|
|
|
///
|
|
|
|
SIMPLE,
|
|
|
|
///
|
|
|
|
REGEX
|
|
|
|
};
|
|
|
|
///
|
|
|
|
enum Direction {
|
|
|
|
///
|
|
|
|
FORWARD,
|
|
|
|
///
|
|
|
|
BACKWARD
|
|
|
|
};
|
|
|
|
|
|
|
|
/// First entry is the bibliography key, second the data
|
|
|
|
typedef std::map<string, string> InfoMap;
|
|
|
|
|
|
|
|
/// Returns a vector of bibliography keys
|
|
|
|
std::vector<string> 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 &);
|
|
|
|
|
2002-04-15 12:05:07 +00:00
|
|
|
// rturn the year from the bibtex data record
|
|
|
|
string const getYear(InfoMap const & map, string const & key);
|
2002-05-25 00:19:56 +00:00
|
|
|
|
2002-04-15 12:05:07 +00:00
|
|
|
/// 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);
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
/** 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<string>::const_iterator
|
2001-07-19 14:12:37 +00:00
|
|
|
searchKeys(InfoMap const & map,
|
|
|
|
std::vector<string> const & keys_to_search,
|
|
|
|
string const & search_expression,
|
|
|
|
std::vector<string>::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<CiteStyle> 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], ...
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
User supplies :
|
|
|
|
the key,
|
|
|
|
the InfoMap of bibkeys info,
|
|
|
|
the available citation styles
|
|
|
|
*/
|
|
|
|
std::vector<string> const
|
|
|
|
getNumericalStrings(string const & key,
|
|
|
|
InfoMap const & map,
|
|
|
|
std::vector<CiteStyle> const & styles);
|
2001-03-28 12:59:29 +00:00
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
/**
|
|
|
|
"Translates" the available Citation Styles into strings for this key.
|
|
|
|
The returned string is displayed by the GUI.
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
Eg, the vector will contain:
|
|
|
|
Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
User supplies :
|
|
|
|
the key,
|
|
|
|
the InfoMap of bibkeys info,
|
|
|
|
the available citation styles
|
|
|
|
*/
|
|
|
|
std::vector<string> const
|
|
|
|
getAuthorYearStrings(string const & key,
|
|
|
|
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
|