From 5de19b909e9bbbbb2bee2378ef726076c6bbe5f9 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 23 Mar 2001 16:10:15 +0000 Subject: [PATCH] ControlCredits::getCredits returns a stringstream not a vector. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1815 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 5 +++++ src/frontends/controllers/ControlCredits.C | 26 +++++++--------------- src/frontends/controllers/ControlCredits.h | 4 +--- src/frontends/xforms/FormCredits.C | 13 +++++------ 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 0e4d7f4bcd..118fabaa34 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2001-03-23 Angus Leeming + + * ControlCredits.[Ch] (getCredits): returns a stringstream not a + vector. + 2001-03-23 Jean-Marc Lasgouttes * ControlCredits.C (getCredits): remove std:: qualifier for diff --git a/src/frontends/controllers/ControlCredits.C b/src/frontends/controllers/ControlCredits.C index 35f2c5bc33..04375af8fd 100644 --- a/src/frontends/controllers/ControlCredits.C +++ b/src/frontends/controllers/ControlCredits.C @@ -9,6 +9,7 @@ #include #include +#include "Lsstream.h" #ifdef __GNUG__ #pragma implementation @@ -32,19 +33,12 @@ ControlCredits::ControlCredits(LyXView & lv, Dialogs & d) } -std::vector const ControlCredits::getCredits() const +std::stringstream & ControlCredits::getCredits(std::stringstream & ss) const { - std::vector 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 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; } diff --git a/src/frontends/controllers/ControlCredits.h b/src/frontends/controllers/ControlCredits.h index 193d3b0aa4..e7e73f431d 100644 --- a/src/frontends/controllers/ControlCredits.h +++ b/src/frontends/controllers/ControlCredits.h @@ -10,8 +10,6 @@ #ifndef CONTROLCREDITS_H #define CONTROLCREDITS_H -#include - #ifdef __GNUG__ #pragma interface #endif @@ -26,7 +24,7 @@ public: ControlCredits(LyXView &, Dialogs &); /// - std::vector const getCredits() const; + std::stringstream & getCredits(std::stringstream &) const; private: /// not needed. diff --git a/src/frontends/xforms/FormCredits.C b/src/frontends/xforms/FormCredits.C index 0a0aed3c00..09ff4c597c 100644 --- a/src/frontends/xforms/FormCredits.C +++ b/src/frontends/xforms/FormCredits.C @@ -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 > base_class; @@ -36,11 +37,7 @@ void FormCredits::build() bc().setCancel(dialog_->button_cancel); bc().refresh(); - vector data = controller().getCredits(); - - /* read the credits into the browser */ - for (vector::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()); } -- 2.39.5