]> git.lyx.org Git - features.git/commitdiff
ControlCredits::getCredits returns a stringstream not a vector<string>.
authorAngus Leeming <leeming@lyx.org>
Fri, 23 Mar 2001 16:10:15 +0000 (16:10 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 23 Mar 2001 16:10:15 +0000 (16:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1815 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlCredits.C
src/frontends/controllers/ControlCredits.h
src/frontends/xforms/FormCredits.C

index 0e4d7f4bcdb897580351a6d4cf9b45b8a311b248..118fabaa348b0d2d6281d5be1f871d423f7f9f4e 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-23  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ControlCredits.[Ch] (getCredits): returns a stringstream not a
+       vector<string>.
+
 2001-03-23  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * ControlCredits.C (getCredits): remove std:: qualifier for
index 35f2c5bc33b5f9ae36f1ece7de8fc493fdf60b74..04375af8fd2599419286046b29055ae128843687 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <config.h>
 #include <fstream>
+#include "Lsstream.h"
 
 #ifdef __GNUG__
 #pragma implementation
@@ -32,19 +33,12 @@ ControlCredits::ControlCredits(LyXView & lv, Dialogs & d)
 }
 
 
-std::vector<string> const ControlCredits::getCredits() const
+std::stringstream & ControlCredits::getCredits(std::stringstream & ss) const
 {
-       std::vector<string> data;
-
        string const name = FileSearch(system_lyxdir, "CREDITS");
 
        bool found(!name.empty());
 
-#warning what are you really doing here... (Lgb)
-       // why not just send a stringstream to the calling func?
-       // then the reader would look like:
-       // stringstream ss;
-       // ss << in.rdbuf();
        if (found) {
                std::ifstream in(name.c_str());
                found = (in.get());
@@ -52,20 +46,16 @@ std::vector<string> const ControlCredits::getCredits() const
                if (found) {
                        in.seekg(0, std::ios::beg); // rewind to the beginning
 
-                       for(;;) {
-                               string line;
-                               getline(in, line);
-                               if (!in.good()) break;
-                               data.push_back(line);
-                       }
+                       ss << in.rdbuf();
+                       found = (ss.good());
                }
        }
 
        if (!found) {
-               data.push_back(_("ERROR: LyX wasn't able to read CREDITS file"));
-               data.push_back(_("Please install correctly to estimate the great"));
-               data.push_back(_("amount of work other people have done for the LyX project."));
+               ss << _("ERROR: LyX wasn't able to read CREDITS file\n")
+                  << _("Please install correctly to estimate the great\n")
+                  << _("amount of work other people have done for the LyX project.");
        }
 
-       return data;
+       return ss;
 }
index 193d3b0aa4cbd1d5d25648246c72eab170ef7801..e7e73f431d43b9d9ec64ff27e3be290b8b82c117 100644 (file)
@@ -10,8 +10,6 @@
 #ifndef CONTROLCREDITS_H
 #define CONTROLCREDITS_H
 
-#include <vector>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
@@ -26,7 +24,7 @@ public:
        ControlCredits(LyXView &, Dialogs &);
 
        ///
-       std::vector<string> const getCredits() const;
+       std::stringstream & getCredits(std::stringstream &) const;
 
 private:
        /// not needed.
index 0a0aed3c00daa382711d680a144fab6190f0bd49..09ff4c597c5786edd8ca2ec24915d7b0469740f9 100644 (file)
@@ -18,8 +18,9 @@
 #include "FormCredits.h"
 #include "form_credits.h"
 #include "xforms_helpers.h"
+#include "Lsstream.h"
 
-using std::vector;
+using std::getline;
 
 typedef FormCB<ControlCredits, FormDB<FD_form_credits> > base_class;
 
@@ -36,11 +37,7 @@ void FormCredits::build()
        bc().setCancel(dialog_->button_cancel);
        bc().refresh();
 
-       vector<string> data = controller().getCredits();
-
-       /* read the credits into the browser */ 
-       for (vector<string>::const_iterator it = data.begin();
-            it < data.end(); ++it) {
-               fl_add_browser_line(dialog_->browser_credits, it->c_str());
-       }
+       std::stringstream ss;
+       fl_add_browser_line(dialog_->browser_credits, 
+                           controller().getCredits(ss).str().c_str());
 }