//
//////////////////////////////////////////////////////////////////////
-BibTeXInfo::BibTeXInfo()
- : isBibTeX(true)
+BibTeXInfo::BibTeXInfo(bool ib)
+ : isBibTeX_(ib)
+{}
+
+
+BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type)
+ : isBibTeX_(true), bibKey_(key), entryType_(type)
{}
docstring const BibTeXInfo::getAbbreviatedAuthor() const
{
- if (!isBibTeX)
+ if (!isBibTeX_)
return docstring();
docstring author = getValueForField("author");
if (author.empty()) {
author = getValueForField("editor");
if (author.empty())
- return bibKey;
+ return bibKey_;
}
// OK, we've got some names. Let's format them.
docstring const BibTeXInfo::getYear() const
{
- if (!isBibTeX)
+ if (!isBibTeX_)
return docstring();
docstring year = getValueForField("year");
docstring const BibTeXInfo::getInfo() const
{
- if (!isBibTeX) {
+ if (!isBibTeX_) {
BibTeXInfo::const_iterator it = find(from_ascii("ref"));
return it->second;
}
/// bibliography entry.
/// The keys are BibTeX fields (e.g., author, title, etc),
/// and the values are the associated field values.
-class BibTeXInfo : public std::map<docstring, docstring> {
+class BibTeXInfo {
public:
///
- BibTeXInfo();
- ///Search for the given field and return the associated info.
- ///The point of this is that BibTeXInfo::operator[] has no const
- ///form.
+ typedef std::map<docstring, docstring>::const_iterator const_iterator;
+ /// argument sets isBibTeX_, so should be false only if it's coming
+ /// from a bibliography environment
+ BibTeXInfo(bool ib = true);
+ /// constructor that sets the entryType
+ BibTeXInfo(docstring const & key, docstring const & type);
+ /// Search for the given field and return the associated info.
+ /// The point of this is that BibTeXInfo::operator[] has no const
+ /// form.
docstring const & getValueForField(docstring const & field) const;
///
docstring const & getValueForField(std::string const & field) const;
docstring const getYear() const;
/// Returns formatted BibTeX data suitable for framing.
docstring const getInfo() const;
+ ///
+ int count(docstring const & f) const { return bimap_.count(f); }
+ ///
+ const_iterator find(docstring const & f) const { return bimap_.find(f); }
+ ///
+ const_iterator end() const { return bimap_.end(); }
+ ///
+ docstring & operator[](docstring const & f)
+ { return bimap_[f]; }
+ ///
+ docstring allData() const { return allData_; }
+ ///
+ void allData(docstring const & d) { allData_ = d; }
+ ///
+ docstring entryType() const { return entryType_; }
+private:
/// the BibTeX key for this entry
- docstring bibKey;
+ docstring bibKey_;
/// a single string containing all BibTeX data associated with this key
- docstring allData;
+ docstring allData_;
/// the BibTeX entry type (article, book, incollection, ...)
- docstring entryType;
+ docstring entryType_;
/// true if from BibTeX; false if from bibliography environment
- bool isBibTeX;
+ bool isBibTeX_;
+ /// our map: <field, value>
+ std::map <docstring, docstring> bimap_;
};
BiblioInfo::const_iterator cit = bibkeysInfo_.find(key);
if (cit == bibkeysInfo_.end())
continue;
- if (cit->second.entryType == entryType)
+ if (cit->second.entryType() == entryType)
result.push_back(key);
}
keyVector = result;
if (only_keys)
data = to_utf8(*it);
else if (field.empty())
- data = to_utf8(*it) + ' ' + to_utf8(kvm.allData);
+ data = to_utf8(*it) + ' ' + to_utf8(kvm.allData());
else if (kvm.hasField(field))
data = to_utf8(kvm.getValueForField(field));
docstring value;
docstring commaNewline;
docstring data;
- BibTeXInfo keyvalmap;
- keyvalmap.entryType = entryType;
+ BibTeXInfo keyvalmap(key, entryType);
bool readNext = removeWSAndComma(ifs);
// add the new entry
keylist.entryTypes.insert(entryType);
- keyvalmap.allData = data;
- keyvalmap.isBibTeX = true;
- keyvalmap.bibKey = key;
+ keyvalmap.allData(data);
keylist[key] = keyvalmap;
}
} //< searching '@'