mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Cleanup usage of contains and simplify a bit.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8378 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3420904448
commit
2e5976a0be
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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, "|");
|
||||
@ -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();
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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, "|");
|
||||
|
||||
|
@ -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, "|");
|
||||
|
@ -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]:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 &);
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user