← Back to team overview

widelands-dev team mailing list archive

Re: string formatting - integers + leading blanks

 

Look here: http://studiofreya.com/cpp/a-few-boostformat-examples/


21/11/2014 13:07, sgrìobh Tibor Bamhor:
> no alignment there - I just wanted to add the height there - for editor
> only.
> 
> 2014-11-21 13:56 GMT+01:00 Fòram na Gàidhlig <fios@xxxxxxxxxxxxxxxxxxx
> <mailto:fios@xxxxxxxxxxxxxxxxxxx>>:
> 
>     How do we blit the coordinates on the bottom right? You might find some
>     code to steal there.
> 
> 
> 
>     21/11/2014 11:52, sgrìobh Tibor Bamhor:
>     > I cannot make it work. I tested couple of layouts. It even crashed
>     the game.
>     >
>     > At the end it is not that critical and perhaps once a branch will be
>     > created somebody will be able to change it that way
>     >
>     > Thanks
>     >
>     > 2014-11-21 12:10 GMT+01:00 Fòram na Gàidhlig
>     <fios@xxxxxxxxxxxxxxxxxxx <mailto:fios@xxxxxxxxxxxxxxxxxxx>
>     > <mailto:fios@xxxxxxxxxxxxxxxxxxx <mailto:fios@xxxxxxxxxxxxxxxxxxx>>>:
>     >
>     >     I think the problem might be that boost::format is
>     interpreting the
>     >     numbers as placehloder order. Try
>     >
>     >     static boost::format node_format("(%1$3i, %2$3i; %3%2i)");
>     >
>     >     If this doesn't solve your problem, you might find usage
>     examples if you
>     >     grep the code base for boost::format. Otherwise, google for the
>     >     documentation. I know these can be a bit tricky.
>     >
>     >     Also, we are trying to get rid of "using namespace" statements
>     in the
>     >     long run, so please use "boost::format" rather than just "format".
>     >
>     >
>     >
>     >     21/11/2014 10:25, sgrìobh Tibor Bamhor:
>     >     > I am trying to use something like this:
>     >     >
>     >     > static format node_format("(%3i, %3i; %2i)");
>     >     >
>     >     > but these numbers are ignored. I noticed that similar code
>     like this
>     >     > '%5.1f' works, what should I use to make it work?
>     >     >
>     >     > Also '%03i' works as intended...
>     >     >
>     >     > Tibor
>     >     >
>     >     >
>     >     > _______________________________________________
>     >     > Mailing list: https://launchpad.net/~widelands-dev
>     >     > Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
>     <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>
>     >     <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx
>     <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>>
>     >     > Unsubscribe : https://launchpad.net/~widelands-dev
>     >     > More help   : https://help.launchpad.net/ListHelp
>     >     >
>     >     >
>     >     >
>     >     > No virus found in this message.
>     >     > Checked by AVG - www.avg.com <http://www.avg.com>
>     <http://www.avg.com> <http://www.avg.com>
>     >     > Version: 2015.0.5577 / Virus Database: 4213/8604 - Release Date:
>     >     11/21/14
>     >     >
>     >
>     >     _______________________________________________
>     >     Mailing list: https://launchpad.net/~widelands-dev
>     >     Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
>     <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>
>     >     <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx
>     <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>>
>     >     Unsubscribe : https://launchpad.net/~widelands-dev
>     >     More help   : https://help.launchpad.net/ListHelp
>     >
>     >
>     > No virus found in this message.
>     > Checked by AVG - www.avg.com <http://www.avg.com> <http://www.avg.com>
>     > Version: 2015.0.5577 / Virus Database: 4213/8604 - Release Date:
>     11/21/14
>     >
> 
>     _______________________________________________
>     Mailing list: https://launchpad.net/~widelands-dev
>     Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
>     <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>
>     Unsubscribe : https://launchpad.net/~widelands-dev
>     More help   : https://help.launchpad.net/ListHelp
> 
> 
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 2015.0.5577 / Virus Database: 4213/8604 - Release Date: 11/21/14
> 


Follow ups

References