Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ STL
Did anyone of you ever use the messages facet of the STL and can help me?
 
I Really don't know how to use this facet expediently. And it seems to me that no compiler does implement a suitable messages facet.
 
Does anyone know a good tutorial for that?
Posted 3-Apr-12 1:16am
Comments
pwasser at 3-Apr-12 19:18pm
   
What exactly do you mean here - error messages..... Could you explain a little more.
A. Ganzer at 5-Apr-12 1:53am
   
I mean the locale facets of the STL, i.e. facets for string comparison, for numeric output etc. A facet can be got from a locale by the use_facet template function.
 
There is one facet that is for localization of strings (the messages facet, so explained in the documentation). But I have no idea how this works.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The only compiler I've ever tried using message facets for is VC++ and I gave up on the idea when a colleague suggested something a bit simpler. It worked okay but was a bit clunky.
 
However while battering my head against the wall of locales I found a couple of books really helpful. They were:
 
- section D.4, especially section D.4.7 (p.928) of Stroustrup's "The C++ Programming Language Special Edition"
- Virtally all of "Standard C++ IOStreams and Locales" by Angelika Langer and Klaus Kreft.
 
Stroustrup has an example of a message catalogue in section D.4.7 and how to plug it into a std::messages object. Langer and Kreft shows you how to plug the whole shebang into a stream.
 
Incidentally the second reference is a really good (if heavy going) detailed examination of it's subject matter. It's rubbish about message catalogues specifically but it'll tell you about all the supporting machinery. By the end of it you'll know everything about streams and locales but will probably feel like your brain is full. At least mine did. It's also a good reference.
 
Cheers,
 
Ash
  Permalink  
Comments
pwasser at 14-Apr-12 22:57pm
   
Some interesting info here.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Quote from "C++ Standard Library: A Tutorial and Reference, The"
By Nicolai M. Josuttis[
^]
"The messages facet is used to retrieve internationalized messages from a catalog of messages. This facet is intended primarily to provide a service similar to that of the function perror(). This function is used in POSIX systems to print a system error message for an error number stored in the global variable errno. Of course, the service provided by messages is more flexible. Unfortunately, it is not defined very precisely."
Conclusion: You better stop to bother yourself with the question how to use it.
  Permalink  
Comments
Aescleal at 14-Apr-12 14:12pm
   
While your quote from Herr J. is correct, I'm not sure I'd share your conclusion that it's not worth bothering about. It pays to understand how things work before you decide to ditch it. At least play with the example Stroustrup provides to see if it's worth sticking you're neck out for the whole ride!
 
If the questioner hacks through a solution that uses a message catalogue and it turns out that using it with a messages facet is too much like hard work then at least he'll have some personal experience as to why.
 
And he can answer questions like his with more personal experience if I decide to go back to using them and need help. :-)
Sergey Chepurin at 15-Apr-12 1:38am
   
There are many more interesting and useful things in the language you can learn, especially in c++11. But you two can still dig deep into something that even gurus cannot explain what.
Aescleal at 15-Apr-12 3:42am
   
While I take your point to be honest I wouldn't call Herr. J. an iostream guru despite writing a very good book on the standard library.
 
Just out of interest he said at a conference a couple of years ago he was writing a new edition on the C++11 library. I don't know if it's come out yet though.
Sergey Chepurin at 15-Apr-12 4:43am
   
Sorry, if my reply may sound not very polite. Don't take me wrong, i use the word "guru" as a commonly accepted and understood name for a person with deep knowledge on the subject. You may agree or not. I take any language, including programming one, as a tool that can be used either to transfer ideas and knowledge (human language), or to make some useful programs for a living (or for a pleasure). But i am not interested in any theoretical applications or dark corners of the language to explore in spare time. And would never advice something like this to anyone. Best regards.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 200
1 PIEBALDconsult 150
2 BillWoodruff 148
3 Jochen Arndt 135
4 DamithSL 130
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 14 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100