}
+docstring BibTeXInfo::getValueForKey(string const & key,
+ BibTeXInfo const * const xref) const
+{
+ docstring const ret = operator[](key);
+ if (!ret.empty() || !xref)
+ return ret;
+ return (*xref)[key];
+}
+
+
docstring familyName(docstring const & name)
{
if (name.empty())
}
+docstring const BibTeXInfo::getXRef() const
+{
+ if (!is_bibtex_)
+ return docstring();
+ return operator[]("crossref");
+}
+
+
namespace {
docstring convertLaTeXCommands(docstring const & str)
} // anon namespace
-docstring const BibTeXInfo::getInfo() const
+docstring const & BibTeXInfo::getInfo(BibTeXInfo const * const xref) const
{
if (!info_.empty())
return info_;
}
// FIXME
- // This could be made a lot better using the entryType
+ // This could be made a lot better using the entry_type_
// field to customize the output based upon entry type.
// Search for all possible "required" fields
- docstring author = operator[]("author");
+ docstring author = getValueForKey("author", xref);
if (author.empty())
- author = operator[]("editor");
+ author = getValueForKey("editor", xref);
- docstring year = operator[]("year");
- docstring title = operator[]("title");
- docstring docLoc = operator[]("pages");
+ docstring year = getValueForKey("year", xref);
+ docstring title = getValueForKey("title", xref);
+ docstring docLoc = getValueForKey("pages", xref);
if (docLoc.empty()) {
- docLoc = operator[]("chapter");
+ docLoc = getValueForKey("chapter", xref);
if (!docLoc.empty())
- docLoc = from_ascii("Ch. ") + docLoc;
+ docLoc = _("Ch. ") + docLoc;
} else {
- docLoc = from_ascii("pp. ") + docLoc;
+ docLoc = _("pp. ") + docLoc;
}
- docstring media = operator[]("journal");
+ docstring media = getValueForKey("journal", xref);
if (media.empty()) {
- media = operator[]("publisher");
+ media = getValueForKey("publisher", xref);
if (media.empty()) {
- media = operator[]("school");
+ media = getValueForKey("school", xref);
if (media.empty())
- media = operator[]("institution");
+ media = getValueForKey("institution");
}
}
- docstring volume = operator[]("volume");
+ docstring volume = getValueForKey("volume", xref);
odocstringstream result;
if (!author.empty())
if (!media.empty())
result << ", " << media;
if (!year.empty())
- result << ", " << year;
+ result << " (" << year << ")";
if (!docLoc.empty())
result << ", " << docLoc;
}
// This should never happen (or at least be very unusual!)
- return docstring();
+ static docstring e = docstring();
+ return e;
}
if (it == end())
return docstring();
BibTeXInfo const & data = it->second;
+ docstring year = data.getYear();
+ if (!year.empty())
+ return year;
+ // let's try the crossref
+ docstring const xref = data.getXRef();
+ if (xref.empty())
+ return year; // no luck
+ BiblioInfo::const_iterator const xrefit = find(xref);
+ if (xrefit == end())
+ return year; // no luck again
+ BibTeXInfo const & xref_data = xrefit->second;
+ return xref_data.getYear();
return data.getYear();
}
if (it == end())
return docstring();
BibTeXInfo const & data = it->second;
- return data.getInfo();
+ BibTeXInfo const * xrefptr = 0;
+ docstring const xref = data.getXRef();
+ if (!xref.empty()) {
+ BiblioInfo::const_iterator const xrefit = find(xref);
+ if (xrefit != end())
+ xrefptr = &(xrefit->second);
+ }
+ return data.getInfo(xrefptr);
}