[locale.messages]

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

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

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

#### 28.3.4.8 The message retrieval category [[category.messages]](category.messages#locale.messages)

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

#### [28.3.4.8.2.1](#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](#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[.](#general-1.sentence-1)

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

[ð](#lib:messages,open)

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

[1](#members-1)

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

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

[ð](#lib:messages,get)

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

[2](#members-2)

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

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

[ð](#lib:messages,close)

`void close(catalog cat) const;
`

[3](#members-3)

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

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

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

[ð](#lib:messages,do_open)

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

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

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

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

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

[ð](#lib:messages,do_get)

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

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

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

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

[ð](#lib:message,do_close)

`void do_close(catalog cat) const;
`

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

[7](#virtuals-7)

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

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

[8](#virtuals-8)

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

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