2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 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"
23 #include "ButtonController.h"
26 /** A controller for Citation dialogs. All citation-specific functionality
29 class ControlCitation : public ControlCommand
33 typedef std::map<string, string> InfoMap;
35 typedef std::map<string, string>::value_type InfoMapValue;
51 ControlCitation(LyXView &, Dialogs &);
52 /// A vector of bibliography keys
53 std::vector<string> const getBibkeys();
54 /// Returns a reference to the map of stored keys
55 InfoMap const & bibkeysInfo() const { return bibkeysInfo_; }
56 /** Returns the BibTeX data associated with a given key.
57 Empty if no info exists. */
58 string const getBibkeyInfo(string const &);
60 /// Clean up, then hide dialog.
62 /// The info associated with each key
67 /** This class instantiates and makes available the GUI-specific
68 ButtonController and View.
70 template <class GUIview, class GUIbc>
71 class GUICitation : public ControlCitation {
74 GUICitation(LyXView &, Dialogs &);
76 virtual ButtonControllerBase & bc() { return bc_; }
78 virtual ViewBase & view() { return view_; }
82 ButtonController<NoRepeatedApplyReadOnlyPolicy, GUIbc> bc_;
87 template <class GUIview, class GUIbc>
88 GUICitation<GUIview, GUIbc>::GUICitation(LyXView & lv, Dialogs & d)
89 : ControlCitation(lv, d),
93 /** Helper functions, of possible use to all frontends
96 /** Multiple citation keys are stored in InsetCommandParams::contents as a
97 comma-separated string. These two functions convert to/from a vector. */
98 string const getStringFromVector(std::vector<string> const &, char delim=',');
100 std::vector<string> const getVectorFromString(string const &, char delim=',');
102 /** Search a BibTeX info field for the given key and return the
104 string const parseBibTeX(string data, string const & findkey);
106 /** Returns an iterator to the first key that meets the search criterion,
107 or end() if unsuccessful.
110 the controller with the map of bibkeys info,
111 the vector of keys to be searched,
112 the search criterion,
113 an iterator defining the starting point of the search,
114 an enum defining a Simple or Regex search,
115 an enum defining the search direction.
118 std::vector<string>::const_iterator
119 searchKeys(ControlCitation const & controller,
120 std::vector<string> const & keys_to_search,
121 string const & search_expression,
122 std::vector<string>::const_iterator start,
123 ControlCitation::Search,
124 ControlCitation::Direction,
125 bool caseSensitive=false);
127 /// Do the dirty work for the search. Should use through the function above
128 std::vector<string>::const_iterator
129 simpleSearch(ControlCitation const & controller,
130 std::vector<string> const & keys_to_search,
131 string const & search_expression,
132 std::vector<string>::const_iterator start,
133 ControlCitation::Direction,
134 bool caseSensitive=false);
136 /// Should use through the function above
137 std::vector<string>::const_iterator
138 regexSearch(ControlCitation const & controller,
139 std::vector<string> const & keys_to_search,
140 string const & search_expression,
141 std::vector<string>::const_iterator start,
142 ControlCitation::Direction);
143 #endif // CONTROLCITATION_H