src/lyxfunc.C
src/lyxrc.C
src/lyxvc.C
-src/mathed/formulabase.C
+src/mathed/formula.C
src/mathed/formulamacro.C
src/mathed/math_hullinset.C
src/mathed/math_macrotemplate.C
+2004-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
+ * lyxtextclasslist.C (less_textclass_avail_desc): inherit from
+ std::binary_function
+
+ * lyxtextclass.C (compare_name): rename to...
+ (LayoutNamesEqual): ...this
+
+ * lyxlex_pimpl.C (compare_tags): inherit from
+ std::binary_function, put back into anon namespace
+
+ * lyxfind.C (MatchString): inherig from std::binary_function
+ (findChange): use empty() istead of !size()
+
+ * format.C (FormatNamesEqual): new functor
+ (getFormat): use it
+ (getNumber): use it
+ (add): use it
+ (erase): use it
+ (setViewer): use it
+
+ * converter.C (compare_Converter): rename to...
+ (ConverterEqual): ...this, and fixup a bit.
+ (getConverter): use it, and make function const
+ (getNumber): use it, and make function const
+ (add): use it
+ (erase): use it:
+
+ * bufferlist.C: add using boost::bind
+
+ * MenuBackend.C (MenuNamesEqual): new functor
+ (hasMenu): use it, and make function const
+ (hasSubmenu): use nested bind to get rid of compare_memfun.
2004-01-30 André Pönitz <poenitz@gmx.net>
#include "frontends/LyXView.h"
#include "support/filetools.h"
-#include "support/lyxfunctional.h"
#include "support/lstrings.h"
#include "support/tostr.h"
+#include <boost/bind.hpp>
+
#include <algorithm>
using lyx::support::compare_ascii_no_case;
using lyx::support::MakeDisplayPath;
using lyx::support::token;
+using boost::bind;
+
using std::auto_ptr;
using std::endl;
+using std::equal_to;
using std::find_if;
using std::max;
using std::sort;
extern BufferList bufferlist;
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
+namespace {
+
+class MenuNamesEqual : public std::unary_function<Menu, bool> {
+public:
+ MenuNamesEqual(string const & name)
+ : name_(name) {}
+ bool operator()(Menu const & menu) const
+ {
+ return menu.name() == name_;
+ }
+private:
+ string name_;
+};
+
+} // namespace anon
+
+
// This is the global menu definition
MenuBackend menubackend;
view);
return;
}
- CharStyles & charstyles =
+ CharStyles & charstyles =
view->buffer()->params().getLyXTextClass().charstyles();
CharStyles::iterator cit = charstyles.begin();
CharStyles::iterator end = charstyles.end();
bool Menu::hasSubmenu(string const & name) const
{
+#if 1
return find_if(begin(), end(),
- lyx::compare_memfun(&MenuItem::submenuname,
- name)) != end();
+ bind(std::equal_to<string>(),
+ bind(&MenuItem::submenuname, _1),
+ name)) != end();
+#else
+ // I would have prefered this, but I am not sure if it
+ // makes a difference. (Lgb)
+ return find_if(
+ make_transform_iterator(begin(),
+ bind(&MenuItem::submenuname, _1)),
+ make_transform_iterator(end(),
+ bind(&MenuItem::submenuname, _1)),
+ name
+ ).base() != end();
+#endif
}
bool MenuBackend::hasMenu(string const & name) const
{
- return find_if(begin(), end(),
- lyx::compare_memfun(&Menu::name, name)) != end();
+ return find_if(begin(), end(), MenuNamesEqual(name)) != end();
}
Menu const & MenuBackend::getMenu(string const & name) const
{
- const_iterator cit = find_if(begin(), end(),
- lyx::compare_memfun(&Menu::name, name));
+ const_iterator cit = find_if(begin(), end(), MenuNamesEqual(name));
if (cit == end())
lyxerr << "No submenu named " << name << endl;
BOOST_ASSERT(cit != end());
Menu & MenuBackend::getMenu(string const & name)
{
- MenuList::iterator it =
- find_if(menulist_.begin(), menulist_.end(),
- lyx::compare_memfun(&Menu::name, name));
- BOOST_ASSERT(it != menulist_.end());
+ iterator it = find_if(begin(), end(), MenuNamesEqual(name));
+ if (it == end())
+ lyxerr << "No submenu named " << name << endl;
+ BOOST_ASSERT(it != end());
return (*it);
}
/** This is a list of importable formats
typically for the File->Export menu. */
ImportFormats,
- /** This is the list of elements available
+ /** This is the list of elements available
* for insertion into document. */
CharStyles,
/** This is the list of floats that we can
///
typedef MenuList::const_iterator const_iterator;
///
+ typedef MenuList::iterator iterator;
+ ///
void read(LyXLex &);
///
void add(Menu const &);
return menulist_.begin();
}
///
+ iterator begin() {
+ return menulist_.begin();
+ }
+ ///
const_iterator end() const {
return menulist_.end();
}
+ ///
+ iterator end() {
+ return menulist_.end();
+ }
private:
///
MenuList menulist_;
using lyx::support::removeAutosaveFile;
using lyx::support::prefixIs;
+using boost::bind;
+
using std::auto_ptr;
using std::endl;
using std::find;
void BufferList::emergencyWriteAll()
{
for_each(bstore.begin(), bstore.end(),
- boost::bind(&BufferList::emergencyWrite, this, _1));
+ bind(&BufferList::emergencyWrite, this, _1));
}
return result;
}
+
+class ConverterEqual : public std::binary_function<string, string, bool> {
+public:
+ ConverterEqual(string const & from, string const & to)
+ : from_(from), to_(to) {}
+ bool operator()(Converter const & c) const {
+ return c.from == from_ && c.to == to_;
+ }
+private:
+ string const from_;
+ string const to_;
+};
+
} // namespace anon
}
-class compare_Converter {
-public:
- compare_Converter(string const & f, string const & t)
- : from(f), to(t) {}
- bool operator()(Converter const & c) {
- return c.from == from && c.to == to;
- }
-private:
- string const & from;
- string const & to;
-};
-
-
-
Converter const * Converters::getConverter(string const & from,
- string const & to)
+ string const & to) const
{
ConverterList::const_iterator cit =
find_if(converterlist_.begin(), converterlist_.end(),
- compare_Converter(from, to));
+ ConverterEqual(from, to));
if (cit != converterlist_.end())
return &(*cit);
else
}
-int Converters::getNumber(string const & from, string const & to)
+int Converters::getNumber(string const & from, string const & to) const
{
ConverterList::const_iterator cit =
find_if(converterlist_.begin(), converterlist_.end(),
- compare_Converter(from, to));
+ ConverterEqual(from, to));
if (cit != converterlist_.end())
- return cit - converterlist_.begin();
+ return distance(converterlist_.begin(), cit);
else
return -1;
}
formats.add(to);
ConverterList::iterator it = find_if(converterlist_.begin(),
converterlist_.end(),
- compare_Converter(from, to));
+ ConverterEqual(from , to));
Converter converter(from, to, command, flags);
if (it != converterlist_.end() && !flags.empty() && flags[0] == '*') {
{
ConverterList::iterator it = find_if(converterlist_.begin(),
converterlist_.end(),
- compare_Converter(from, to));
+ ConverterEqual(from, to));
if (it != converterlist_.end())
converterlist_.erase(it);
}
return converterlist_[i];
}
///
- Converter const * getConverter(std::string const & from, std::string const & to);
+ Converter const * getConverter(std::string const & from,
+ std::string const & to) const;
///
- int getNumber(std::string const & from, std::string const & to);
+ int getNumber(std::string const & from, std::string const & to) const;
///
void add(std::string const & from, std::string const & to,
std::string const & command, std::string const & flags);
#include "support/filetools.h"
#include "support/path.h"
#include "support/systemcall.h"
-#include "support/lyxfunctional.h"
using lyx::support::bformat;
using lyx::support::compare_ascii_no_case;
string const token_path("$$p");
string const token_socket("$$a");
+
+class FormatNamesEqual : public std::unary_function<Format, bool> {
+public:
+ FormatNamesEqual(string const & name)
+ : name_(name) {}
+ bool operator()(Format const & f) const
+ {
+ return f.name() == name_;
+ }
+private:
+ string name_;
+};
+
} //namespace anon
bool operator<(Format const & a, Format const & b)
}
Format::Format(string const & n, string const & e, string const & p,
- string const & s, string const & v): name_(n),
- extension_(e),
- prettyname_(p),
- shortcut_(s),
- viewer_(v)
+ string const & s, string const & v)
+ : name_(n), extension_(e), prettyname_(p),shortcut_(s), viewer_(v)
{}
{
FormatList::const_iterator cit =
find_if(formatlist.begin(), formatlist.end(),
- lyx::compare_memfun(&Format::name, name));
+ FormatNamesEqual(name));
if (cit != formatlist.end())
return &(*cit);
else
{
FormatList::const_iterator cit =
find_if(formatlist.begin(), formatlist.end(),
- lyx::compare_memfun(&Format::name, name));
+ FormatNamesEqual(name));
if (cit != formatlist.end())
- return cit - formatlist.begin();
+ return distance(formatlist.begin(), cit);
else
return -1;
}
{
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
- lyx::compare_memfun(&Format::name, name));
+ FormatNamesEqual(name));
if (it == formatlist.end())
formatlist.push_back(Format(name, extension, prettyname,
shortcut, ""));
{
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
- lyx::compare_memfun(&Format::name, name));
+ FormatNamesEqual(name));
if (it != formatlist.end())
formatlist.erase(it);
}
add(name);
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
- lyx::compare_memfun(&Format::name, name));
+ FormatNamesEqual(name));
if (it != formatlist.end())
it->setViewer(command);
}
+2004-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * biblio.C (RegexMatch): inherit from std::unary_function, make
+ operator() const and variable regex_ mutable.
+
+ * ControlSpellchecker.C (check): use correct types for the result
+ from distance.
+
2004-01-28 Lars Gullik Bjonnes <larsbj@gullik.net>
* ControlSpellchecker.C: add using statements for std::advance and
PosIterator const beg = buffer()->pos_iterator_begin();
PosIterator const end = buffer()->pos_iterator_end();
- int start = distance(beg, cur);
- int const total = start + distance(cur, end);
+ PosIterator::difference_type start = distance(beg, cur);
+ PosIterator::difference_type const total = start + distance(cur, end);
if (cur != buffer()->pos_iterator_begin())
for (; cur != end && isLetter(cur); ++cur, ++start);
// A functor for use with std::find_if, used to ascertain whether a
// data entry matches the required regex_
-struct RegexMatch
+struct RegexMatch : public std::unary_function<string, bool>
{
// re and icase are used to construct an instance of boost::RegEx.
// if icase is true, then matching is insensitive to case
RegexMatch(InfoMap const & m, string const & re, bool icase)
: map_(m), regex_(re, icase) {}
- bool operator()(string const & key) {
+ bool operator()(string const & key) const {
if (!validRE())
return false;
private:
InfoMap const map_;
- boost::RegEx regex_;
+ mutable boost::RegEx regex_;
};
} // namespace anon
namespace {
-struct Sorter {
+struct Sorter
+ : public std::binary_function<frnt::LanguagePair,
+ frnt::LanguagePair, bool>
+{
bool operator()(frnt::LanguagePair const & lhs,
frnt::LanguagePair const & rhs) const {
return lhs.first < rhs.first;
+2004-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * RadioButtonGroup.C (is_set_button): inherit from
+ std::unary_function
+
2004-01-28 Lars Gullik Bjonnes <larsbj@gullik.net>
* XFormsToolbar.C: add using statement for std::distance
}
-template < typename T >
-struct is_set_button {
+template <typename T>
+struct is_set_button : public std::unary_function<T, bool> {
bool operator() (T const & item) const
{
return fl_get_button((item).first);
+2004-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
+
+ * PreviewLoader.C (FindFirst): inherit from std::unary_function
+ and make operator() const
+ (FindSnippet): inherit from unary_function, simplify slightly.
+
2004-01-07 Lars Gullik Bjonnes <larsbj@gullik.net>
* GraphicsTypes.C: include <string>
using std::find_if;
using std::make_pair;
+using boost::bind;
+
using std::ifstream;
using std::list;
using std::map;
void setAscentFractions(vector<double> & ascent_fractions,
string const & metrics_file);
-struct FindFirst {
+class FindFirst : public std::unary_function<StrPair, bool> {
+public:
FindFirst(string const & comp) : comp_(comp) {}
- bool operator()(StrPair const & sp)
+ bool operator()(StrPair const & sp) const
{
return sp.first == comp_;
}
namespace {
-struct FindSnippet {
+class FindSnippet : public std::unary_function<InProgressProcess, bool> {
+public:
FindSnippet(string const & s) : snippet_(s) {}
- bool operator()(InProgressProcess const & process)
+ bool operator()(InProgressProcess const & process) const
{
BitmapFile const & snippets = process.second.snippets;
- BitmapFile::const_iterator it = snippets.begin();
+ BitmapFile::const_iterator beg = snippets.begin();
BitmapFile::const_iterator end = snippets.end();
- it = find_if(it, end, FindFirst(snippet_));
- return it != end;
+ return find_if(beg, end, FindFirst(snippet_)) != end;
}
private:
- string const & snippet_;
+ string const snippet_;
};
} // namespace anon
// Initiate the conversion from LaTeX to bitmap images files.
support::Forkedcall::SignalTypePtr
convert_ptr(new support::Forkedcall::SignalType);
- convert_ptr->connect(
- boost::bind(&Impl::finishedGenerating, this, _1, _2));
+ convert_ptr->connect(bind(&Impl::finishedGenerating, this, _1, _2));
support::Forkedcall call;
int ret = call.startscript(command, convert_ptr);
}
if (!tablemode) {
-
- int cell = cur.idx();
+ int const cell = cur.idx();
lyxerr << "# InsetTabular::dispatch: A " << cur << endl;
result = tabular.getCellInset(cell).dispatch(cur, cmd);
namespace {
-class MatchString
+class MatchString : public std::binary_function<Paragraph, lyx::pos_type, bool>
{
public:
MatchString(string const & str, bool cs, bool mw)
bool findChange(PosIterator & cur, PosIterator const & end)
{
for (; cur != end; ++cur) {
- if ((!cur.pit()->size() || !cur.at_end())
+ if ((cur.pit()->empty() || !cur.at_end())
&& cur.pit()->lookupChange(cur.pos()) != Change::UNCHANGED)
return true;
}
using std::istream;
using std::ostream;
-// namespace {
-struct compare_tags {
+namespace {
+
+struct compare_tags : public std::binary_function<keyword_item, keyword_item, int> {
// used by lower_bound, sort and sorted
- inline
int operator()(keyword_item const & a, keyword_item const & b) const {
// we use the ascii version, because in turkish, 'i'
// is not the lowercase version of 'I', and thus
return compare_ascii_no_case(a.tag, b.tag) < 0;
}
};
-// } // end of anon namespace
+
+} // end of anon namespace
LyXLex::Pimpl::Pimpl(keyword_item * tab, int num)
using std::ostream;
-namespace { // anon
+namespace {
-struct compare_name {
-
- compare_name(string const & name)
+class LayoutNamesEqual : public std::unary_function<LyXLayout_ptr, bool> {
+public:
+ LayoutNamesEqual(string const & name)
: name_(name)
{}
-
- bool operator()(boost::shared_ptr<LyXLayout> const & c)
+ bool operator()(LyXLayout_ptr const & c) const
{
return c->name() == name_;
}
-
+private:
string name_;
-
};
-} // anon
+} // namespace anon
LyXTextClass::LyXTextClass(string const & fn, string const & cln,
string const & desc, bool texClassAvail )
: name_(fn), latexname_(cln), description_(desc),
- floatlist_(new FloatList), ctrs_(new Counters), texClassAvail_(texClassAvail)
+ floatlist_(new FloatList), ctrs_(new Counters),
+ texClassAvail_(texClassAvail)
{
outputType_ = LATEX;
columns_ = 1;
LyXFont font(LyXFont::ALL_INHERIT);
LyXFont labelfont(LyXFont::ALL_INHERIT);
string preamble;
-
+
bool getout = false;
while (!getout && lexrc.isOK()) {
int le = lexrc.lex();
string const name = (n.empty() ? defaultLayoutName() : n);
return find_if(layoutlist_.begin(), layoutlist_.end(),
- compare_name(name))
+ LayoutNamesEqual(name))
!= layoutlist_.end();
}
LayoutList::const_iterator cit =
find_if(layoutlist_.begin(),
layoutlist_.end(),
- compare_name(name));
+ LayoutNamesEqual(name));
if (cit == layoutlist_.end()) {
lyxerr << "We failed to find the layout '" << name
LayoutList::iterator it =
remove_if(layoutlist_.begin(), layoutlist_.end(),
- compare_name(name));
+ LayoutNamesEqual(name));
LayoutList::iterator end = layoutlist_.end();
bool const ret = (it != end);
LayoutList layoutlist_;
/// CharStyles available to this layout
mutable CharStyles charstylelist_;
-
+
/// available types of float, eg. figure, algorithm.
boost::shared_ptr<FloatList> floatlist_;
// used when sorting the textclass list.
-class less_textclass_avail_desc {
-public:
- int operator()(LyXTextClass const & tc1, LyXTextClass const & tc2) {
+struct less_textclass_avail_desc
+ : public std::binary_function<LyXTextClass, LyXTextClass, int>
+{
+ int operator()(LyXTextClass const & tc1,
+ LyXTextClass const & tc2) const
+ {
// Ordering criteria:
// 1. Availability of text class
// 2. Description (lexicographic)
return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) ||
- (tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() &&
- tc1.description() < tc2.description());
+ (tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() &&
+ tc1.description() < tc2.description());
}
};
void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
MathNestInset::metrics(mi);
- dim = cell(0).dim();
- dim += cell(1).dim();
+ dim = cell(0).dim();
+ dim += cell(1).dim();
dim.asc += 5;
dim.des += 5;
dim.wid += 10 + font_metrics::width(prefix(), mi.base.font);
using std::endl;
using std::max;
-
using std::string;
using std::ostream;
using std::auto_ptr;
+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.
+
2004-01-28 Lars Gullik Bjonnes <larsbj@gullik.net>
* globbing.C: add using statement for std::distance, remove std::
#include <sys/wait.h>
+using boost::bind;
+
using std::endl;
using std::find_if;
using std::string;
timeout_ = new Timeout(100, Timeout::ONETIME);
timeout_->timeout
- .connect(boost::bind(&ForkedcallsController::timer, this));
+ .connect(bind(&ForkedcallsController::timer, this));
}
if (prelen > alen || a.empty())
return false;
else {
-#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
- return ::strncmp(a.c_str(), pre.c_str(), prelen) == 0;
-#else
+#if defined(STD_STRING_IS_GOOD)
return a.compare(0, prelen, pre) == 0;
+#else
+ return ::strncmp(a.c_str(), pre.c_str(), prelen) == 0;
#endif
}
}
bool contains(std::string const & a, char b);
/// This should probably we rewritten to be more general.
-class contains_functor {
-public:
- typedef std::string first_argument_type;
- typedef std::string second_argument_type;
- typedef bool result_type;
-
- bool operator()(std::string const & haystack, std::string const & needle) const {
+struct contains_functor
+ : public std::binary_function<std::string, std::string, bool>
+{
+ bool operator()(std::string const & haystack,
+ std::string const & needle) const
+ {
return contains(haystack, needle);
}
};
#include <utility>
#include <iterator>
#include <algorithm>
-#include <set>
namespace lyx {
template<class C>
void eliminate_duplicates(C & c)
{
- C unique_c;
- std::set<typename C::value_type> s;
-
- for (typename C::iterator p = c.begin(); p != c.end(); ++p) {
- if (s.find(*p) == s.end()) {
- unique_c.push_back(*p);
- s.insert(*p);
- }
- }
- swap(c, unique_c);
+ // It is a requirement that the container is sorted for
+ // std::unique to work properly.
+ std::sort(c.begin(), c.end());
+ c.erase(std::unique(c.begin(), c.end()), c.end());
}
} // namespace lyx
{
ParagraphList::iterator pit = getPar(cur);
if (pit->rows.empty())
- return xo_;
+ return xo_;
Row const & row = *pit->getRow(cur.pos());
pos_type pos = cur.pos();
pos_type cursor_vpos = 0;
CursorBase & cur = text->bv()->cursor().cursor_;
//lyxerr << "findText: text: " << text << " cursor: "
// << text->bv()->cursor() << endl;
- for (int i = cur.size() - 1; i > 0; --i)
+ for (int i = cur.size() - 1; i > 0; --i)
if (cur[i].text() == text)
return i;
if (text->bv()->text() == text)