This patch removes the contains_functor and make contains be a
template, also when checking for a char use 'c' not "c".

Will go in shortly.

? Config
? advdist.diff
? contains.diff
? func.diff
? positer.diff
? usingstd.diff
Index: src/vc-backend.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/vc-backend.C,v
retrieving revision 1.48
diff -u -p -b -r1.48 vc-backend.C
--- src/vc-backend.C	17 Oct 2003 18:23:40 -0000	1.48
+++ src/vc-backend.C	1 Feb 2004 12:22:44 -0000
@@ -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.
Index: src/frontends/controllers/biblio.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/biblio.C,v
retrieving revision 1.60
diff -u -p -b -r1.60 biblio.C
--- src/frontends/controllers/biblio.C	31 Jan 2004 15:30:23 -0000	1.60
+++ src/frontends/controllers/biblio.C	1 Feb 2004 12:22:45 -0000
@@ -372,7 +372,7 @@ string const parseBibTeX(string data, st
 		// 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: src/frontends/gnome/GFloat.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gnome/GFloat.C,v
retrieving revision 1.7
diff -u -p -b -r1.7 GFloat.C
--- src/frontends/gnome/GFloat.C	23 Aug 2003 00:16:37 -0000	1.7
+++ src/frontends/gnome/GFloat.C	1 Feb 2004 12:22:45 -0000
@@ -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: src/frontends/qt2/floatplacement.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/floatplacement.C,v
retrieving revision 1.6
diff -u -p -b -r1.6 floatplacement.C
--- src/frontends/qt2/floatplacement.C	6 Oct 2003 15:42:52 -0000	1.6
+++ src/frontends/qt2/floatplacement.C	1 Feb 2004 12:22:45 -0000
@@ -111,22 +111,22 @@ void FloatPlacement::set(string const & 
 
 	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: src/frontends/qt2/lengthcombo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lengthcombo.C,v
retrieving revision 1.17
diff -u -p -b -r1.17 lengthcombo.C
--- src/frontends/qt2/lengthcombo.C	5 Dec 2003 16:22:35 -0000	1.17
+++ src/frontends/qt2/lengthcombo.C	1 Feb 2004 12:22:45 -0000
@@ -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: src/frontends/xforms/FormDocument.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormDocument.C,v
retrieving revision 1.164
diff -u -p -b -r1.164 FormDocument.C
--- src/frontends/xforms/FormDocument.C	14 Dec 2003 16:33:56 -0000	1.164
+++ src/frontends/xforms/FormDocument.C	1 Feb 2004 12:22:45 -0000
@@ -40,20 +40,23 @@
 #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, "|");
Index: src/frontends/xforms/FormFloat.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormFloat.C,v
retrieving revision 1.30
diff -u -p -b -r1.30 FormFloat.C
--- src/frontends/xforms/FormFloat.C	6 Oct 2003 15:42:54 -0000	1.30
+++ src/frontends/xforms/FormFloat.C	1 Feb 2004 12:22:45 -0000
@@ -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: src/frontends/xforms/FormParagraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormParagraph.C,v
retrieving revision 1.100
diff -u -p -b -r1.100 FormParagraph.C
--- src/frontends/xforms/FormParagraph.C	28 Nov 2003 15:53:33 -0000	1.100
+++ src/frontends/xforms/FormParagraph.C	1 Feb 2004 12:22:45 -0000
@@ -32,11 +32,14 @@
 
 #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: src/frontends/xforms/FormTabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormTabular.C,v
retrieving revision 1.81
diff -u -p -b -r1.81 FormTabular.C
--- src/frontends/xforms/FormTabular.C	6 Oct 2003 15:42:57 -0000	1.81
+++ src/frontends/xforms/FormTabular.C	1 Feb 2004 12:22:46 -0000
@@ -24,11 +24,14 @@
 
 #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: src/frontends/xforms/FormVSpace.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormVSpace.C,v
retrieving revision 1.6
diff -u -p -b -r1.6 FormVSpace.C
--- src/frontends/xforms/FormVSpace.C	5 Dec 2003 02:42:41 -0000	1.6
+++ src/frontends/xforms/FormVSpace.C	1 Feb 2004 12:22:46 -0000
@@ -33,11 +33,14 @@
 
 #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: src/insets/insetcite.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcite.C,v
retrieving revision 1.75
diff -u -p -b -r1.75 insetcite.C
--- src/insets/insetcite.C	11 Dec 2003 15:23:15 -0000	1.75
+++ src/insets/insetcite.C	1 Feb 2004 12:22:46 -0000
@@ -194,10 +194,10 @@ string const getBasicLabel(string const 
 	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: src/insets/insetfloat.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloat.C,v
retrieving revision 1.118
diff -u -p -b -r1.118 insetfloat.C
--- src/insets/insetfloat.C	20 Jan 2004 14:25:14 -0000	1.118
+++ src/insets/insetfloat.C	1 Feb 2004 12:22:46 -0000
@@ -241,7 +241,7 @@ void InsetFloat::read(Buffer const & buf
 
 void InsetFloat::validate(LaTeXFeatures & features) const
 {
-	if (contains(params_.placement, "H")) {
+	if (contains(params_.placement, 'H')) {
 		features.require("float");
 	}
 
Index: src/insets/insetlatexaccent.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.C,v
retrieving revision 1.88
diff -u -p -b -r1.88 insetlatexaccent.C
--- src/insets/insetlatexaccent.C	5 Nov 2003 12:06:16 -0000	1.88
+++ src/insets/insetlatexaccent.C	1 Feb 2004 12:22:46 -0000
@@ -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: src/support/lstrings.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lstrings.C,v
retrieving revision 1.84
diff -u -p -b -r1.84 lstrings.C
--- src/support/lstrings.C	31 Jan 2004 15:30:24 -0000	1.84
+++ src/support/lstrings.C	1 Feb 2004 12:22:46 -0000
@@ -324,22 +324,6 @@ bool suffixIs(string const & a, string c
 }
 
 
-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: src/support/lstrings.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lstrings.h,v
retrieving revision 1.55
diff -u -p -b -r1.55 lstrings.h
--- src/support/lstrings.h	31 Jan 2004 15:30:24 -0000	1.55
+++ src/support/lstrings.h	1 Feb 2004 12:22:46 -0000
@@ -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: src/tex2lyx/text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/text.C,v
retrieving revision 1.32
diff -u -p -b -r1.32 text.C
--- src/tex2lyx/text.C	7 Jan 2004 18:30:14 -0000	1.32
+++ src/tex2lyx/text.C	1 Feb 2004 12:22:47 -0000
@@ -445,7 +445,7 @@ void parse_box(Parser & p, ostream & os,
 	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)
-- 
        Lgb

Reply via email to