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