]> git.lyx.org Git - features.git/commitdiff
Some more functor work.
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 5 Jan 2004 17:33:57 +0000 (17:33 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 5 Jan 2004 17:33:57 +0000 (17:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8303 a592a061-630c-0410-9148-cb99ea01b6c8

src/BranchList.C
src/BranchList.h
src/ChangeLog
src/insets/ChangeLog
src/insets/Makefile.am
src/insets/insetbranch.C
src/insets/insettabular.C

index dc09595841052b5a563f02b0df1b9842747e960b..1900d956c3fd4becd2daaf7ccebba049bc81e4ce 100644 (file)
 
 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
 {
index 893d8f9b6352657d2268928b44554462c91b5aea..fc57d2478b16e506cd63fda85446f751431cef91 100644 (file)
@@ -98,4 +98,17 @@ private:
        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
index adb10d34f57b7e154e1b9391b6c381a68fb22e0a..ecd51ccce02e7ef58c75405a29e8f048220999ac 100644 (file)
@@ -1,5 +1,8 @@
 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
        SameName and match.
        (add): replace a finding loop with std::find_if.
index d8462e6c5e15734369f39addf91d4d74368422d1..9e265a198f9b7815c75df460b7b94c645f68be90 100644 (file)
@@ -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>
 
        * insetexternal.C (setParams): update defaultTemplateName.
index 676894d5b6ccbaaa97fdb9500cbeb5af22dbf8d8..b4bcf0701119fa6d4f31eeb08bfd782bdabbc0b5 100644 (file)
@@ -117,4 +117,4 @@ libinsets_la_SOURCES = \
 #      insetsection.h \
 #      insetsection.C \
 #      insettheorem.C \
-#      insettheorem.h \
+#      insettheorem.h
index a2e67e0e3c0978f88d8c2cd430dd3ac304ac9d9a..67ecbc6e0b052376ab15797e12f3325fe6bbf53c 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "support/std_sstream.h"
 
-
 using std::string;
 using std::auto_ptr;
 using std::istringstream;
@@ -140,31 +139,19 @@ InsetBranch::priv_dispatch(FuncRequest const & cmd,
                        return DispatchResult(true);
                }
                return InsetCollapsable::priv_dispatch(cmd, idx, pos);
-               
+
        default:
                return InsetCollapsable::priv_dispatch(cmd, idx, pos);
        }
 }
 
 
-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
 {
-       BranchList::const_iterator it = branchlist.begin();
        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)
                return false;
        return it->getSelected();
index e54fcf8c8bd026558dcf67f390ef1de2e194722e..360763d7cc1123ea607f621d891abc3c09bf718e 100644 (file)
@@ -38,6 +38,7 @@
 #include "frontends/Painter.h"
 
 #include "support/std_sstream.h"
+
 #include <iostream>
 
 using lyx::graphics::PreviewLoader;
@@ -120,18 +121,15 @@ TabularFeature tabularFeature[] =
        { LyXTabular::LAST_ACTION, "" }
 };
 
-struct FindFeature {
-       ///
-       FindFeature(LyXTabular::Feature feature)
-               : feature_(feature)
-       {}
-       ///
-       bool operator()(TabularFeature & tf)
-       {
+
+class FeatureEqual : public std::unary_function<TabularFeature, bool> {
+public:
+       FeatureEqual(LyXTabular::Feature feature)
+               : feature_(feature) {}
+       bool operator()(TabularFeature const & tf) const {
                return tf.action == feature_;
        }
 private:
-       ///
        LyXTabular::Feature feature_;
 };
 
@@ -140,10 +138,10 @@ private:
 
 string const featureAsString(LyXTabular::Feature feature)
 {
-       TabularFeature * it  = tabularFeature;
-       TabularFeature * end = it +
+       TabularFeature * end = 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;
 }
 
@@ -282,7 +280,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
                                continue;
                        if (first_visible_cell < 0)
                                first_visible_cell = cell;
-                       if (hasSelection()) 
+                       if (hasSelection())
                                drawCellSelection(pi.pain, nx, y, i, j, cell);
 
                        int const cx = nx + tabular.getBeginningOfTextInCell(cell);
@@ -507,16 +505,16 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
        case LFUN_MOUSE_RELEASE:
                lfunMouseRelease(cmd);
                return DispatchResult(true, true);
-       
+
        default:
                break;
        }
 
        int cell = bv->cursor().data_.back().idx_;
        if (cell != -1) {
-               
+
                if (cell != actcell) {
-                       lyxerr << "## ERROR ## InsetTabular::priv_dispatch: actcell: " 
+                       lyxerr << "## ERROR ## InsetTabular::priv_dispatch: actcell: "
                                << actcell << " and cell " << cell << " should be the same "
                                << "here" << endl;
                }