mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
Some more functor work.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8303 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9387970e7d
commit
4b1212acf2
@ -14,22 +14,6 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class BranchNamesEqual : public std::unary_function<Branch, bool> {
|
|
||||||
public:
|
|
||||||
BranchNamesEqual(string const & name)
|
|
||||||
: name_(name) {}
|
|
||||||
bool operator()(Branch const & branch) const
|
|
||||||
{
|
|
||||||
return branch.getBranch() == name_;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
string name_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace anon
|
|
||||||
|
|
||||||
|
|
||||||
string const & Branch::getBranch() const
|
string const & Branch::getBranch() const
|
||||||
{
|
{
|
||||||
|
@ -98,4 +98,17 @@ private:
|
|||||||
std::string separator_;
|
std::string separator_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BranchNamesEqual : public std::unary_function<Branch, bool> {
|
||||||
|
public:
|
||||||
|
BranchNamesEqual(std::string const & name)
|
||||||
|
: name_(name) {}
|
||||||
|
bool operator()(Branch const & branch) const
|
||||||
|
{
|
||||||
|
return branch.getBranch() == name_;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::string name_;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2004-01-05 Lars Gullik Bjonnes <larsbj@gullik.net>
|
2004-01-05 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||||
|
|
||||||
|
* BranchList.h: move the BranchNamesEqual functor here from...
|
||||||
|
* BranchList.C: ... to here
|
||||||
|
|
||||||
* BranchList.C: new BranchListEqual fuctor, use it. Remove
|
* BranchList.C: new BranchListEqual fuctor, use it. Remove
|
||||||
SameName and match.
|
SameName and match.
|
||||||
(add): replace a finding loop with std::find_if.
|
(add): replace a finding loop with std::find_if.
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2004-01-05 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||||
|
|
||||||
|
* insetbranch.C (isBranchSelected): use the BranchNamesEqual
|
||||||
|
functor
|
||||||
|
get rid of the SameName functor
|
||||||
|
|
||||||
|
* insettabular.C: improve the functor.
|
||||||
|
|
||||||
2003-12-29 Angus Leeming <leeming@lyx.org>
|
2003-12-29 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* insetexternal.C (setParams): update defaultTemplateName.
|
* insetexternal.C (setParams): update defaultTemplateName.
|
||||||
|
@ -117,4 +117,4 @@ libinsets_la_SOURCES = \
|
|||||||
# insetsection.h \
|
# insetsection.h \
|
||||||
# insetsection.C \
|
# insetsection.C \
|
||||||
# insettheorem.C \
|
# insettheorem.C \
|
||||||
# insettheorem.h \
|
# insettheorem.h
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include "support/std_sstream.h"
|
#include "support/std_sstream.h"
|
||||||
|
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::auto_ptr;
|
using std::auto_ptr;
|
||||||
using std::istringstream;
|
using std::istringstream;
|
||||||
@ -147,24 +146,12 @@ InsetBranch::priv_dispatch(FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
struct SameBranch {
|
|
||||||
SameBranch(string const & branch_name) : bn(branch_name) {}
|
|
||||||
bool operator()(Branch const & branch) const
|
|
||||||
{ return bn == branch.getBranch(); }
|
|
||||||
private:
|
|
||||||
string bn;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace anon
|
|
||||||
|
|
||||||
|
|
||||||
bool InsetBranch::isBranchSelected(BranchList const & branchlist) const
|
bool InsetBranch::isBranchSelected(BranchList const & branchlist) const
|
||||||
{
|
{
|
||||||
BranchList::const_iterator it = branchlist.begin();
|
|
||||||
BranchList::const_iterator const end = branchlist.end();
|
BranchList::const_iterator const end = branchlist.end();
|
||||||
it = std::find_if(it, end, SameBranch(params_.branch));
|
BranchList::const_iterator it =
|
||||||
|
std::find_if(branchlist.begin(), end,
|
||||||
|
BranchNamesEqual(params_.branch));
|
||||||
if (it == end)
|
if (it == end)
|
||||||
return false;
|
return false;
|
||||||
return it->getSelected();
|
return it->getSelected();
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
|
|
||||||
#include "support/std_sstream.h"
|
#include "support/std_sstream.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using lyx::graphics::PreviewLoader;
|
using lyx::graphics::PreviewLoader;
|
||||||
@ -120,18 +121,15 @@ TabularFeature tabularFeature[] =
|
|||||||
{ LyXTabular::LAST_ACTION, "" }
|
{ LyXTabular::LAST_ACTION, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FindFeature {
|
|
||||||
///
|
class FeatureEqual : public std::unary_function<TabularFeature, bool> {
|
||||||
FindFeature(LyXTabular::Feature feature)
|
public:
|
||||||
: feature_(feature)
|
FeatureEqual(LyXTabular::Feature feature)
|
||||||
{}
|
: feature_(feature) {}
|
||||||
///
|
bool operator()(TabularFeature const & tf) const {
|
||||||
bool operator()(TabularFeature & tf)
|
|
||||||
{
|
|
||||||
return tf.action == feature_;
|
return tf.action == feature_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
///
|
|
||||||
LyXTabular::Feature feature_;
|
LyXTabular::Feature feature_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,10 +138,10 @@ private:
|
|||||||
|
|
||||||
string const featureAsString(LyXTabular::Feature feature)
|
string const featureAsString(LyXTabular::Feature feature)
|
||||||
{
|
{
|
||||||
TabularFeature * it = tabularFeature;
|
TabularFeature * end = tabularFeature +
|
||||||
TabularFeature * end = it +
|
|
||||||
sizeof(tabularFeature) / sizeof(TabularFeature);
|
sizeof(tabularFeature) / sizeof(TabularFeature);
|
||||||
it = std::find_if(it, end, FindFeature(feature));
|
TabularFeature * it = std::find_if(tabularFeature, end,
|
||||||
|
FeatureEqual(feature));
|
||||||
return (it == end) ? string() : it->feature;
|
return (it == end) ? string() : it->feature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user