#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "LString.h"
#include "biblio.h"
+
+#include "Lsstream.h"
#include "gettext.h" // for _()
#include "helper_funcs.h"
+#include "Lsstream.h"
+#include "LString.h"
+
#include "support/lstrings.h"
#include "support/LAssert.h"
#include <boost/regex.hpp>
-#include "BoostFormat.h"
#include <algorithm>
+using namespace lyx::support;
+
using std::vector;
+
namespace biblio {
string const familyName(string const & name)
// "Surname, F."
// "FirstName Surname"
// "F. Surname"
- string::size_type idx = fname.find(",");
+ string::size_type idx = fname.find(',');
if (idx != string::npos)
return ltrim(fname.substr(0, idx));
- idx = fname.rfind(".");
+ idx = fname.rfind('.');
if (idx != string::npos)
fname = ltrim(fname.substr(idx + 1));
// test if we have a LaTeX Space in front
string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
{
- lyx::Assert(!map.empty());
+ Assert(!map.empty());
InfoMap::const_iterator it = map.find(key);
if (it == map.end())
}
string author = parseBibTeX(data, "author");
+
if (author.empty())
author = parseBibTeX(data, "editor");
if (authors.empty())
return author;
-#if USE_BOOST_FORMAT
- boost::format fmter("");
- if (authors.size() == 2)
- fmter = boost::format(_("%1$s and %2$s"))
- % familyName(authors[0]) % familyName(authors[1]);
- else if (authors.size() > 2)
- fmter = boost::format(_("%1$s et al.")) % familyName(authors[0]);
- else
- fmter = boost::format("%1$s") % familyName(authors[0]);
- return fmter.str();
-#else
- string msg;
if (authors.size() == 2)
- msg = familyName(authors[0]) + _(" and ") + familyName(authors[1]);
- else if (authors.size() > 2)
- msg = familyName(authors[0]) + _("et al.");
- else
- msg = familyName(authors[0]);
- return msg;
-#endif
+ return bformat(_("%1$s and %2$s"),
+ familyName(authors[0]), familyName(authors[1]));
+
+ if (authors.size() > 2)
+ return bformat(_("%1$s et al."), familyName(authors[0]));
+
+ return familyName(authors[0]);
}
string const getYear(InfoMap const & map, string const & key)
{
- lyx::Assert(!map.empty());
+ Assert(!map.empty());
InfoMap::const_iterator it = map.find(key);
if (it == map.end())
string const getInfo(InfoMap const & map, string const & key)
{
- lyx::Assert(!map.empty());
+ Assert(!map.empty());
InfoMap::const_iterator it = map.find(key);
if (it == map.end())
// The '$' must be prefixed with the escape character '\' for
// boost to treat it as a literal.
// Thus, to prefix a matched expression with '\', we use:
- string const fmt("\\\\$&");
-
- return reg.Merge(expr, fmt);
+ return STRCONV(reg.Merge(STRCONV(expr), "\\\\$&"));
}
// re and icase are used to construct an instance of boost::RegEx.
// if icase is true, then matching is insensitive to case
RegexMatch(InfoMap const & m, string const & re, bool icase)
- : map_(m), regex_(re, icase) {}
+ : map_(m), regex_(STRCONV(re), icase) {}
bool operator()(string const & key) {
if (!validRE())
string data = key;
InfoMap::const_iterator info = map_.find(key);
if (info != map_.end())
- data += " " + info->second;
+ data += ' ' + info->second;
// Attempts to find a match for the current RE
// somewhere in data.
- return regex_.Search(data);
+ return regex_.Search(STRCONV(data));
}
bool validRE() const { return regex_.error_code() == 0; }
// with a space
if (!dummy.empty()) {
if (!contains(dummy, "="))
- data_ += (' ' + dummy);
+ data_ += ' ' + dummy;
else
data_ += dummy;
}
keyvalue = dummy;
dummy = token(data, ',', Entries++);
while (!contains(dummy, '=') && !dummy.empty()) {
- keyvalue += (',' + dummy);
+ keyvalue += ',' + dummy;
dummy = token(data, ',', Entries++);
}
if (full) {
CiteStyle const * last = citeStylesFull + nCiteStylesFull;
if (std::find(citeStylesFull, last, command) != last)
- cite += "*";
+ cite += '*';
}
if (forceUCase) {
break;
case CITEYEARPAR:
- str = "(" + year + ")";
+ str = '(' + year + ')';
break;
}
switch (styles[i]) {
case CITE:
case CITET:
- str = author + " (" + year + ")";
+ str = author + " (" + year + ')';
break;
case CITEP:
- str = "(" + author + ", " + year + ")";
+ str = '(' + author + ", " + year + ')';
break;
case CITEALT:
- str = author + " " + year ;
+ str = author + ' ' + year ;
break;
case CITEALP:
break;
case CITEYEARPAR:
- str = "(" + year + ")";
+ str = '(' + year + ')';
break;
}