4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS.
17 #include "support/docstring.h"
30 /// FIXME: To Citation.cpp?
31 /// Returns a vector of available Citation styles.
32 std::vector<CiteStyle> citeStyles(CiteEngine);
33 /// \param latex_str a LaTeX command, "cite", "Citep*", etc
34 CitationStyle citationStyleFromString(std::string const & latex_str);
35 /// the other way rounf
36 std::string citationStyleToString(CitationStyle const &);
39 /// Class to represent information about a BibTeX or
40 /// bibliography entry.
41 /// The keys are BibTeX fields (e.g., author, title, etc),
42 /// and the values are the associated field values.
46 typedef std::map<docstring, docstring>::const_iterator const_iterator;
47 /// argument sets isBibTeX_, so should be false only if it's coming
48 /// from a bibliography environment
49 BibTeXInfo(bool ib = true);
50 /// constructor that sets the entryType
51 BibTeXInfo(docstring const & key, docstring const & type);
52 /// Search for the given field and return the associated info.
53 /// The point of this is that BibTeXInfo::operator[] has no const
55 docstring const & getValueForField(docstring const & field) const;
57 docstring const & getValueForField(std::string const & field) const;
59 bool hasField(docstring const & field) const;
60 /// return the short form of an authorlist
61 docstring const getAbbreviatedAuthor() const;
63 docstring const getYear() const;
64 /// Returns formatted BibTeX data suitable for framing.
65 docstring const getInfo() const;
67 int count(docstring const & f) const { return bimap_.count(f); }
69 const_iterator find(docstring const & f) const { return bimap_.find(f); }
71 const_iterator end() const { return bimap_.end(); }
73 docstring & operator[](docstring const & f)
76 docstring const & allData() const { return all_data_; }
78 void setAllData(docstring const & d) { all_data_ = d; }
80 docstring entryType() const { return entry_type_; }
82 /// true if from BibTeX; false if from bibliography environment
84 /// the BibTeX key for this entry
86 /// a single string containing all BibTeX data associated with this key
88 /// the BibTeX entry type (article, book, incollection, ...)
89 docstring entry_type_;
90 /// our map: <field, value>
91 std::map <docstring, docstring> bimap_;
95 /// Class to represent a collection of bibliographical data, whether
96 /// from BibTeX or from bibliography environments.
97 /// BiblioInfo.first is the bibliography key
98 /// BiblioInfo.second is the data for that key
104 typedef std::map<docstring, BibTeXInfo>::const_iterator const_iterator;
105 /// Returns a sorted vector of bibliography keys
106 std::vector<docstring> const getKeys() const;
107 /// Returns a sorted vector of present BibTeX fields
108 std::vector<docstring> const getFields() const;
109 /// Returns a sorted vector of BibTeX entry types in use
110 std::vector<docstring> const getEntries() const;
111 /// Fills keys with BibTeX information derived from the various insets
112 /// in a given buffer, in its master document.
113 void fillWithBibKeys(Buffer const * const buf);
114 /// return the short form of an authorlist
115 docstring const getAbbreviatedAuthor(docstring const & key) const;
116 /// return the year from the bibtex data record
117 docstring const getYear(docstring const & key) const;
118 /// Returns formatted BibTeX data associated with a given key.
119 /// Empty if no info exists.
120 docstring const getInfo(docstring const & key) const;
123 * "Translates" the available Citation Styles into strings for a given key,
124 * either numerical or author-year depending upon the active engine. (See
125 * below for those methods.)
127 std::vector<docstring> const
128 getCiteStrings(docstring const & key, Buffer const & buf) const;
130 * "Translates" the available Citation Styles into strings for a given key.
131 * The returned string is displayed by the GUI.
132 * [XX] is used in place of the actual reference
133 * Eg, the vector will contain: [XX], Jones et al. [XX], ...
138 std::vector<docstring> const
139 getNumericalStrings(docstring const & key, Buffer const & buf) const;
141 * "Translates" the available Citation Styles into strings for a given key.
142 * The returned string is displayed by the GUI.
143 * Eg, the vector will contain:
144 * Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
149 std::vector<docstring> const
150 getAuthorYearStrings(docstring const & key, Buffer const & buf) const;
152 const_iterator begin() const { return bimap_.begin(); }
154 void clear() { bimap_.clear(); }
156 bool empty() const { return bimap_.empty(); }
158 const_iterator end() const { return bimap_.end(); }
160 const_iterator find(docstring const & f) const { return bimap_.find(f); }
162 BibTeXInfo & operator[](docstring const & f) { return bimap_[f]; }
164 void addFieldName(docstring const & f) { field_names_.insert(f); }
166 void addEntryType(docstring const & f) { entry_types_.insert(f); }
169 std::set<docstring> field_names_;
171 std::set<docstring> entry_types_;
172 /// our map: keys --> BibTeXInfo
173 std::map<docstring, BibTeXInfo> bimap_;
178 #endif // BIBLIOINFO_H