mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
use std::advance and std::distance instead of home-grown versions
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8372 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1eaa3eb913
commit
7ea6f6e883
@ -1,3 +1,7 @@
|
||||
2004-01-26 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* libs/regex/src/Makefile.am: remove trailing backslash
|
||||
|
||||
2004-01-08 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* add boost::filesystem.
|
||||
|
@ -19,4 +19,4 @@ libboostregex_la_SOURCES = \
|
||||
# posix_api.cpp \
|
||||
# wide_posix_api.cpp \
|
||||
# regex_debug.cpp
|
||||
# winstances.cpp \
|
||||
# winstances.cpp
|
||||
|
@ -27,9 +27,7 @@ src/frontends/controllers/ControlLog.C
|
||||
src/frontends/controllers/ControlPreamble.C
|
||||
src/frontends/controllers/ControlPrefs.C
|
||||
src/frontends/controllers/ControlPrint.C
|
||||
src/frontends/controllers/ControlSearch.C
|
||||
src/frontends/controllers/ControlSpellchecker.C
|
||||
src/frontends/controllers/ControlThesaurus.C
|
||||
src/frontends/controllers/biblio.C
|
||||
src/frontends/controllers/character.C
|
||||
src/frontends/controllers/frnt_lang.C
|
||||
@ -141,7 +139,7 @@ src/frontends/xforms/xformsBC.h
|
||||
src/frontends/xforms/xforms_helpers.C
|
||||
src/gettext.h
|
||||
src/importer.C
|
||||
src/insets/inset.C
|
||||
src/insets/insetbase.C
|
||||
src/insets/insetbibtex.C
|
||||
src/insets/insetbox.C
|
||||
src/insets/insetbranch.C
|
||||
@ -185,6 +183,7 @@ src/mathed/formulabase.C
|
||||
src/mathed/formulamacro.C
|
||||
src/mathed/math_hullinset.C
|
||||
src/mathed/math_macrotemplate.C
|
||||
src/mathed/math_nestinset.C
|
||||
src/mathed/math_parboxinset.C
|
||||
src/mathed/ref_inset.C
|
||||
src/output.C
|
||||
@ -194,6 +193,9 @@ src/output_plaintext.C
|
||||
src/paragraph.C
|
||||
src/paragraph_funcs.C
|
||||
src/rowpainter.C
|
||||
src/support/globbing.C
|
||||
src/support/path_defines.C
|
||||
src/tex2lyx/lengthcommon.C
|
||||
src/text.C
|
||||
src/text2.C
|
||||
src/text3.C
|
||||
|
@ -1,4 +1,11 @@
|
||||
2004-01-26 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* lyxfind.C (replaceAll): use std::advance
|
||||
|
||||
* iterators.h: inherit from std::iterator.
|
||||
|
||||
* PosIterator.C (advance, distance): remove
|
||||
* PosIterator.h: interit from std::iterator.
|
||||
|
||||
2004-01-26 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
@ -102,7 +109,7 @@
|
||||
|
||||
* lyxcursor.[hC]: remove, it's CursorSlice now.
|
||||
|
||||
* Makefile.am:
|
||||
* Makefile.am:
|
||||
* BufferView_pimpl.[Ch]:
|
||||
* bufferview_funcs.C:
|
||||
* cursor_slice.C:
|
||||
@ -122,7 +129,7 @@
|
||||
|
||||
* BufferView_pimpl.C (MenuInsertLyXFile):
|
||||
* lyx_cb.C (WriteAs, getContentsOfAsciiFile):
|
||||
* lyxfunc.C (menuNew, open, doImport):
|
||||
* lyxfunc.C (menuNew, open, doImport):
|
||||
FileFilterList change to the FileDialog open and save functions.
|
||||
|
||||
2004-01-07 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
@ -33,7 +33,7 @@ PosIterator & PosIterator::operator++()
|
||||
BOOST_ASSERT(!stack_.empty());
|
||||
while (true) {
|
||||
PosIteratorItem & p = stack_.back();
|
||||
|
||||
|
||||
if (p.pos < p.pit->size()) {
|
||||
if (InsetBase * inset = p.pit->getInset(p.pos)) {
|
||||
if (LyXText * text = inset->getText(p.index)) {
|
||||
@ -49,10 +49,10 @@ PosIterator & PosIterator::operator++()
|
||||
++p.pit;
|
||||
p.pos = 0;
|
||||
}
|
||||
|
||||
|
||||
if (p.pit != p.pl->end() || stack_.size() == 1)
|
||||
return *this;
|
||||
|
||||
|
||||
stack_.pop_back();
|
||||
}
|
||||
return *this;
|
||||
@ -62,9 +62,9 @@ PosIterator & PosIterator::operator++()
|
||||
PosIterator & PosIterator::operator--()
|
||||
{
|
||||
BOOST_ASSERT(!stack_.empty());
|
||||
|
||||
|
||||
// try to go one position backwards: if on the start of the
|
||||
// ParagraphList, pops an item
|
||||
// ParagraphList, pops an item
|
||||
PosIteratorItem & p = stack_.back();
|
||||
if (p.pos > 0) {
|
||||
--p.pos;
|
||||
@ -105,10 +105,10 @@ bool operator!=(PosIterator const & lhs, PosIterator const & rhs)
|
||||
|
||||
bool operator==(PosIterator const & lhs, PosIterator const & rhs)
|
||||
{
|
||||
|
||||
|
||||
PosIteratorItem const & li = lhs.stack_.back();
|
||||
PosIteratorItem const & ri = rhs.stack_.back();
|
||||
|
||||
|
||||
return (li.pl == ri.pl && li.pit == ri.pit &&
|
||||
(li.pit == li.pl->end() || li.pos == ri.pos));
|
||||
}
|
||||
@ -132,7 +132,7 @@ PosIterator::PosIterator(BufferView & bv)
|
||||
LyXText * text = bv.getLyXText();
|
||||
lyx::pos_type pos = bv.cursor().pos();
|
||||
ParagraphList::iterator pit = text->cursorPar();
|
||||
|
||||
|
||||
ParIterator par = bv.buffer()->par_iterator_begin();
|
||||
ParIterator end = bv.buffer()->par_iterator_end();
|
||||
for ( ; par != end; ++par) {
|
||||
@ -151,21 +151,3 @@ InsetBase * PosIterator::inset() const
|
||||
PosIteratorItem const & pi = stack_[stack_.size() - 2];
|
||||
return pi.pit->getInset(pi.pos);
|
||||
}
|
||||
|
||||
|
||||
int distance(PosIterator const & cur, PosIterator const & end)
|
||||
{
|
||||
int count = 0;
|
||||
for (PosIterator p = cur; p != end; ++p, ++count)
|
||||
;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
void advance(PosIterator & cur, int howmuch)
|
||||
{
|
||||
for (int i = 0; i < howmuch; ++i)
|
||||
++cur;
|
||||
for (int i = 0; i > howmuch; --i)
|
||||
--cur;
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ struct PosIteratorItem {
|
||||
};
|
||||
|
||||
|
||||
class PosIterator {
|
||||
class PosIterator : public std::iterator<
|
||||
std::bidirectional_iterator_tag,
|
||||
ParagraphList::value_type> {
|
||||
public:
|
||||
PosIterator(BufferView & bv);
|
||||
PosIterator(ParIterator & par, lyx::pos_type pos);
|
||||
@ -52,7 +54,7 @@ public:
|
||||
InsetBase * inset() const;
|
||||
friend PosIterator ParIterator::asPosIterator(lyx::pos_type) const;
|
||||
friend ParIterator::ParIterator(PosIterator const &);
|
||||
|
||||
|
||||
private:
|
||||
PosIterator() {};
|
||||
//this is conceptually a stack, but we need random access sometimes
|
||||
@ -63,8 +65,4 @@ private:
|
||||
bool operator!=(PosIterator const &, PosIterator const &);
|
||||
bool operator==(PosIterator const &, PosIterator const &);
|
||||
|
||||
int distance(PosIterator const &, PosIterator const &);
|
||||
void advance(PosIterator &, int);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-01-26 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||
|
||||
* ControlSpellchecker.C (check): use std::distance and
|
||||
std::advance
|
||||
|
||||
2004-01-25 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ControlSearch.[Ch]: derive from Dialog::Controller rather than
|
||||
|
@ -154,7 +154,7 @@ bool isLetter(PosIterator & cur)
|
||||
return !cur.at_end()
|
||||
&& cur.pit()->isLetter(cur.pos())
|
||||
&& !isDeletedText(*cur.pit(), cur.pos())
|
||||
&& (!cur.inset() || cur.inset()->allowSpellCheck());
|
||||
&& (!cur.inset() || cur.inset()->allowSpellCheck());
|
||||
}
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ WordLangTuple nextWord(PosIterator & cur, PosIterator const & end,
|
||||
{
|
||||
// skip until we have real text (will jump paragraphs)
|
||||
for (; cur != end && !isLetter(cur); ++cur, ++progress);
|
||||
|
||||
|
||||
if (cur == end)
|
||||
return WordLangTuple(string(), string());
|
||||
|
||||
@ -195,8 +195,8 @@ void ControlSpellchecker::check()
|
||||
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);
|
||||
int start = std::distance(beg, cur);
|
||||
int const total = start + std::distance(cur, end);
|
||||
|
||||
if (cur != buffer()->pos_iterator_begin())
|
||||
for (; cur != end && isLetter(cur); ++cur, ++start);
|
||||
@ -235,9 +235,9 @@ void ControlSpellchecker::check()
|
||||
|
||||
if (!word_.word().empty()) {
|
||||
int const size = word_.word().size();
|
||||
advance(cur, -size);
|
||||
std::advance(cur, -size);
|
||||
bufferview()->putSelectionAt(cur, size, false);
|
||||
advance(cur, size);
|
||||
std::advance(cur, size);
|
||||
} else {
|
||||
showSummary();
|
||||
endSession();
|
||||
|
@ -25,7 +25,9 @@ class BufferView;
|
||||
class PosIterator;
|
||||
|
||||
|
||||
class ParIterator {
|
||||
class ParIterator : public std::iterator<
|
||||
std::forward_iterator_tag,
|
||||
ParagraphList::value_type> {
|
||||
public:
|
||||
///
|
||||
ParIterator(ParagraphList::iterator pit, ParagraphList const & pl);
|
||||
@ -77,7 +79,9 @@ bool operator==(ParIterator const & iter1, ParIterator const & iter2);
|
||||
bool operator!=(ParIterator const & iter1, ParIterator const & iter2);
|
||||
|
||||
|
||||
class ParConstIterator {
|
||||
class ParConstIterator : public std::iterator<
|
||||
std::forward_iterator_tag,
|
||||
ParagraphList::value_type> {
|
||||
public:
|
||||
///
|
||||
ParConstIterator(ParagraphList::iterator pit, ParagraphList const & pl);
|
||||
|
@ -78,7 +78,7 @@ namespace lyx {
|
||||
namespace find {
|
||||
|
||||
string const find2string(string const & search,
|
||||
bool casesensitive, bool matchword, bool forward)
|
||||
bool casesensitive, bool matchword, bool forward)
|
||||
{
|
||||
ostringstream ss;
|
||||
ss << search << '\n'
|
||||
@ -88,7 +88,7 @@ string const find2string(string const & search,
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
string const replace2string(string const & search, string const & replace,
|
||||
bool casesensitive, bool matchword,
|
||||
@ -155,7 +155,7 @@ void replace(BufferView * bv, FuncRequest const & ev)
|
||||
casesensitive, matchword) :
|
||||
::replace(bv, search, replace,
|
||||
casesensitive, matchword, forward);
|
||||
|
||||
|
||||
if (replace_count == 0) {
|
||||
lv->message(_("String not found!"));
|
||||
} else {
|
||||
@ -180,10 +180,10 @@ bool findNextChange(BufferView * bv)
|
||||
|
||||
if (!findChange(cur, endit))
|
||||
return false;
|
||||
|
||||
|
||||
ParagraphList::iterator pit = cur.pit();
|
||||
pos_type pos = cur.pos();
|
||||
|
||||
|
||||
Change orig_change = pit->lookupChangeFull(pos);
|
||||
pos_type parsize = pit->size();
|
||||
pos_type end = pos;
|
||||
@ -243,7 +243,7 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// search string
|
||||
string str;
|
||||
@ -328,9 +328,9 @@ int replaceAll(BufferView * bv,
|
||||
|
||||
if (!searchAllowed(bv, searchstr) || buf.isReadonly())
|
||||
return 0;
|
||||
|
||||
|
||||
recordUndo(Undo::ATOMIC, bv->text(), 0, buf.paragraphs().size() - 1);
|
||||
|
||||
|
||||
PosIterator cur = buf.pos_iterator_begin();
|
||||
PosIterator const end = buf.pos_iterator_end();
|
||||
MatchString const match(searchstr, cs, mw);
|
||||
@ -345,7 +345,7 @@ int replaceAll(BufferView * bv,
|
||||
= cur.pit()->getFontSettings(buf.params(), pos);
|
||||
int striked = ssize - cur.pit()->erase(pos, pos + ssize);
|
||||
cur.pit()->insert(pos, replacestr, font);
|
||||
advance(cur, rsize + striked);
|
||||
std::advance(cur, rsize + striked);
|
||||
++num;
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ int replaceAll(BufferView * bv,
|
||||
|
||||
|
||||
bool stringSelected(BufferView * bv,
|
||||
string const & searchstr,
|
||||
string const & searchstr,
|
||||
bool cs, bool mw, bool fw)
|
||||
{
|
||||
LyXText * text = bv->getLyXText();
|
||||
@ -395,7 +395,7 @@ int replace(BufferView * bv,
|
||||
bv->buffer()->markDirty();
|
||||
find(bv, searchstr, cs, mw, fw);
|
||||
bv->update();
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user