From 5c44cab01c620b102542435c3a6b3c37995f167e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 1 May 2003 12:31:35 +0000 Subject: [PATCH] add more functions to ParagraphList git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6906 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/ParagraphList.C | 34 +++++++++++++++++++++++++++++++++- src/ParagraphList.h | 6 ++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index a16bf32488..a12d7fe667 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2003-05-01 Lars Gullik Bjønnes + * ParagraphList.C (ParagraphList): implement copy constructor + (operator=): implement, base on copy constructor. + (assign): new func + * paragraph.C (erase): return a bool * paragraph_pimpl.C (erasePos): remove function, move contents... diff --git a/src/ParagraphList.C b/src/ParagraphList.C index 4f4b50633b..3a579413e1 100644 --- a/src/ParagraphList.C +++ b/src/ParagraphList.C @@ -86,13 +86,35 @@ bool operator!=(ParagraphList::iterator const & i1, return !(i1 == i2); } - +////////// ////////// The ParagraphList proper +////////// + ParagraphList::ParagraphList() : parlist(0) {} +ParagraphList::ParagraphList(ParagraphList const & pl) + : parlist(0) +{ + // Deep copy. + ParagraphList::iterator it = pl.begin(); + ParagraphList::iterator end = pl.end(); + for (; it != end; ++it) { + push_back(new Paragraph(*it, false)); + } +} + + +ParagraphList & ParagraphList::operator=(ParagraphList const & rhs) +{ + ParagraphList tmp(rhs); + std::swap(parlist, tmp.parlist); + return *this; +} + + ParagraphList::iterator ParagraphList::insert(ParagraphList::iterator it, Paragraph * par) { @@ -136,6 +158,16 @@ ParagraphList::insert(ParagraphList::iterator it, Paragraph * par) } +void ParagraphList::assign(iterator beg, iterator end) +{ + clear(); + for (; beg != end; ++beg) { + push_back(new Paragraph(*beg, false)); + } +} + + + void ParagraphList::clear() { #ifndef NO_NEXT diff --git a/src/ParagraphList.h b/src/ParagraphList.h index f60337eff4..52154c1156 100644 --- a/src/ParagraphList.h +++ b/src/ParagraphList.h @@ -47,8 +47,14 @@ public: /// ParagraphList(); /// + ParagraphList(ParagraphList const &); + /// + ParagraphList & operator=(ParagraphList const &); + /// iterator insert(iterator it, Paragraph * par); /// + void assign(iterator beg, iterator end); + /// void clear(); /// void erase(iterator it); -- 2.39.2