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
102 typedef std::map<docstring, BibTeXInfo>::const_iterator const_iterator;
103 /// Returns a sorted vector of bibliography keys
104 std::vector<docstring> const getKeys() const;
105 /// Returns a sorted vector of present BibTeX fields
106 std::vector<docstring> const getFields() const;
107 /// Returns a sorted vector of BibTeX entry types in use
108 std::vector<docstring> const getEntries() const;
109 /// Fills keys with BibTeX information derived from the various insets
110 /// in a given buffer, in its master document.
111 void fillWithBibKeys(Buffer const * const buf);
112 /// return the short form of an authorlist
113 docstring const getAbbreviatedAuthor(docstring const & key) const;
114 /// return the year from the bibtex data record
115 docstring const getYear(docstring const & key) const;
116 /// Returns formatted BibTeX data associated with a given key.
117 /// Empty if no info exists.
118 docstring const getInfo(docstring const & key) const;
121 * "Translates" the available Citation Styles into strings for a given key,
122 * either numerical or author-year depending upon the active engine. (See
123 * below for those methods.)
125 std::vector<docstring> const
126 getCiteStrings(docstring const & key, Buffer const & buf) const;
128 * "Translates" the available Citation Styles into strings for a given key.
129 * The returned string is displayed by the GUI.
130 * [XX] is used in place of the actual reference
131 * Eg, the vector will contain: [XX], Jones et al. [XX], ...
136 std::vector<docstring> const
137 getNumericalStrings(docstring const & key, Buffer const & buf) const;
139 * "Translates" the available Citation Styles into strings for a given key.
140 * The returned string is displayed by the GUI.
141 * Eg, the vector will contain:
142 * Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
147 std::vector<docstring> const
148 getAuthorYearStrings(docstring const & key, Buffer const & buf) const;
150 const_iterator begin() const { return bimap_.begin(); }
152 void clear() { bimap_.clear(); }
154 bool empty() const { return bimap_.empty(); }
156 const_iterator end() const { return bimap_.end(); }
158 const_iterator find(docstring const & f) const { return bimap_.find(f); }
160 BibTeXInfo & operator[](docstring const & f) { return bimap_[f]; }
162 void addFieldName(docstring const & f) { field_names_.insert(f); }
164 void addEntryType(docstring const & f) { entry_types_.insert(f); }
167 std::set<docstring> field_names_;
169 std::set<docstring> entry_types_;
170 /// our map: keys --> BibTeXInfo
171 std::map<docstring, BibTeXInfo> bimap_;
176 #endif // BIBLIOINFO_H