help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Formatted output with std::basic_ostream


From: Roger Leigh
Subject: Formatted output with std::basic_ostream
Date: Sat, 17 Dec 2005 18:23:43 +0000
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi folks,

In an application I maintain, I use printf along with GNU gettext to
output translated messages.  The format string allows the order of the
parameters in the string to be changed if the tranlation requires it.

I've since rewritten the application in C++, but it's still using
printf() for output.  I would like to switch to iostreams, but I need
to be able to continue to use format strings for translated messages,
because 'ostream<<' does not allow reordering; it's fixed at compile
time.  I can't see anything in e.g. basic_ostream<> that allows this.

Another case is exceptions, where the string is localised and also
takes a parameter.  I could use snprintf and then create a string from
that, but ideally I'd like to output to a std::ostringstream or
std::string directly.  I can't see this supported in the standard.

Are there any GNU extensions that allow this, or could anyone suggest
an alternate solution?


Many thanks,
Roger

- -- 
Roger Leigh
                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFDpFetVcFcaSW/uEgRAkY/AJ9FLAF/yDvfMDjE5bOFlrgnVJISiACeMsd/
aBGbJ1fgzMpDSXrpcbuHlec=
=JcYc
-----END PGP SIGNATURE-----


reply via email to

[Prev in Thread] Current Thread [Next in Thread]