Right, so here is the patch that adds begin() and end() methods
instead of returning (a copy of...) the buffer vector.

g

On 10/6/06, Abdelrazak Younes <[EMAIL PROTECTED]> wrote:
Guillaume Pothier wrote:
>> Dunno haven't see it, you forgot the attachment ;-)
>
> ha! that's one of my favorites!
> Here is the attachment corresponding to my first mail.

Got it but next time, if the patch is not very big please don't compress
it. It's easier for review.

Index: src/bufferlist.C
===================================================================
--- src/bufferlist.C    (revision 15262)
+++ src/bufferlist.C    (working copy)
@@ -222,6 +222,10 @@
        return nvec;
  }

+vector<Buffer *> const BufferList::getBuffers() const
+{
+       return bstore;
+}

  Buffer * BufferList::first()
  {
Index: src/bufferlist.h
===================================================================
--- src/bufferlist.h    (revision 15262)
+++ src/bufferlist.h    (working copy)
@@ -42,6 +42,9 @@

        /// returns a vector with all the buffers filenames
        std::vector<std::string> const getFileNames() const;
+
+       /// returns a vector with all the buffers
+       std::vector<Buffer *> const getBuffers() const;



Be careful here because you are returning a copy of the inner vector.
Should have been:

+       std::vector<Buffer *> const & getBuffers() const;


Abdel.


Index: src/bufferlist.C
===================================================================
--- src/bufferlist.C    (revision 15262)
+++ src/bufferlist.C    (working copy)
@@ -223,6 +223,27 @@
 }
 
 
+BufferList::iterator BufferList::begin()
+{
+       return bstore.begin(); 
+}
+
+BufferList::const_iterator BufferList::begin() const
+{
+       return bstore.begin();
+}
+
+BufferList::iterator BufferList::end()
+{
+       return bstore.end();
+}
+
+BufferList::const_iterator BufferList::end() const
+{
+       return bstore.end();
+}
+
+
 Buffer * BufferList::first()
 {
        if (bstore.empty())
Index: src/bufferlist.h
===================================================================
--- src/bufferlist.h    (revision 15262)
+++ src/bufferlist.h    (working copy)
@@ -42,7 +42,7 @@
 
        /// returns a vector with all the buffers filenames
        std::vector<std::string> const getFileNames() const;
-
+       
        /// FIXME
        void updateIncludedTeXfiles(std::string const &, OutputParams const &);
 
@@ -85,7 +85,22 @@
 
        /// reset current author for all buffers
        void setCurrentAuthor(std::string const & name, std::string const & 
email);
+       
+       typedef std::vector<Buffer *>::iterator iterator;
+       typedef std::vector<Buffer *>::const_iterator const_iterator;
+       
+       /// Returns an iterator that points to the beginning of the buffers list
+       iterator begin();
+       
+       /// Returns a const iterator that points to the beginning of the 
buffers list
+       const_iterator begin() const;
 
+       /// Returns an iterator that points to the end of the buffers list
+       iterator end();
+       
+       /// Returns a const iterator that points to the end of the buffers list
+       const_iterator end() const;
+
 private:
        /// ask to save a buffer on quit, returns false if should cancel
        bool quitWriteBuffer(Buffer * buf);

Reply via email to