]> git.lyx.org Git - lyx.git/blobdiff - src/Encoding.cpp
Move <algorithm> from DocIterator.h
[lyx.git] / src / Encoding.cpp
index 2379209d270cc25d80b63059377f12cc3cb9c5da..64bb3c0b64a4a9c4a5361596d5b51cd5d5afb09e 100644 (file)
@@ -67,7 +67,7 @@ EncodingException::EncodingException(char_type c)
 }
 
 
-const char * EncodingException::what() const throw()
+const char * EncodingException::what() const noexcept
 {
        return "Could not find LaTeX command for a character";
 }
@@ -228,8 +228,7 @@ pair<docstring, docstring> Encoding::latexString(docstring const & input, bool d
        docstring result;
        docstring uncodable;
        bool terminate = false;
-       for (size_t n = 0; n < input.size(); ++n) {
-               char_type const c = input[n];
+       for (char_type const c : input) {
                try {
                        pair<docstring, bool> latex_char = latexChar(c);
                        docstring const latex = latex_char.first;
@@ -252,10 +251,10 @@ pair<docstring, docstring> Encoding::latexString(docstring const & input, bool d
                        if (dryrun) {
                                result += "<" + _("LyX Warning: ")
                                           + _("uncodable character") + " '";
-                               result += docstring(1, input[n]);
+                               result += docstring(1, c);
                                result += "'>";
                        } else
-                               uncodable += input[n];
+                               uncodable += c;
                }
        }
        return make_pair(result, uncodable);
@@ -274,7 +273,7 @@ vector<char_type> Encoding::symbolsList() const
        // add all encodable characters
        copy(encodable_.begin(), encodable_.end(), back_inserter(symbols));
        // now the ones from the unicodesymbols file that are not already there
-       for (pair<char_type, CharInfo> const & elem : unicodesymbols) {
+       for (auto const & elem : unicodesymbols) {
                if (find(symbols.begin(), symbols.end(), elem.first) == symbols.end())
                        symbols.push_back(elem.first);
        }
@@ -636,9 +635,9 @@ Encodings::fromLyXName(string const & name, bool allowUnsafe) const
 {
        EncodingList::const_iterator const it = encodinglist.find(name);
        if (it == encodinglist.end())
-               return 0;
+               return nullptr;
        if (!allowUnsafe && it->second.unsafe())
-               return 0;
+               return nullptr;
        return &it->second;
 }
 
@@ -662,7 +661,7 @@ Encodings::fromLaTeXName(string const & n, int const & p, bool allowUnsafe) cons
                if ((it->second.latexName() == name) && (it->second.package() & p)
                                && (!it->second.unsafe() || allowUnsafe))
                        return &it->second;
-       return 0;
+       return nullptr;
 }
 
 
@@ -674,7 +673,7 @@ Encodings::fromIconvName(string const & n, int const & p, bool allowUnsafe) cons
                if ((it->second.iconvName() == n) && (it->second.package() & p)
                                && (!it->second.unsafe() || allowUnsafe))
                        return &it->second;
-       return 0;
+       return nullptr;
 }
 
 
@@ -733,14 +732,14 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
                        } else if (prefixIs(flag, "force=")) {
                                vector<string> encs =
                                        getVectorFromString(flag.substr(6), ";");
-                               for (size_t i = 0; i < encs.size(); ++i)
-                                       forcedselected[encs[i]].insert(symbol);
+                               for (auto const & enc : encs)
+                                       forcedselected[enc].insert(symbol);
                                flags |= CharInfoForceSelected;
                        } else if (prefixIs(flag, "force!=")) {
                                vector<string> encs =
                                        getVectorFromString(flag.substr(7), ";");
-                               for (size_t i = 0; i < encs.size(); ++i)
-                                       forcednotselected[encs[i]].insert(symbol);
+                               for (auto const & enc : encs)
+                                       forcednotselected[enc].insert(symbol);
                                flags |= CharInfoForceSelected;
                        } else if (flag == "mathalpha") {
                                mathalpha.insert(symbol);