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;
48 BibTeXInfo() : is_bibtex_(true) {}
49 /// argument sets isBibTeX_, so should be false only if it's coming
50 /// from a bibliography environment
51 BibTeXInfo(bool ib) : is_bibtex_(ib) {}
52 /// constructor that sets the entryType
53 BibTeXInfo(docstring const & key, docstring const & type);
54 /// Search for the given field and return the associated info.
55 /// The point of this is that BibTeXInfo::operator[] has no const
57 docstring const & getValueForField(docstring const & field) const;
59 docstring const & getValueForField(std::string const & field) const;
61 bool hasField(docstring const & field) const;
62 /// return the short form of an authorlist
63 docstring const getAbbreviatedAuthor() const;
65 docstring const getYear() const;
66 /// Returns formatted BibTeX data suitable for framing.
67 docstring const getInfo() const;
69 int count(docstring const & f) const { return bimap_.count(f); }
71 const_iterator find(docstring const & f) const { return bimap_.find(f); }
73 const_iterator end() const { return bimap_.end(); }
75 docstring & operator[](docstring const & f)
78 docstring const & allData() const { return all_data_; }
80 void setAllData(docstring const & d) { all_data_ = d; }
82 docstring entryType() const { return entry_type_; }
84 /// true if from BibTeX; false if from bibliography environment
86 /// the BibTeX key for this entry
88 /// a single string containing all BibTeX data associated with this key
90 /// the BibTeX entry type (article, book, incollection, ...)
91 docstring entry_type_;
92 /// our map: <field, value>
93 std::map <docstring, docstring> bimap_;
97 /// Class to represent a collection of bibliographical data, whether
98 /// from BibTeX or from bibliography environments.
99 /// BiblioInfo.first is the bibliography key
100 /// 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 /// return the short form of an authorlist
112 docstring const getAbbreviatedAuthor(docstring const & key) const;
113 /// return the year from the bibtex data record
114 docstring const getYear(docstring const & key) const;
115 /// Returns formatted BibTeX data associated with a given key.
116 /// Empty if no info exists.
117 docstring const getInfo(docstring const & key) const;
120 * "Translates" the available Citation Styles into strings for a given key,
121 * either numerical or author-year depending upon the active engine. (See
122 * below for those methods.)
124 std::vector<docstring> const
125 getCiteStrings(docstring const & key, Buffer const & buf) const;
127 * "Translates" the available Citation Styles into strings for a given key.
128 * The returned string is displayed by the GUI.
129 * [XX] is used in place of the actual reference
130 * Eg, the vector will contain: [XX], Jones et al. [XX], ...
135 std::vector<docstring> const
136 getNumericalStrings(docstring const & key, Buffer const & buf) const;
138 * "Translates" the available Citation Styles into strings for a given key.
139 * The returned string is displayed by the GUI.
140 * Eg, the vector will contain:
141 * Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
146 std::vector<docstring> const
147 getAuthorYearStrings(docstring const & key, Buffer const & buf) const;
149 const_iterator begin() const { return bimap_.begin(); }
151 void clear() { bimap_.clear(); }
153 bool empty() const { return bimap_.empty(); }
155 const_iterator end() const { return bimap_.end(); }
157 const_iterator find(docstring const & f) const { return bimap_.find(f); }
159 void mergeBiblioInfo(BiblioInfo const & info);
161 BibTeXInfo & operator[](docstring const & f) { return bimap_[f]; }
163 void addFieldName(docstring const & f) { field_names_.insert(f); }
165 void addEntryType(docstring const & f) { entry_types_.insert(f); }
168 std::set<docstring> field_names_;
170 std::set<docstring> entry_types_;
171 /// our map: keys --> BibTeXInfo
172 std::map<docstring, BibTeXInfo> bimap_;
177 #endif // BIBLIOINFO_H