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>
* ControlCredits.C (getCredits): remove std:: qualifier for

View 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;
}

View 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.

View 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());
}