Re: much text, one cout<< ?
On Feb 11, 8:06 am, Martin York <Martin.YorkAma...@gmail.com> wrote:
[...]
Personally I would do somthing like this:
1) Put the text in a seprate file:
std::ifstream text(getLocalisedFileName());
std::copy(std::istreambuf_iterator<char>(text),std::istreambuf_iterator<ch=
ar>(),std::ostream_iterator<char>(std::cout));
Whether this is a good idea or not depends on context. It
definitly makes deployment more complicated, because you have to
deliver two files, rather than one. And you have to somehow
ensure that the program can find the second file, which isn't
necessarily trivial. Anytime you can reasonably put everything
into a executable, and just deliver that single file, it's a
definite advantage. (I've seen far too many programs where the
only message you get from help is something along the lines
"Cannot open .../help.txt". Not very helpful, really.)
Of course, it all depends. If you need a number of different
files anyway, one more isn't going to change anything, and it
does make maintaining different versions (e.g. depending on
language) slightly easier. Back in the old days, of course,
when memory was tight, you'd always use separate file, since
that way, it wasn't part of the binary imagine in memory; that
could still be a consideration today if you have very large help
files. (More likely, today, the help command will be a separate
executable, with a name something like /usr/bin/firefox or
C:/Program Files/Mozilla_Firefox/firefox.exe:-). In which case, of
course, you'll definitely keep the help text in a separate file.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34