Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost Spirit Karma - convert character to hex representation
From: Ernest Zaslavsky (ernest.zaslavsky_at_[hidden])
Date: 2015-04-20 08:28:34


std::islower/isupper uses the locale but debugging into it I didn’t see the dreaded facet lazy initialization, so lets consider there is no issue until proven otherwise
Huge thanks, Hartmut!


-----Original Message-----
From: Boost-users [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Hartmut Kaiser
Sent: Monday, April 20, 2015 2:57 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Boost Spirit Karma - convert character to hex representation


> Padding looks like what the doctor ordered. However I'm concerned with
> upper/lower directives. What is needed in hex is a simple mapping for
> 6 letters from a..z to A..Z and vice versa. Upper/lower, I guess, will
> employ std::locale to work properly which in turn uses std::facet
> which (at least in Windows) has lazy initialization and protected by
> CriticalSection. This is a performance killer, I've just spent two
> weeks getting rid of these from my code. Now tell me that I'm wrong
> and these directives do not use std::locale and I will be happy for
> the rest of my life :)

The implementation of upper/lower depends on the used character set. By default those simply map to std::isupper()/std::islower() (see https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/support/char_encoding/ascii.hpp#L281).

Looks like you can be happy 'till the end of your life!

> Otherwise I would like to know if there is another possibility to
> control hex letter case

There is always the possibility for you to write your own generator (which is not too difficult). See here for some explanation: http://boost-spirit.com/home/articles/karma-examples/creating-your-own-generator-component-for-spirit-karma/.

HTH
Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu

>
> -----Original Message-----
> From: Boost-users [mailto:boost-users-bounces_at_[hidden]] On
> Behalf Of Hartmut Kaiser
> Sent: Sunday, April 19, 2015 4:23 PM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] Boost Spirit Karma - convert character to
> hex representation
>
>
> > There is karma::hex formatter and I need somehow to add zero padding
> > to get “0a” instead of just “a”. in addition it would be lovely to
> > have some king of control over hex letter case. It sounds like a
> > policies for real or Boolean formatters but I didn’t find one for hex.
> > Is it possible to achieve the above without policy?
>
> Padding can be achieved by using the right_align[] directive:
> http://www.boost.org/doc/libs/1_58_0/libs/spirit/doc/html/spirit/karma
> /ref
> erence/directive/alignment.html.
>
> You can control the hex-letter case using the upper[] and lower[]
> directives:
> http://www.boost.org/doc/libs/1_58_0/libs/spirit/doc/html/spirit/karma
> /ref
> erence/directive/upperlower.html.
>
> HTH
> Regards Hartmut
> ---------------
> http://boost-spirit.com
> http://stellar.cct.lsu.edu
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
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