2 * This file Copyright (C) Mnemosyne LLC
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
8 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10 * $Id: formatter.h 11092 2010-08-01 20:36:13Z charles $
16 #include <inttypes.h> /* uint64_t */
24 class Formatter
: public QObject
31 virtual ~Formatter( ) { }
35 static QString
memToString( uint64_t bytes
);
36 static QString
sizeToString( uint64_t bytes
);
37 static QString
speedToString( const Speed
& speed
);
38 static QString
percentToString( double x
);
39 static QString
ratioToString( double ratio
);
40 static QString
timeToString( int seconds
);
44 typedef enum { B
, KB
, MB
, GB
, TB
} Size
;
45 typedef enum { SPEED
, SIZE
, MEM
} Type
;
46 static QString
unitStr( Type t
, Size s
) { return unitStrings
[t
][s
]; }
47 static void initUnits( );
51 static QString unitStrings
[3][5];