25 Localization library [localization]

25.4 Standard locale categories [locale.categories]

25.4.7 The message retrieval category [category.messages]

Class messages<charT> implements retrieval of strings from message catalogs.

25.4.7.1 Class template messages [locale.messages]

namespace std {
  class messages_base {
  public:
    using catalog = unspecified signed integer type;
  };

  template <class charT>
    class messages : public locale::facet, public messages_base {
    public:
      using char_type   = charT;
      using string_type = basic_string<charT>;

      explicit messages(size_t refs = 0);

      catalog open(const basic_string<char>& fn, const locale&) 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:
      ~messages();
      virtual catalog do_open(const basic_string<char>&, const locale&) const;
      virtual string_type do_get(catalog, int set, int msgid,
                                 const string_type& dfault) const;
      virtual void do_close(catalog) const;
    };
}

Values of type messages_­base​::​catalog usable as arguments to members get and close can be obtained only by calling member open.

25.4.7.1.1 messages members [locale.messages.members]

catalog open(const basic_string<char>& name, const locale& loc) const;

Returns: do_­open(name, loc).

string_type get(catalog cat, int set, int msgid, const string_type& dfault) const;

Returns: do_­get(cat, set, msgid, dfault).

void close(catalog cat) const;

Effects: Calls do_­close(cat).

25.4.7.1.2 messages virtual functions [locale.messages.virtuals]

catalog do_open(const basic_string<char>& name, const locale& loc) const;

Returns: A value that may be passed to get() to retrieve a message from the message catalog identified by the string name according to an implementation-defined mapping. The result can be used until it is passed to close().

Returns a value less than 0 if no such catalog can be opened.

Remarks: The locale argument loc is used for character set code conversion when retrieving messages, if needed.

string_type do_get(catalog cat, int set, int msgid, const string_type& dfault) const;

Requires: cat shall be a catalog obtained from open() and not yet closed.

Returns: A message identified by arguments set, msgid, and dfault, according to an implementation-defined mapping. If no such message can be found, returns dfault.

void do_close(catalog cat) const;

Requires: cat shall be a catalog obtained from open() and not yet closed.

Effects: Releases unspecified resources associated with cat.

Remarks: The limit on such resources, if any, is implementation-defined.

25.4.7.2 Class template messages_­byname [locale.messages.byname]

namespace std {
  template <class charT>
    class messages_byname : public messages<charT> {
    public:
      using catalog     = messages_base::catalog;
      using string_type = basic_string<charT>;

      explicit messages_byname(const char*, size_t refs = 0);
      explicit messages_byname(const string&, size_t refs = 0);

    protected:
      ~messages_byname();
    };
}