ControlCredits::getCredits returns a stringstream not a vector<string>.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1815 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-03-23 16:10:15 +00:00
parent b8fd45fd39
commit 5de19b909e
4 changed files with 19 additions and 29 deletions

View 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> 2001-03-23 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* ControlCredits.C (getCredits): remove std:: qualifier for * ControlCredits.C (getCredits): remove std:: qualifier for

View File

@ -9,6 +9,7 @@
#include <config.h> #include <config.h>
#include <fstream> #include <fstream>
#include "Lsstream.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #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"); string const name = FileSearch(system_lyxdir, "CREDITS");
bool found(!name.empty()); 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) { if (found) {
std::ifstream in(name.c_str()); std::ifstream in(name.c_str());
found = (in.get()); found = (in.get());
@ -52,20 +46,16 @@ std::vector<string> const ControlCredits::getCredits() const
if (found) { if (found) {
in.seekg(0, std::ios::beg); // rewind to the beginning in.seekg(0, std::ios::beg); // rewind to the beginning
for(;;) { ss << in.rdbuf();
string line; found = (ss.good());
getline(in, line);
if (!in.good()) break;
data.push_back(line);
}
} }
} }
if (!found) { if (!found) {
data.push_back(_("ERROR: LyX wasn't able to read CREDITS file")); ss << _("ERROR: LyX wasn't able to read CREDITS file\n")
data.push_back(_("Please install correctly to estimate the great")); << _("Please install correctly to estimate the great\n")
data.push_back(_("amount of work other people have done for the LyX project.")); << _("amount of work other people have done for the LyX project.");
} }
return data; return ss;
} }

View File

@ -10,8 +10,6 @@
#ifndef CONTROLCREDITS_H #ifndef CONTROLCREDITS_H
#define CONTROLCREDITS_H #define CONTROLCREDITS_H
#include <vector>
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -26,7 +24,7 @@ public:
ControlCredits(LyXView &, Dialogs &); ControlCredits(LyXView &, Dialogs &);
/// ///
std::vector<string> const getCredits() const; std::stringstream & getCredits(std::stringstream &) const;
private: private:
/// not needed. /// not needed.

View File

@ -18,8 +18,9 @@
#include "FormCredits.h" #include "FormCredits.h"
#include "form_credits.h" #include "form_credits.h"
#include "xforms_helpers.h" #include "xforms_helpers.h"
#include "Lsstream.h"
using std::vector; using std::getline;
typedef FormCB<ControlCredits, FormDB<FD_form_credits> > base_class; typedef FormCB<ControlCredits, FormDB<FD_form_credits> > base_class;
@ -36,11 +37,7 @@ void FormCredits::build()
bc().setCancel(dialog_->button_cancel); bc().setCancel(dialog_->button_cancel);
bc().refresh(); bc().refresh();
vector<string> data = controller().getCredits(); std::stringstream ss;
fl_add_browser_line(dialog_->browser_credits,
/* read the credits into the browser */ controller().getCredits(ss).str().c_str());
for (vector<string>::const_iterator it = data.begin();
it < data.end(); ++it) {
fl_add_browser_line(dialog_->browser_credits, it->c_str());
}
} }