]> git.lyx.org Git - lyx.git/blob - src/Biblio.h
Move the lyx::biblio namespace into src/. Also make changes to how the BibTeX
[lyx.git] / src / 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  * \author Herbert Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef BIBLIO_H
14 #define BIBLIO_H
15
16 #include "Buffer.h"
17 #include "support/docstring.h"
18
19 #include <vector>
20
21 namespace lyx {
22         
23 namespace biblio {
24         
25         extern const docstring TheBibliographyRef;
26
27         enum CiteEngine {
28                 ENGINE_BASIC,
29                 ENGINE_NATBIB_AUTHORYEAR,
30                 ENGINE_NATBIB_NUMERICAL,
31                 ENGINE_JURABIB
32         };
33
34
35         enum CiteStyle {
36                 CITE,
37                 CITET,
38                 CITEP,
39                 CITEALT,
40                 CITEALP,
41                 CITEAUTHOR,
42                 CITEYEAR,
43                 CITEYEARPAR
44         };
45
46
47         enum Search {
48                 SIMPLE,
49                 REGEX
50         };
51
52
53         enum Direction {
54                 FORWARD,
55                 BACKWARD
56         };
57
58
59 /** Fills keys with BibTeX information derived from the various
60  *  in this document or its master document.
61  */
62         void fillWithBibKeys(Buffer const * const buf, 
63                 std::vector<std::pair<std::string, docstring> > & keys);
64
65 /** Each citation engine recognizes only a subset of all possible
66         *  citation commands. Given a latex command \c input, this function
67         *  returns an appropriate command, valid for \c engine.
68  */
69         std::string const asValidLatexCommand(std::string const & input,
70                                               CiteEngine const engine);
71
72 /// First entry is the bibliography key, second the data
73         typedef std::map<std::string, docstring> InfoMap;
74
75 /// Returns a vector of bibliography keys
76         std::vector<std::string> const getKeys(InfoMap const &);
77
78 /** Returns the BibTeX data associated with a given key.
79         Empty if no info exists. */
80         docstring const getInfo(InfoMap const &, std::string const & key);
81
82 /// return the year from the bibtex data record
83         docstring const getYear(InfoMap const & map, std::string const & key);
84
85 /// return the short form of an authorlist
86         docstring const getAbbreviatedAuthor(InfoMap const & map, std::string const & key);
87
88 // return only the family name
89         docstring const familyName(docstring const & name);
90
91 /** Search a BibTeX info field for the given key and return the
92         associated field. */
93         docstring const parseBibTeX(docstring data, std::string const & findkey);
94
95 /** Returns an iterator to the first key that meets the search
96         criterion, or end() if unsuccessful.
97
98     User supplies :
99         the InfoMap of bibkeys info,
100         the vector of keys to be searched,
101         the search criterion,
102         an iterator defining the starting point of the search,
103         an enum defining a Simple or Regex search,
104         an enum defining the search direction.
105  */
106
107         std::vector<std::string>::const_iterator
108                         searchKeys(InfoMap const & map,
109                                    std::vector<std::string> const & keys_to_search,
110                                    docstring const & search_expression,
111                                    std::vector<std::string>::const_iterator start,
112          Search,
113         Direction,
114  bool caseSensitive=false);
115
116
117         class CitationStyle {
118                 public:
119                         ///
120                         CitationStyle(CiteStyle s = CITE, bool f = false, bool force = false)
121                         : style(s), full(f), forceUCase(force) {}
122                         /// \param latex_str a LaTeX command, "cite", "Citep*", etc
123                         CitationStyle(std::string const & latex_str);
124                         ///
125                         std::string const asLatexStr() const;
126                         ///
127                         CiteStyle style;
128                         ///
129                         bool full;
130                         ///
131                         bool forceUCase;
132         };
133
134
135 /// Returns a vector of available Citation styles.
136         std::vector<CiteStyle> const getCiteStyles(CiteEngine const );
137
138 /**
139         "Translates" the available Citation Styles into strings for this key.
140         The returned string is displayed by the GUI.
141
142
143         [XX] is used in place of the actual reference
144         Eg, the vector will contain: [XX], Jones et al. [XX], ...
145
146    User supplies :
147         the key,
148         the InfoMap of bibkeys info,
149         the available citation styles
150  */
151         std::vector<docstring> const
152                         getNumericalStrings(std::string const & key,
153                                             InfoMap const & map,
154                                             std::vector<CiteStyle> const & styles);
155
156 /**
157         "Translates" the available Citation Styles into strings for this key.
158         The returned string is displayed by the GUI.
159
160    Eg, the vector will contain:
161         Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
162
163    User supplies :
164         the key,
165         the InfoMap of bibkeys info,
166         the available citation styles
167  */
168         std::vector<docstring> const
169                         getAuthorYearStrings(std::string const & key,
170                                              InfoMap const & map,
171                                              std::vector<CiteStyle> const & styles);
172
173 } // namespace biblio
174 } // namespace lyx
175 #endif