adaptablize a functor, remove a warning

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8326 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2004-01-07 18:30:14 +00:00
parent fa494db882
commit c6c9bbdac2
2 changed files with 22 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2004-01-07 Lars Gullik Bjonnes <larsbj@gullik.net>
* text.C: reorder the using statements.
(translate_len): remove usage of a uninitialized variable.
(isLayout): make it adaptable and constify operator()
(findLayout): reformat slightly and dont use the same var for
different things.
2004-01-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* text.C: fix status tag output for ERT inset

View File

@ -26,6 +26,10 @@
#include <sstream>
#include <vector>
using lyx::support::rtrim;
using lyx::support::suffixIs;
using lyx::support::contains;
using std::cerr;
using std::endl;
@ -36,10 +40,6 @@ using std::istringstream;
using std::string;
using std::vector;
using lyx::support::rtrim;
using lyx::support::suffixIs;
using lyx::support::contains;
// thin wrapper around parse_text using a string
string parse_text(Parser & p, unsigned flags, const bool outer,
@ -160,7 +160,7 @@ bool translate_len(string const & length, string & valstring, string & unit)
// a normal length
if (unit.empty() || unit[0] != '\\')
return true;
const string::size_type i = unit.find(" ", i);
string::size_type const i = unit.find(' ');
string const endlen = (i == string::npos) ? string() : string(unit, i);
if (unit == "\\textwidth") {
valstring = percentval;
@ -286,10 +286,11 @@ void handle_comment(ostream & os, string const & s, Context & context)
}
struct isLayout {
class isLayout : public std::unary_function<LyXLayout_ptr, bool> {
public:
isLayout(string const name) : name_(name) {}
bool operator()(LyXLayout_ptr const & ptr) {
return ptr.get() && ptr->latexname() == name_;
bool operator()(LyXLayout_ptr const & ptr) const {
return ptr->latexname() == name_;
}
private:
string const name_;
@ -299,9 +300,12 @@ private:
LyXLayout_ptr findLayout(LyXTextClass const & textclass,
string const & name)
{
LyXTextClass::const_iterator it = textclass.begin();
LyXTextClass::const_iterator beg = textclass.begin();
LyXTextClass::const_iterator end = textclass.end();
it = std::find_if(it, end, isLayout(name));
LyXTextClass::const_iterator
it = std::find_if(beg, end, isLayout(name));
return (it == end) ? LyXLayout_ptr() : *it;
}