[category.messages]

# 28 Text processing library [[text]](./#text)

## 28.3 Localization library [[localization]](localization#category.messages)

### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#category.messages)

#### 28.3.4.8 The message retrieval category [category.messages]

#### [28.3.4.8.1](#general) General [[category.messages.general]](category.messages.general)

[1](#general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4730)

Class messages<charT> implements retrieval of strings from message catalogs[.](#general-1.sentence-1)

#### [28.3.4.8.2](#locale.messages) Class template messages [[locale.messages]](locale.messages)

#### [28.3.4.8.2.1](#locale.messages.general) General [[locale.messages.general]](locale.messages.general)

[ð](#lib: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 string& 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 string&, const locale&) const; virtual string_type do_get(catalog, int set, int msgid, const string_type& dfault) const; virtual void do_close(catalog) const; };}

[1](#locale.messages.general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4771)

Values of type messages_base​::​catalog usable as arguments to members get and close can be obtained only by calling member open[.](#locale.messages.general-1.sentence-1)

#### [28.3.4.8.2.2](#locale.messages.members) Members [[locale.messages.members]](locale.messages.members)

[ð](#lib:messages,open)

`catalog open(const string& name, const locale& loc) const;
`

[1](#locale.messages.members-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4784)

*Returns*: do_open(name, loc)[.](#locale.messages.members-1.sentence-1)

[ð](#lib:messages,get)

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

[2](#locale.messages.members-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4795)

*Returns*: do_get(cat, set, msgid, dfault)[.](#locale.messages.members-2.sentence-1)

[ð](#lib:messages,close)

`void close(catalog cat) const;
`

[3](#locale.messages.members-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4806)

*Effects*: Calls do_close(cat)[.](#locale.messages.members-3.sentence-1)

#### [28.3.4.8.2.3](#locale.messages.virtuals) Virtual functions [[locale.messages.virtuals]](locale.messages.virtuals)

[ð](#lib:messages,do_open)

`catalog do_open(const string& name, const locale& loc) const;
`

[1](#locale.messages.virtuals-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4819)

*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[.](#locale.messages.virtuals-1.sentence-1)

The result can be used until it is passed to close()[.](#locale.messages.virtuals-1.sentence-2)

[2](#locale.messages.virtuals-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4828)

Returns a value less than 0 if no such catalog can be opened[.](#locale.messages.virtuals-2.sentence-1)

[3](#locale.messages.virtuals-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4831)

*Remarks*: The locale argument loc is used for
character set code conversion when retrieving messages, if needed[.](#locale.messages.virtuals-3.sentence-1)

[ð](#lib:messages,do_get)

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

[4](#locale.messages.virtuals-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4843)

*Preconditions*: cat is a catalog obtained from open() and not yet closed[.](#locale.messages.virtuals-4.sentence-1)

[5](#locale.messages.virtuals-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4847)

*Returns*: A message identified by
arguments set, msgid, and dfault,
according to
an implementation-defined mapping[.](#locale.messages.virtuals-5.sentence-1)

If no such message can be found, returns dfault[.](#locale.messages.virtuals-5.sentence-2)

[ð](#lib:message,do_close)

`void do_close(catalog cat) const;
`

[6](#locale.messages.virtuals-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4862)

*Preconditions*: cat is a catalog obtained from open() and not yet closed[.](#locale.messages.virtuals-6.sentence-1)

[7](#locale.messages.virtuals-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4866)

*Effects*: Releases unspecified resources associated with cat[.](#locale.messages.virtuals-7.sentence-1)

[8](#locale.messages.virtuals-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4870)

*Remarks*: The limit on such resources, if any, isimplementation-defined[.](#locale.messages.virtuals-8.sentence-1)

#### [28.3.4.8.3](#locale.messages.byname) Class template messages_byname [[locale.messages.byname]](locale.messages.byname)

[ð](#lib: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(); };}
