+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
#include <config.h>
#include <fstream>
+#include "Lsstream.h"
#ifdef __GNUG__
#pragma implementation
}
-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());
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;
}
#ifndef CONTROLCREDITS_H
#define CONTROLCREDITS_H
-#include <vector>
-
#ifdef __GNUG__
#pragma interface
#endif
ControlCredits(LyXView &, Dialogs &);
///
- std::vector<string> const getCredits() const;
+ std::stringstream & getCredits(std::stringstream &) const;
private:
/// not needed.
#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;
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());
}