Mailinglist Archive: zypp-devel (68 mails)
| < Previous | Next > |
[zypp-devel] Use typedefs - looking up the concrete type is the compilers job....
- From: Michael Andres <ma@xxxxxxx>
- Date: Fri, 4 May 2007 15:46:24 +0200
- Message-id: <20070504134624.GA28596@xxxxxxx>
Example:
ByteCount size(str::strtonum<long long>(reader_r->getAttribute("installed").asString()), Unit());
_package->size = size;
1)
Class ByteCount typedefs the SizeType. So do not convert to a long
long, assuming this is 'big' enough. Use the appropriate type:
str::strtonum<ByteCount::SizeType>( .... )
This should be always right. Looking up the concrete type is the
compilers job.
(If a typedef is missing, ask for it or simply introduce it)
_package->size = str::strtonum<ByteCount::SizeType>(
reader_r->getAttribute("installed").asString() );
2)
ByteCount's default unit is byte. So you can simply write
ByteCount size( str::strtonum<ByteCount::SizeType>( ... ) );
If you want to state the unit explicitly, use the unit constants
ByteCount defines for that purpose: B K M G T kB MB GB TB.
ByteCount size( ...., ByteCount::B );
ByteCount::K.factor() == 1024
ByteCount::kB.factor() == 1000
--
cu,
Michael Andres
+------------------------------------------------------------------+
Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4
+------------------------------------------------------------------+
Michael Andres YaST Development ma@xxxxxxxxxx
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0
+------------------------------------------------------------------+
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
| < Previous | Next > |