X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBranchList.cpp;h=a593c5478fc91e9b421537f6cc849b32b2590238;hb=24fe5b08c0e1dfb739738acb6fc995da7315d35f;hp=2867f49e4ad436ddaca924c05d748a3835d2fb30;hpb=9383f4c3c6f9cfab2d658701ba66e2b54cd68bea;p=lyx.git diff --git a/src/BranchList.cpp b/src/BranchList.cpp index 2867f49e4a..a593c5478f 100644 --- a/src/BranchList.cpp +++ b/src/BranchList.cpp @@ -19,8 +19,25 @@ using namespace std; + namespace lyx { +namespace { + +class BranchNamesEqual : public std::unary_function +{ +public: + BranchNamesEqual(docstring const & name) : name_(name) {} + + bool operator()(Branch const & branch) const + { + return branch.branch() == name_; + } +private: + docstring name_; +}; +} + Branch::Branch() : selected_(false) { @@ -30,7 +47,7 @@ Branch::Branch() : selected_(false) } -docstring const & Branch::getBranch() const +docstring const & Branch::branch() const { return branch_; } @@ -42,7 +59,7 @@ void Branch::setBranch(docstring const & s) } -bool Branch::getSelected() const +bool Branch::isSelected() const { return selected_; } @@ -57,7 +74,7 @@ bool Branch::setSelected(bool b) } -RGBColor const & Branch::getColor() const +RGBColor const & Branch::color() const { return color_; } @@ -82,7 +99,7 @@ void Branch::setColor(string const & str) Branch * BranchList::find(docstring const & name) { List::iterator it = - std::find_if(list.begin(), list.end(), BranchNamesEqual(name)); + find_if(list.begin(), list.end(), BranchNamesEqual(name)); return it == list.end() ? 0 : &*it; } @@ -90,7 +107,7 @@ Branch * BranchList::find(docstring const & name) Branch const * BranchList::find(docstring const & name) const { List::const_iterator it = - std::find_if(list.begin(), list.end(), BranchNamesEqual(name)); + find_if(list.begin(), list.end(), BranchNamesEqual(name)); return it == list.end() ? 0 : &*it; } @@ -98,9 +115,9 @@ Branch const * BranchList::find(docstring const & name) const bool BranchList::add(docstring const & s) { bool added = false; - docstring::size_type i = 0; + size_t i = 0; while (true) { - docstring::size_type const j = s.find_first_of(separator_, i); + size_t const j = s.find_first_of(separator_, i); docstring name; if (j == docstring::npos) name = s.substr(i); @@ -108,7 +125,7 @@ bool BranchList::add(docstring const & s) name = s.substr(i, j - i); // Is this name already in the list? bool const already = - std::find_if(list.begin(), list.end(), + find_if(list.begin(), list.end(), BranchNamesEqual(name)) != list.end(); if (!already) { added = true;