]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/biblio.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / biblio.C
index d5ebf67a969ffde49fca44c3a729096d4571125e..e689b2213d51d18e43eaca556807f34349f5e17d 100644 (file)
 
 #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)
@@ -41,10 +43,10 @@ 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
@@ -57,7 +59,7 @@ string const familyName(string const & name)
 
 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())
@@ -81,6 +83,7 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
        }
 
        string author = parseBibTeX(data, "author");
+
        if (author.empty())
                author = parseBibTeX(data, "editor");
 
@@ -95,32 +98,20 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
        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())
@@ -184,7 +175,7 @@ vector<string> const getKeys(InfoMap const & map)
 
 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())
@@ -267,9 +258,7 @@ string const escape_special_chars(string const & expr)
        // 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), "\\\\$&"));
 }
 
 
@@ -280,7 +269,7 @@ struct RegexMatch
        // 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())
@@ -291,11 +280,11 @@ struct RegexMatch
                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; }
@@ -376,7 +365,7 @@ string const parseBibTeX(string data, string const & findkey)
                // with a space
                if (!dummy.empty()) {
                        if (!contains(dummy, "="))
-                               data_ += (' ' + dummy);
+                               data_ += ' ' + dummy;
                        else
                                data_ += dummy;
                }
@@ -418,7 +407,7 @@ string const parseBibTeX(string data, string const & findkey)
        keyvalue = dummy;
        dummy = token(data, ',', Entries++);
        while (!contains(dummy, '=') && !dummy.empty()) {
-               keyvalue += (',' + dummy);
+               keyvalue += ',' + dummy;
                dummy = token(data, ',', Entries++);
        }
 
@@ -551,7 +540,7 @@ string const getCiteCommand(CiteStyle command, bool full, bool forceUCase)
        if (full) {
                CiteStyle const * last = citeStylesFull + nCiteStylesFull;
                if (std::find(citeStylesFull, last, command) != last)
-                       cite += "*";
+                       cite += '*';
        }
 
        if (forceUCase) {
@@ -629,7 +618,7 @@ getNumericalStrings(string const & key,
                        break;
 
                case CITEYEARPAR:
-                       str = "(" + year + ")";
+                       str = '(' + year + ')';
                        break;
                }
 
@@ -660,15 +649,15 @@ getAuthorYearStrings(string const & key,
                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:
@@ -684,7 +673,7 @@ getAuthorYearStrings(string const & key,
                        break;
 
                case CITEYEARPAR:
-                       str = "(" + year + ")";
+                       str = '(' + year + ')';
                        break;
                }