[antlr-interest] Translating from Java to C++
Ric Klaren
klaren at cs.utwente.nl
Tue Jul 13 03:17:45 PDT 2004
On Tue, Jul 13, 2004 at 10:19:14AM +0100, Anthony Youngman wrote:
> It doesn't help that I'm using this to learn C++ ... :-) (although I am
> a good C programmer).
Best advice try to forget C for starters ;)
> g++ doesn't like the $getText.toUpperCase() stuff. I've found toupper()
> but it appears to actually change its argument - which I don't want to
> do. How do I do that? And are there any decent websites discussing the
> standard libraries? I've got the Stroustrup C++ book :-)
#include <algorithm>
std::string s("input123");
std::transform(s.begin(), s.end(), s.begin(),
static_cast<int(*)(int)>(std::toupper) );
You might have to make copy of the $getText first since its actually a call
to somestring.substr(..). Not 100% sure though.
Depending on your standard library you might have to loose the std
namespace on the toupper.
For STL reference I use the stroustrup book and the sgi website:
http://www.sgi.com/tech/stl/
The stroustrup book is often a bit too sparse in giving the exact thing a
certain method does. The STL site is usually a bit more informing.
I can really recommend getting the Effective C++ books from Scott Meyers
they discuss a lot of common pitfalls (and give a lot of solutions).
There's also a CD version that has the whole contents of the books in
searchable form.
For streams/locale handling and also some string stuff I can recommend the
Standard C++ IOStreams and Locales book from Langer and Kreft. (very good
reference but also a lot of how to + tradeoffs in the solutions)
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755 ----
-----+++++*****************************************************+++++++++-------
Human beings, who are almost unique in having the ability to learn
from the experience of others, are also remarkable for their apparent
disinclination to do so. --- Douglas Adams, Last Chance to See
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list