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"
32 ENGINE_NATBIB_AUTHORYEAR
,
33 ENGINE_NATBIB_NUMERICAL
,
53 CitationStyle(CiteStyle s
= CITE
, bool f
= false, bool force
= false)
54 : style(s
), full(f
), forceUCase(force
) {}
55 /// \param latex_str a LaTeX command, "cite", "Citep*", etc
56 CitationStyle(std::string
const & latex_str
);
58 std::string
const asLatexStr() const;
67 /// Returns a vector of available Citation styles.
68 std::vector
<CiteStyle
> const getCiteStyles(CiteEngine
const );
72 /// Class to represent information about a BibTeX or
73 /// bibliography entry.
74 /// The keys are BibTeX fields (e.g., author, title, etc),
75 /// and the values are the associated field values.
79 typedef std::map
<docstring
, docstring
>::const_iterator const_iterator
;
80 /// argument sets isBibTeX_, so should be false only if it's coming
81 /// from a bibliography environment
82 BibTeXInfo(bool ib
= true);
83 /// constructor that sets the entryType
84 BibTeXInfo(docstring
const & key
, docstring
const & type
);
85 /// Search for the given field and return the associated info.
86 /// The point of this is that BibTeXInfo::operator[] has no const
88 docstring
const & getValueForField(docstring
const & field
) const;
90 docstring
const & getValueForField(std::string
const & field
) const;
92 bool hasField(docstring
const & field
) const;
93 /// return the short form of an authorlist
94 docstring
const getAbbreviatedAuthor() const;
96 docstring
const getYear() const;
97 /// Returns formatted BibTeX data suitable for framing.
98 docstring
const getInfo() const;
100 int count(docstring
const & f
) const { return bimap_
.count(f
); }
102 const_iterator
find(docstring
const & f
) const { return bimap_
.find(f
); }
104 const_iterator
end() const { return bimap_
.end(); }
106 docstring
& operator[](docstring
const & f
)
107 { return bimap_
[f
]; }
109 docstring
const & allData() const { return all_data_
; }
111 void setAllData(docstring
const & d
) { all_data_
= d
; }
113 docstring
entryType() const { return entry_type_
; }
115 /// true if from BibTeX; false if from bibliography environment
117 /// the BibTeX key for this entry
119 /// a single string containing all BibTeX data associated with this key
121 /// the BibTeX entry type (article, book, incollection, ...)
122 docstring entry_type_
;
123 /// our map: <field, value>
124 std::map
<docstring
, docstring
> bimap_
;
128 /// Class to represent a collection of bibliographical data, whether
129 /// from BibTeX or from bibliography environments.
130 /// BiblioInfo.first is the bibliography key
131 /// BiblioInfo.second is the data for that key
137 typedef std::map
<docstring
, BibTeXInfo
>::const_iterator const_iterator
;
138 /// Returns a sorted vector of bibliography keys
139 std::vector
<docstring
> const getKeys() const;
140 /// Returns a sorted vector of present BibTeX fields
141 std::vector
<docstring
> const getFields() const;
142 /// Returns a sorted vector of BibTeX entry types in use
143 std::vector
<docstring
> const getEntries() const;
144 /// Fills keys with BibTeX information derived from the various insets
145 /// in a given buffer, in its master document.
146 void fillWithBibKeys(Buffer
const * const buf
);
147 /// return the short form of an authorlist
148 docstring
const getAbbreviatedAuthor(docstring
const & key
) const;
149 /// return the year from the bibtex data record
150 docstring
const getYear(docstring
const & key
) const;
151 /// Returns formatted BibTeX data associated with a given key.
152 /// Empty if no info exists.
153 docstring
const getInfo(docstring
const & key
) const;
156 * "Translates" the available Citation Styles into strings for a given key,
157 * either numerical or author-year depending upon the active engine. (See
158 * below for those methods.)
160 std::vector
<docstring
> const
161 getCiteStrings(docstring
const & key
, Buffer
const & buf
) const;
163 * "Translates" the available Citation Styles into strings for a given key.
164 * The returned string is displayed by the GUI.
165 * [XX] is used in place of the actual reference
166 * Eg, the vector will contain: [XX], Jones et al. [XX], ...
171 std::vector
<docstring
> const
172 getNumericalStrings(docstring
const & key
, Buffer
const & buf
) const;
174 * "Translates" the available Citation Styles into strings for a given key.
175 * The returned string is displayed by the GUI.
176 * Eg, the vector will contain:
177 * Jones et al. (1990), (Jones et al. 1990), Jones et al. 1990, ...
182 std::vector
<docstring
> const
183 getAuthorYearStrings(docstring
const & key
, Buffer
const & buf
) const;
185 const_iterator
begin() const { return bimap_
.begin(); }
187 void clear() { bimap_
.clear(); }
189 bool empty() const { return bimap_
.empty(); }
191 const_iterator
end() const { return bimap_
.end(); }
193 const_iterator
find(docstring
const & f
) const { return bimap_
.find(f
); }
195 BibTeXInfo
& operator[](docstring
const & f
) { return bimap_
[f
]; }
197 void addFieldName(docstring
const & f
) { field_names_
.insert(f
); }
199 void addEntryType(docstring
const & f
) { entry_types_
.insert(f
); }
202 std::set
<docstring
> field_names_
;
204 std::set
<docstring
> entry_types_
;
205 /// our map: keys --> BibTeXInfo
206 std::map
<docstring
, BibTeXInfo
> bimap_
;