]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/biblio.h
The std::string mammoth path.
[lyx.git] / src / frontends / controllers / biblio.h
1 // -*- C++ -*-
2 /**
3  * \file biblio.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BIBLIOHELPERS_H
13 #define BIBLIOHELPERS_H
14
15 #include <map>
16 #include <vector>
17
18 /** Functions of use to citation and bibtex GUI controllers and views */
19 namespace biblio {
20
21 ///
22 enum CiteStyle {
23         CITE,
24         CITET,
25         CITEP,
26         CITEALT,
27         CITEALP,
28         CITEAUTHOR,
29         CITEYEAR,
30         CITEYEARPAR
31 };
32
33 ///
34 enum Search {
35         ///
36         SIMPLE,
37         ///
38         REGEX
39 };
40
41 ///
42 enum Direction {
43         ///
44         FORWARD,
45         ///
46         BACKWARD
47 };
48
49 /// First entry is the bibliography key, second the data
50 typedef std::map<std::string, std::string> InfoMap;
51
52 /// Returns a vector of bibliography keys
53 std::vector<std::string> const getKeys(InfoMap const &);
54
55 /** Returns the BibTeX data associated with a given key.
56     Empty if no info exists. */
57 std::string const getInfo(InfoMap const &, std::string const &);
58
59 // rturn the year from the bibtex data record
60 std::string const getYear(InfoMap const & map, std::string const & key);
61
62 /// return the short form of an authorlist
63 std::string const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
64
65 // return only the family name
66 std::string const familyName(std::string const & name);
67
68 /** Search a BibTeX info field for the given key and return the
69     associated field. */
70 std::string const parseBibTeX(std::string data, std::string const & findkey);
71
72 /** Returns an iterator to the first key that meets the search
73     criterion, or end() if unsuccessful.
74
75     User supplies :
76     the InfoMap of bibkeys info,
77     the vector of keys to be searched,
78     the search criterion,
79     an iterator defining the starting point of the search,
80     an enum defining a Simple or Regex search,
81     an enum defining the search direction.
82 */
83
84 std::vector<std::string>::const_iterator
85 searchKeys(InfoMap const & map,
86            std::vector<std::string> const & keys_to_search,
87            std::string const & search_expression,
88            std::vector<std::string>::const_iterator start,
89            Search,
90            Direction,
91            bool caseSensitive=false);
92
93 /// Type returned by getCitationStyle, below
94 struct CitationStyle {
95         ///
96         CitationStyle() : style(CITE), full(false), forceUCase(false) {}
97         ///
98         CiteStyle style;
99         ///
100         bool full;
101         ///
102         bool forceUCase;
103 };
104
105 /// Given the LaTeX command, return the appropriate CitationStyle
106 CitationStyle const getCitationStyle(std::string const & command);
107
108 /** Returns the LaTeX citation command
109
110 User supplies :
111 The CiteStyle enum,
112 a flag forcing the full author list,
113 a flag forcing upper case, e.g. "della Casa" becomes "Della Case"
114 */
115 std::string const getCiteCommand(CiteStyle, bool full, bool forceUCase);
116
117 /// Returns a vector of available Citation styles.
118 std::vector<CiteStyle> const getCiteStyles(bool usingNatbib);
119
120 /**
121    "Translates" the available Citation Styles into strings for this key.
122    The returned string is displayed by the GUI.
123
124
125    [XX] is used in place of the actual reference
126    Eg, the vector will contain: [XX], Jones et al. [XX], ...
127
128    User supplies :
129    the key,
130    the InfoMap of bibkeys info,
131    the available citation styles
132 */
133 std::vector<std::string> const
134 getNumericalStrings(std::string const & key,
135                     InfoMap const & map,
136                     std::vector<CiteStyle> const & styles);
137
138 /**
139    "Translates" the available Citation Styles into strings for this key.
140    The returned string is displayed by the GUI.
141
142    Eg, the vector will contain:
143    Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
144
145    User supplies :
146    the key,
147    the InfoMap of bibkeys info,
148    the available citation styles
149 */
150 std::vector<std::string> const
151 getAuthorYearStrings(std::string const & key,
152                      InfoMap const & map,
153                      std::vector<CiteStyle> const & styles);
154 } // namespace biblio
155
156 #endif // BIBLIOHELPERS_H