The Message Retrieval Category

The messages facet is the least specified facet in the C++ standard. Just about everything having to do with messages is implementation defined.

Listing: Template Class Messages Synopsis
namespace std {
class messages_base

{

public:

   typedef int catalog;

};

template <class charT>

class messages

   : public locale::facet,

      public messages_base

{

public:

   typedef charT char_type;

   typedef basic_string<charT> string_type;

   explicit messages(size_t refs = 0);

   catalog open(const basic_string<char>& fn, 

      const locale& loc) const;

   string_type get(catalog c, int set, int msgid, 

       const string_type& dfault) const;

   void close(catalog c) const;

   static locale::id id;

protected:

   virtual ~messages();

   virtual catalog do_open(const basic_string<char>& fn, 

      const locale& loc) const;

   virtual string_type do_get(catalog c, int set, int msgid,

      const string_type& dfault) const;

   virtual void do_close(catalog c) const;

};

}

The intent is that you can use this class to read messages from a catalog. There may be multiple sets of messages in a catalog. And each message set can have any number of int/string pairs. But beyond that, the standard is quiet.

Does the string fn in open refer to a file? If so, what is the format of the set/msgid/string data to be read in from the file? There is also a messages_byname class that derives from messages. What functionality does messages_byname add over messages?

Unfortunately the answers to all of these questions are implementation defined. This document seeks to answer those questions. Please remember that applications depending on these answers will probably not be portable to other implementations of the standard C++ library.