]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/biblio.h
Added // -*- C++ -*- to the top of all files in controllers/ and xforms/
[lyx.git] / src / frontends / controllers / biblio.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2001 The LyX Team.
8  *
9  * ======================================================
10  *
11  * \file biblio.h
12  * \author Angus Leeming <a.leeming@ic.ac.uk>
13  */
14
15 #ifndef BIBLIOHELPERS_H
16 #define BIBLIOHELPERS_H
17
18 #include <map>
19
20 #ifdef __GNUG__
21 #pragma interface
22 #endif
23
24 /** Functions of use to citation and bibtex GUI controllers and views */
25 namespace biblio 
26 {
27         ///
28         enum Search {
29                 ///
30                 SIMPLE,
31                 ///
32                 REGEX
33         };
34         ///
35         enum Direction {
36                 ///
37                 FORWARD,
38                 ///
39                 BACKWARD
40         };
41
42         /// First entry is the bibliography key, second the data
43         typedef std::map<string, string> InfoMap;
44
45         /// Returns a vector of bibliography keys
46         std::vector<string> const getKeys(InfoMap const &);
47
48         /** Returns the BibTeX data associated with a given key.
49             Empty if no info exists. */
50         string const getInfo(InfoMap const &, string const &);
51
52         /** Search a BibTeX info field for the given key and return the
53             associated field. */
54         string const parseBibTeX(string data, string const & findkey);
55
56         /** Returns an iterator to the first key that meets the search
57             criterion, or end() if unsuccessful.
58
59             User supplies :
60             the InfoMap of bibkeys info,
61             the vector of keys to be searched,
62             the search criterion,
63             an iterator defining the starting point of the search,
64             an enum defining a Simple or Regex search,
65             an enum defining the search direction.
66         */
67
68         std::vector<string>::const_iterator
69             searchKeys(InfoMap const & map,
70                        std::vector<string> const & keys_to_search,
71                        string const & search_expression,
72                        std::vector<string>::const_iterator start,
73                        Search,
74                        Direction,
75                        bool caseSensitive=false);
76
77         /** Do the dirty work for the search.
78             Should use through the function above */
79         std::vector<string>::const_iterator
80             simpleSearch(InfoMap const & map,
81                          std::vector<string> const & keys_to_search,
82                          string const & search_expression,
83                          std::vector<string>::const_iterator start,
84                          Direction,
85                          bool caseSensitive=false);
86
87         /// Should use through the function above
88         std::vector<string>::const_iterator
89             regexSearch(InfoMap const & map,
90                         std::vector<string> const & keys_to_search,
91                         string const & search_expression,
92                         std::vector<string>::const_iterator start,
93                         Direction);
94
95 } // namespace biblio 
96
97 #endif // BIBLIOHELPERS_H