2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2001 The LyX Team.
9 * ======================================================
11 * \file ControlCitation.h
12 * \author Angus Leeming <a.leeming@ic.ac.uk>
15 #ifndef CONTROLCITATION_H
16 #define CONTROLCITATION_H
22 #include "ControlCommand.h"
24 /** A controller for Citation dialogs. All citation-specific functionality
27 class ControlCitation : public ControlCommand
31 typedef std::map<string, string> InfoMap;
33 typedef std::map<string, string>::value_type InfoMapValue;
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 &);
58 /// Clean up, then hide dialog.
60 /// The info associated with each key
65 /** This class instantiates and makes available the GUI-specific
66 ButtonController and View.
68 template <class GUIview, class GUIbc>
69 class GUICitation : public ControlCitation {
72 GUICitation(LyXView &, Dialogs &);
74 virtual ButtonControllerBase & bc() { return bc_; }
76 virtual ViewBase & view() { return view_; }
80 ButtonController<NoRepeatedApplyReadOnlyPolicy, GUIbc> bc_;
85 template <class GUIview, class GUIbc>
86 GUICitation<GUIview, GUIbc>::GUICitation(LyXView & lv, Dialogs & d)
87 : ControlCitation(lv, d),
91 /** Helper functions, of possible use to all frontends
94 /** Search a BibTeX info field for the given key and return the
96 string const parseBibTeX(string data, string const & findkey);
98 /** Returns an iterator to the first key that meets the search criterion,
99 or end() if unsuccessful.
102 the controller with the map of bibkeys info,
103 the vector of keys to be searched,
104 the search criterion,
105 an iterator defining the starting point of the search,
106 an enum defining a Simple or Regex search,
107 an enum defining the search direction.
110 std::vector<string>::const_iterator
111 searchKeys(ControlCitation const & controller,
112 std::vector<string> const & keys_to_search,
113 string const & search_expression,
114 std::vector<string>::const_iterator start,
115 ControlCitation::Search,
116 ControlCitation::Direction,
117 bool caseSensitive=false);
119 /// Do the dirty work for the search. Should use through the function above
120 std::vector<string>::const_iterator
121 simpleSearch(ControlCitation const & controller,
122 std::vector<string> const & keys_to_search,
123 string const & search_expression,
124 std::vector<string>::const_iterator start,
125 ControlCitation::Direction,
126 bool caseSensitive=false);
128 /// Should use through the function above
129 std::vector<string>::const_iterator
130 regexSearch(ControlCitation const & controller,
131 std::vector<string> const & keys_to_search,
132 string const & search_expression,
133 std::vector<string>::const_iterator start,
134 ControlCitation::Direction);
135 #endif // CONTROLCITATION_H