[Kde-finance-apps] Re: AlkValue <-> QString round trip

Alvaro Soliverez asoliverez at kde.org
Mon Mar 28 11:50:04 CEST 2011


That works, then. Sorry for missing that.

Thanks a lot, Thomas!

Regards,
Alvaro

On Mon, Mar 28, 2011 at 3:44 AM, Thomas Baumgart <thb at net-bembel.de> wrote:
> Hi,
>
> on Monday 28 March 2011 04:20:19 Alvaro Soliverez wrote:
>
>> Hello Thomas,
>> I'm working on a couple of Alkimia of classes used to send quotes
>> value over DBus.
>> For that, the classes have to be marshalled and demarshalled on arrival.
>>
>> Looking at AlkValue, there's not a clear way to do the round-trip.
>> Meaning, I have to convert AlkValue to QString (in that case,
>> toString() should suffice), and the I'd need an equivalent
>> fromString() method.
>>
>> I see there's a constructor, but from the docs, that takes a regular
>> currency string. I'd need one that takes the output of toString and
>> returns a proper AlkValue.
>
> Hmm, the docs clearly state that it takes 'our own toString() format' so that
> should not be a problem at all. The decimal symbol required does not matter in
> this case as none is contained in the toString() output.
>
>> Did I miss it and it's hidden there somewhere?
>
>  AlkValue a(100,1);
>  QString s;
>  s = a.toString();
>  AlkValue b(s, '.');
>
> should do the trick. You could also use the assignment operator as in
>
>  AlkValue a;
>  QString s("1/100");
>
>  a = s;
>
> which does not require the decimal symbol (as it defaults to the dot) but
> might be less efficient.
>
>
>> I know I could parse the string and then call one of the constructors,
>> but I'd rather avoid it if it's possible to have it in AlkValue
>> itself, where it can be properly validated.
>
> Please take a look at the following testcases:
>
> AlkValueTest::equality()
> void AlkValueTest::stringCtor() 2nd and 3rd case
>
>> PS: I expect to have these classes ready for review this week, and
>> I'll send them to you.
>
> Sounds good.
>
> --
>
> Regards
>
> Thomas Baumgart
>
> GPG-FP: E55E D592 F45F 116B 8429   4F99 9C59 DB40 B75D D3BA
> -------------------------------------------------------------
> The shortest words, namely yes and no,
> require the most thoughts. -- Pythagoras of Samos
> -------------------------------------------------------------
>
> _______________________________________________
> Kde-finance-apps mailing list
> Kde-finance-apps at kde.org
> https://mail.kde.org/mailman/listinfo/kde-finance-apps
>
>


More information about the Kde-finance-apps mailing list