]> git.lyx.org Git - features.git/commitdiff
Cleanup usage of contains and simplify a bit.
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 1 Feb 2004 12:46:14 +0000 (12:46 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 1 Feb 2004 12:46:14 +0000 (12:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8378 a592a061-630c-0410-9148-cb99ea01b6c8

24 files changed:
src/ChangeLog
src/frontends/controllers/ChangeLog
src/frontends/controllers/biblio.C
src/frontends/gnome/ChangeLog
src/frontends/gnome/GFloat.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/floatplacement.C
src/frontends/qt2/lengthcombo.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormFloat.C
src/frontends/xforms/FormParagraph.C
src/frontends/xforms/FormTabular.C
src/frontends/xforms/FormVSpace.C
src/insets/ChangeLog
src/insets/insetcite.C
src/insets/insetfloat.C
src/insets/insetlatexaccent.C
src/support/ChangeLog
src/support/lstrings.C
src/support/lstrings.h
src/tex2lyx/ChangeLog
src/tex2lyx/text.C
src/vc-backend.C

index dd2164e0f89dd85639974b293ad2a55abd5b6a3f..d58c83408abe518b1912f5bbfddb6cfee5086e5a 100644 (file)
@@ -1,7 +1,11 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * vc-backend.C (scanMaster): ";" -> ';'
+
 2004-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * lyxtextclasslist.C (less_textclass_avail_desc): inherit from
-       std::binary_function 
+       std::binary_function
 
        * lyxtextclass.C (compare_name): rename to...
        (LayoutNamesEqual): ...this
@@ -24,7 +28,7 @@
        (getConverter): use it, and make function const
        (getNumber): use it, and make function const
        (add): use it
-       (erase): use it: 
+       (erase): use it:
 
        * bufferlist.C: add using boost::bind
 
index e15fb3860a7085b0d36368ee5cac750741f017ec..b6f08b2fca26232c6dfa565de603fd2c87cdcb7a 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * biblio.C (parseBibTeX): "=" -> '='
+
 2004-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * biblio.C (RegexMatch): inherit from std::unary_function, make
index 29213a98c3091df7968cff891f4f3a4e9d2c7a17..a6c0a4ad1bdbcdc2f0c30b904e07df26d09453dc 100644 (file)
@@ -372,7 +372,7 @@ string const parseBibTeX(string data, string const & findkey)
                // the \n and in the second we replace it
                // with a space
                if (!dummy.empty()) {
-                       if (!contains(dummy, "="))
+                       if (!contains(dummy, '='))
                                data_ += ' ' + dummy;
                        else
                                data_ += dummy;
index 674533e4b8c8cd74d27c8d3cc5fa592af295f183..7f1bdeb618758316077065af0e5aea2d9da9d8bb 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * GFloat.C (update): "c" -> 'c' in calls to contains
+
 2003-12-14  Michael Schmitt  <michael.schmitt@teststep.org>
 
        * Dialogs.C:
index bc40754ed6aed9e955307fa8db44a8f6cea21fab..53df5c9003f3c4e2de6dc0e2d320a7125bec082e 100644 (file)
@@ -73,19 +73,19 @@ void GFloat::update()
 
        string placement(controller().params().placement);
 
-       if (contains(placement, "H")) {
+       if (contains(placement, 'H')) {
                forcehere = true;
        } else {
-               if (contains(placement, "t")) {
+               if (contains(placement, 't')) {
                        top = true;
                }
-               if (contains(placement, "b")) {
+               if (contains(placement, 'b')) {
                        bottom = true;
                }
-               if (contains(placement, "p")) {
+               if (contains(placement, 'p')) {
                        page = true;
                }
-               if (contains(placement, "h")) {
+               if (contains(placement, 'h')) {
                        here = true;
                }
        }
index b7ba44559c38e5a71d714e4a8b34adbac88f613e..bffc44e6c6160305d42954667f2e4566d044f38c 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * floatplacement.C (set): "c" -> 'c' in calls to contains
+
 2004-01-28  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * QPrefs.C: add using statement for std::distance
index 5284b473f226b0190401805530c59e8f54047261..cf0150bab49caf069171a6cb95622f3426cd7479 100644 (file)
@@ -111,22 +111,22 @@ void FloatPlacement::set(string const & placement)
 
        if (placement.empty()) {
                def_placement = true;
-       } else if (contains(placement, "H")) {
+       } else if (contains(placement, 'H')) {
                here_definitely = true;
        } else {
-               if (contains(placement, "!")) {
+               if (contains(placement, '!')) {
                        force = true;
                }
-               if (contains(placement, "t")) {
+               if (contains(placement, 't')) {
                        top = true;
                }
-               if (contains(placement, "b")) {
+               if (contains(placement, 'b')) {
                        bottom = true;
                }
-               if (contains(placement, "p")) {
+               if (contains(placement, 'p')) {
                        page = true;
                }
-               if (contains(placement, "h")) {
+               if (contains(placement, 'h')) {
                        here = true;
                }
        }
index ce0a4b07ddacac512603c6c70654f28295b526d6..09261a8074dec4b5d40aa71b0c297a31e26dbb7e 100644 (file)
@@ -62,7 +62,7 @@ void LengthCombo::noPercents()
 {
        int num = QComboBox::count();
        for (int i = 0; i < num; i++) {
-               if (QComboBox::text(i).contains("%") > 0) {
+               if (QComboBox::text(i).contains('%') > 0) {
                        QComboBox::removeItem(i);
                        i -= 1;
                        num -= 1;
index 5c19af12b7df03185754dbe8bef9548d79d47a39..8f6ee4b1f64563f3837b23969272c164f7773a96 100644 (file)
@@ -1,3 +1,13 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * FormFloat.C (update): "c" -> 'c' in calls to contains
+
+       * FormDocument.C (build): use boost::bind instead of bind2nd, use
+       contains<char> instead of contains_functor
+       * FormParagraph.C (build): ditto
+       * FormTabular.C (build): ditto
+       * FormVSpace.C (build): ditto
+
 2004-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * RadioButtonGroup.C (is_set_button): inherit from
index 54d64115057cf9a2d95176244913c265d90b3299..e15aa4018a81afed0c0d5f5cb60861f1e8979075 100644 (file)
 #include "vspace.h"
 
 #include "support/tostr.h"
-#include "support/lstrings.h" // contains_functor, getStringFromVector
+#include "support/lstrings.h" // contains, getStringFromVector
 #include "support/filetools.h" // LibFileSearch
 
 #include "lyx_xpm.h"
 
+#include <boost/bind.hpp>
+
 #include <iomanip>
 
 using lyx::support::bformat;
-using lyx::support::contains_functor;
+using lyx::support::contains;
 using lyx::support::getStringFromVector;
 using lyx::support::getVectorFromString;
 using lyx::support::LibFileSearch;
 
-using std::bind2nd;
+using boost::bind;
+
 using std::endl;
 using std::string;
 using std::vector;
@@ -169,7 +172,7 @@ void FormDocument::build()
        vector<string>::iterator ret =
                std::remove_if(units_vec.begin(),
                               units_vec.end(),
-                              bind2nd(contains_functor(), "%"));
+                              bind(contains<char>, _1, '%'));
        units_vec.erase(ret, units_vec.end());
 
        string const units = getStringFromVector(units_vec, "|");
@@ -759,7 +762,7 @@ void FormDocument::branch_input(FL_OBJECT * ob)
                        fl_get_browser_line(branch_->browser_all_branches, i);
 
                Branch * branch = branchlist_.find(current_branch);
-               
+
                if (branch && branch->setSelected(selected))
                        rebuild_selected_branches_browser();
 
index a102a525d8182c28c83c0cc839f2e66ab4e8cdfb..c683fbcfbade875b25067ebba6b4cc76e1c65b48 100644 (file)
@@ -160,13 +160,13 @@ void FormFloat::update()
        string placement(controller().params().placement);
        bool const wide = controller().params().wide;
 
-       bool const here_definitely = contains(placement, "H");
+       bool const here_definitely = contains(placement, 'H');
 
-       bool const top    = contains(placement, "t");
-       bool const bottom = contains(placement, "b");
-       bool const page   = contains(placement, "p");
-       bool const here   = contains(placement, "h");
-       bool const force  = contains(placement, "!");
+       bool const top    = contains(placement, 't');
+       bool const bottom = contains(placement, 'b');
+       bool const page   = contains(placement, 'p');
+       bool const here   = contains(placement, 'h');
+       bool const force  = contains(placement, '!');
        bool const alternatives = top || bottom || page || (here && !wide);
 
        if (alternatives) {
index b5bfe655d8b605e51b0ae09ef703a1897f54aa7e..316f98c6ab2967fec3e087b786cc2dd6a41739e4 100644 (file)
 
 #include "lyx_forms.h"
 
-using lyx::support::contains_functor;
+#include <boost/bind.hpp>
+
+using lyx::support::contains;
 using lyx::support::getStringFromVector;
 using lyx::support::rtrim;
 
-using std::bind2nd;
+using boost::bind;
+
 using std::remove_if;
 
 using std::vector;
@@ -98,7 +101,7 @@ void FormParagraph::build()
        vector<string> units_vec = getLatexUnits();
        vector<string>::iterator del =
                remove_if(units_vec.begin(), units_vec.end(),
-                         bind2nd(contains_functor(), "%"));
+                         bind(contains<char>, _1, '%'));
        units_vec.erase(del, units_vec.end());
 
        // set default unit for custom length
index f7c6ead413687a6fce474d8d757bc00fc9fccec6..88d0860fad39f4b4116be94c00cf1369805a3ed2 100644 (file)
 
 #include "lyx_forms.h"
 
-using lyx::support::contains_functor;
+#include <boost/bind.hpp>
+
+using lyx::support::contains;
 using lyx::support::getStringFromVector;
 using lyx::support::isStrDbl;
 
-using std::bind2nd;
+using boost::bind;
+
 using std::string;
 using std::vector;
 
@@ -81,7 +84,7 @@ void FormTabular::build()
        vector<string> units_vec = getLatexUnits();
        vector<string>::iterator ret =
                remove_if(units_vec.begin(), units_vec.end(),
-                         bind2nd(contains_functor(), "%"));
+                         bind(contains<char>, _1, '%'));
        units_vec.erase(ret, units_vec.end());
        string const units = getStringFromVector(units_vec, "|");
 
index 09777af5fea69ecfdb17c37f723dad7febcd0fe7..a94686ceecc506fa2f92ef7938930263f55c2b28 100644 (file)
 
 #include "lyx_forms.h"
 
-using lyx::support::contains_functor;
+#include <boost/bind.hpp>
+
+using lyx::support::contains;
 using lyx::support::getStringFromVector;
 using lyx::support::rtrim;
 
-using std::bind2nd;
+using boost::bind;
+
 using std::remove_if;
 
 using std::vector;
@@ -196,7 +199,7 @@ void FormVSpace::build()
        vector<string> units_vec = getLatexUnits();
        vector<string>::iterator del =
                remove_if(units_vec.begin(), units_vec.end(),
-                         bind2nd(contains_functor(), "%"));
+                         bind(contains<char>, _1, '%'));
        units_vec.erase(del, units_vec.end());
 
        string const units = getStringFromVector(units_vec, "|");
index 57c34f57a2c03bdf636bfd0169ed1d0b754b045b..3451fd64e9af19bc312f2bb37633453ae72b4a57 100644 (file)
@@ -1,3 +1,10 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * insetlatexaccent.C (checkContents): "c" -> 'c' in calls to contains
+
+       * insetfloat.C (validate): "H" -> 'H' in call to contains
+
+       * insetcite.C (getBasicLabel): "," -> ',' in calls to contains
 
 2004-01-30  André Pönitz  <poenitz@gmx.net>
        * inset.[Ch]:
index 05d168c01ef8647df42d72c196bccd3d767d19e9..bbb874d4f2aa6fb4ee8e9b2eed9823e37a77ebf5 100644 (file)
@@ -194,10 +194,10 @@ string const getBasicLabel(string const & keyList, string const & after)
        string keys(keyList);
        string label;
 
-       if (contains(keys, ",")) {
+       if (contains(keys, ',')) {
                // Final comma allows while loop to cover all keys
                keys = ltrim(split(keys, label, ',')) + ',';
-               while (contains(keys, ",")) {
+               while (contains(keys, ',')) {
                        string key;
                        keys = ltrim(split(keys, key, ','));
                        label += ", " + key;
index 4e7ba7c409a51306f9cac5f8256f92086b96acc6..e5caa64fa6bb1a81144431360ac73be380d5a84d 100644 (file)
@@ -241,7 +241,7 @@ void InsetFloat::read(Buffer const & buf, LyXLex & lex)
 
 void InsetFloat::validate(LaTeXFeatures & features) const
 {
-       if (contains(params_.placement, "H")) {
+       if (contains(params_.placement, 'H')) {
                features.require("float");
        }
 
@@ -356,7 +356,7 @@ int InsetFloat::docbook(Buffer const & buf, ostream & os,
 bool InsetFloat::insetAllowed(InsetOld::Code code) const
 {
        return code != InsetOld::FLOAT_CODE
-           && code != InsetOld::FOOT_CODE 
+           && code != InsetOld::FOOT_CODE
            && code != InsetOld::MARGIN_CODE;
 }
 
index 2929970213e015d30e6ae00a3fcfa4220aa19872..02fed3d41726bd70eb92a509557c21dcaa61d977 100644 (file)
@@ -68,7 +68,7 @@ void InsetLatexAccent::checkContents()
        // REMOVE IN 0.13
        // Dirty Hack for backward compability. remove in 0.13 (Lgb)
        contents = trim(contents);
-       if (!contains(contents, "{") && !contains(contents, "}")) {
+       if (!contains(contents, '{') && !contains(contents, '}')) {
                if (contents.length() == 2) {
                        string tmp;
                        tmp += contents[0];
index 8e7e356f77861a9173dab012e35d26e11e6fc18a..1047ccd03d3122aa6540b73af99361cb323960a9 100644 (file)
@@ -1,10 +1,17 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * lstrings.h (contains_functor): delete
+       (contains): change into template, simplify
+
+       * lstrings.C (contains): remove both functions
+
 2004-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * lyxalgo.h (eliminate_duplicates): reimplement with sort and the
        unique-erase idom.
 
        * lstrings.h (contains_functor): inherit from
-       std::binary_function, remove typedefs. 
+       std::binary_function, remove typedefs.
 
 2004-01-28  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
index 337b128a2d47a660320b384d9827cfdb418b50da..c4182fb5a10ee38a34be9976d315923ea2d45ab2 100644 (file)
@@ -324,22 +324,6 @@ bool suffixIs(string const & a, string const & suf)
 }
 
 
-bool contains(string const & a, string const & b)
-{
-       if (a.empty())
-               return false;
-       return a.find(b) != string::npos;
-}
-
-
-bool contains(string const & a, char b)
-{
-       if (a.empty())
-               return false;
-       return a.find(b) != string::npos;
-}
-
-
 bool containsOnly(string const & s, string const & cset)
 {
        return s.find_first_not_of(cset) == string::npos;
index 7101f24a8802e2a0229e8b9671b0be8c91047b84..7d371266e327ac143cb1e26b10b4c78841c0b018 100644 (file)
@@ -97,22 +97,11 @@ bool suffixIs(std::string const &, char);
 bool suffixIs(std::string const &, std::string const &);
 
 ///
-bool contains(std::string const & a, std::string const & b);
-
-///
-bool contains(std::string const & a, char b);
-
-/// This should probably we rewritten to be more general.
-struct contains_functor
-       : public std::binary_function<std::string, std::string, bool>
+template <typename B>
+bool contains(std::string const & a, B b)
 {
-       bool operator()(std::string const & haystack,
-                       std::string const & needle) const
-       {
-               return contains(haystack, needle);
-       }
-};
-
+       return a.find(b) != std::string::npos;
+}
 
 ///
 bool containsOnly(std::string const &, std::string const &);
index b3da5fbbb11cf42401b9c1dd5c4be0ea0b299f36..4d3f03544f1cbd6db177d8abfe1b99e8437c342c 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-01  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * text.C (parse_box): "\\" -> '\\' in calls to contains.
+
 2004-01-07  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * text.C: reorder the using statements.
index 543fe707fe441180586483899c41c05784f118b3..64c3dda4e4a0bb9299e663faa09371922f34521b 100644 (file)
@@ -445,7 +445,7 @@ void parse_box(Parser & p, ostream & os, unsigned flags, bool outer,
        string width_unit;
        string const latex_width = p.verbatim_item();
        translate_len(latex_width, width_value, width_unit);
-       if (contains(width_unit, "\\") || contains(height_unit, "\\")) {
+       if (contains(width_unit, '\\') || contains(height_unit, '\\')) {
                // LyX can't handle length variables
                ostringstream ss;
                if (use_parbox)
index 414c8e4d9f27999afd24d80ace91dfef3116df33..99bcd4fa4646d305ec61b6b17b9f88a2bb1b1421 100644 (file)
@@ -134,7 +134,7 @@ void RCS::scanMaster()
                        // nothing
                } else if (contains(token, "locks")) {
                        // get locker here
-                       if (contains(token, ";")) {
+                       if (contains(token, ';')) {
                                locker_ = "Unlocked";
                                vcstatus = UNLOCKED;
                                continue;
@@ -153,7 +153,7 @@ void RCS::scanMaster()
                                        vcstatus = LOCKED;
                                        break;
                                }
-                       } while (!contains(tmpt, ";"));
+                       } while (!contains(tmpt, ';'));
 
                } else if (token == "comment") {
                        // we don't need to read any further than this.