Boost logo

Boost Users :

Subject: Re: [Boost-users] Question about boost::locale translations
From: Bastien Montagne (montagne29_at_[hidden])
Date: 2012-11-06 06:10:20


Thank you very much, Artyom, it's exactly what I was looking for, works
like a charm! :D

Much better than my previous hack (which was simply storing the last
translated messages's std::basic_string in a static array with
"rotating" index).

@Dominique: I'm of course no reference at all here, but I'd say (or
guess) it's returning pointer to the internal representation of the
messages for the current mo file, hence that memory would be freed when
"unloading" that (locale/domain(/encoding?)-dependent) catalog (and
pointer is valid until then)...

On 06/11/2012 11:46, Dominique Devienne wrote:
> On Tue, Nov 6, 2012 at 11:11 AM, Artyom Beilis<artyomtnk_at_[hidden]> wrote:
>> You can use message_format facet directly [...]
>> char const *gettext(char const *input) {
>> try {
>> std::locale l;
>> boost::locale::message_facet<char> const&facet =
>> std::use_facet<boost::locale::message_facet<char> >(l);
>> char const *r = facet.get(my_domain_id,0,input);
>> if(r) return r;
>> return input;
>> } [...]
>> }
> Much better. But who exactly is in charge of the lifetime of the
> returned r pointer? And when does the memory get released exactly (if
> ever)? Just curious. The API doc you linked to doesn't say. Is there a
> higher-level doc that discussed memory management of those translated
> C strings? TIA, --DD
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net