]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlCitation.h
Fixed "can't create new inset" bug. Described dialogs' control loop in
[lyx.git] / src / frontends / controllers / ControlCitation.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 ControlCitation.h
12  * \author Angus Leeming <a.leeming@ic.ac.uk>
13  */
14
15 #ifndef CONTROLCITATION_H
16 #define CONTROLCITATION_H
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 #include "ControlCommand.h"
23
24 /** A controller for Citation dialogs. All citation-specific functionality
25     should go in here.
26  */
27 class ControlCitation : public ControlCommand
28 {
29 public:
30         ///
31         typedef std::map<string, string> InfoMap;
32         ///
33         typedef std::map<string, string>::value_type InfoMapValue;
34         ///
35         enum Search {
36                 ///
37                 SIMPLE,
38                 ///
39                 REGEX
40         };
41         ///
42         enum Direction {
43                 ///
44                 FORWARD,
45                 ///
46                 BACKWARD
47         };
48         ///
49         ControlCitation(LyXView &, Dialogs &);
50         /// A vector of bibliography keys
51         std::vector<string> const getBibkeys();
52         /// Returns a reference to the map of stored keys
53         InfoMap const & bibkeysInfo() const { return bibkeysInfo_; }
54         /** Returns the BibTeX data associated with a given key.
55             Empty if no info exists. */
56         string const getBibkeyInfo(string const &);
57 private:
58         /// clean-up any daughter class-particular data on hide().
59         virtual void clearDaughterParams();
60         /// The info associated with each key
61         InfoMap bibkeysInfo_;
62 };
63
64 /** Helper functions, of possible use to all frontends
65  */
66
67 /** Search a BibTeX info field for the given key and return the
68     associated field. */
69 string const parseBibTeX(string data, string const & findkey);
70
71 /** Returns an iterator to the first key that meets the search criterion,
72     or end() if unsuccessful.
73
74     User supplies :
75     the controller with the map of bibkeys info,
76     the vector of keys to be searched,
77     the search criterion,
78     an iterator defining the starting point of the search,
79     an enum defining a Simple or Regex search,
80     an enum defining the search direction.
81 */
82
83 std::vector<string>::const_iterator
84 searchKeys(ControlCitation const & controller,
85            std::vector<string> const & keys_to_search,
86            string const & search_expression,
87            std::vector<string>::const_iterator start,
88            ControlCitation::Search,
89            ControlCitation::Direction,
90            bool caseSensitive=false);
91
92 /// Do the dirty work for the search. Should use through the function above
93 std::vector<string>::const_iterator
94 simpleSearch(ControlCitation const & controller,
95              std::vector<string> const & keys_to_search,
96              string const & search_expression,
97              std::vector<string>::const_iterator start,
98              ControlCitation::Direction,
99              bool caseSensitive=false);
100
101 /// Should use through the function above
102 std::vector<string>::const_iterator
103 regexSearch(ControlCitation const & controller,
104             std::vector<string> const & keys_to_search,
105             string const & search_expression,
106             std::vector<string>::const_iterator start,
107             ControlCitation::Direction);
108 #endif // CONTROLCITATION_H
109
110
111