web/lib/Zend/Measure/Binary.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category  Zend
       
    16  * @package   Zend_Measure
       
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    18  * @license   http://framework.zend.com/license/new-bsd     New BSD License
       
    19  * @version   $Id: Binary.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    20  */
       
    21 
       
    22 /**
       
    23  * Implement needed classes
       
    24  */
       
    25 require_once 'Zend/Measure/Abstract.php';
       
    26 require_once 'Zend/Locale.php';
       
    27 
       
    28 /**
       
    29  * Class for handling binary conversions
       
    30  *
       
    31  * @category   Zend
       
    32  * @package    Zend_Measure
       
    33  * @subpackage Zend_Measure_Binary
       
    34  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    36  */
       
    37 class Zend_Measure_Binary extends Zend_Measure_Abstract
       
    38 {
       
    39     const STANDARD = 'BYTE';
       
    40 
       
    41     const BIT               = 'BIT';
       
    42     const CRUMB             = 'CRUMB';
       
    43     const NIBBLE            = 'NIBBLE';
       
    44     const BYTE              = 'BYTE';
       
    45     const KILOBYTE          = 'KILOBYTE';
       
    46     const KIBIBYTE          = 'KIBIBYTE';
       
    47     const KILO_BINARY_BYTE  = 'KILO_BINARY_BYTE';
       
    48     const KILOBYTE_SI       = 'KILOBYTE_SI';
       
    49     const MEGABYTE          = 'MEGABYTE';
       
    50     const MEBIBYTE          = 'MEBIBYTE';
       
    51     const MEGA_BINARY_BYTE  = 'MEGA_BINARY_BYTE';
       
    52     const MEGABYTE_SI       = 'MEGABYTE_SI';
       
    53     const GIGABYTE          = 'GIGABYTE';
       
    54     const GIBIBYTE          = 'GIBIBYTE';
       
    55     const GIGA_BINARY_BYTE  = 'GIGA_BINARY_BYTE';
       
    56     const GIGABYTE_SI       = 'GIGABYTE_SI';
       
    57     const TERABYTE          = 'TERABYTE';
       
    58     const TEBIBYTE          = 'TEBIBYTE';
       
    59     const TERA_BINARY_BYTE  = 'TERA_BINARY_BYTE';
       
    60     const TERABYTE_SI       = 'TERABYTE_SI';
       
    61     const PETABYTE          = 'PETABYTE';
       
    62     const PEBIBYTE          = 'PEBIBYTE';
       
    63     const PETA_BINARY_BYTE  = 'PETA_BINARY_BYTE';
       
    64     const PETABYTE_SI       = 'PETABYTE_SI';
       
    65     const EXABYTE           = 'EXABYTE';
       
    66     const EXBIBYTE          = 'EXBIBYTE';
       
    67     const EXA_BINARY_BYTE   = 'EXA_BINARY_BYTE';
       
    68     const EXABYTE_SI        = 'EXABYTE_SI';
       
    69     const ZETTABYTE         = 'ZETTABYTE';
       
    70     const ZEBIBYTE          = 'ZEBIBYTE';
       
    71     const ZETTA_BINARY_BYTE = 'ZETTA_BINARY_BYTE';
       
    72     const ZETTABYTE_SI      = 'ZETTABYTE_SI';
       
    73     const YOTTABYTE         = 'YOTTABYTE';
       
    74     const YOBIBYTE          = 'YOBIBYTE';
       
    75     const YOTTA_BINARY_BYTE = 'YOTTA_BINARY_BYTE';
       
    76     const YOTTABYTE_SI      = 'YOTTABYTE_SI';
       
    77 
       
    78     /**
       
    79      * Calculations for all binary units
       
    80      *
       
    81      * @var array
       
    82      */
       
    83     protected $_units = array(
       
    84         'BIT'              => array('0.125',                     'b'),
       
    85         'CRUMB'            => array('0.25',                      'crumb'),
       
    86         'NIBBLE'           => array('0.5',                       'nibble'),
       
    87         'BYTE'             => array('1',                         'B'),
       
    88         'KILOBYTE'         => array('1024',                      'kB'),
       
    89         'KIBIBYTE'         => array('1024',                      'KiB'),
       
    90         'KILO_BINARY_BYTE' => array('1024',                      'KiB'),
       
    91         'KILOBYTE_SI'      => array('1000',                      'kB.'),
       
    92         'MEGABYTE'         => array('1048576',                   'MB'),
       
    93         'MEBIBYTE'         => array('1048576',                   'MiB'),
       
    94         'MEGA_BINARY_BYTE' => array('1048576',                   'MiB'),
       
    95         'MEGABYTE_SI'      => array('1000000',                   'MB.'),
       
    96         'GIGABYTE'         => array('1073741824',                'GB'),
       
    97         'GIBIBYTE'         => array('1073741824',                'GiB'),
       
    98         'GIGA_BINARY_BYTE' => array('1073741824',                'GiB'),
       
    99         'GIGABYTE_SI'      => array('1000000000',                'GB.'),
       
   100         'TERABYTE'         => array('1099511627776',             'TB'),
       
   101         'TEBIBYTE'         => array('1099511627776',             'TiB'),
       
   102         'TERA_BINARY_BYTE' => array('1099511627776',             'TiB'),
       
   103         'TERABYTE_SI'      => array('1000000000000',             'TB.'),
       
   104         'PETABYTE'         => array('1125899906842624',          'PB'),
       
   105         'PEBIBYTE'         => array('1125899906842624',          'PiB'),
       
   106         'PETA_BINARY_BYTE' => array('1125899906842624',          'PiB'),
       
   107         'PETABYTE_SI'      => array('1000000000000000',          'PB.'),
       
   108         'EXABYTE'          => array('1152921504606846976',       'EB'),
       
   109         'EXBIBYTE'         => array('1152921504606846976',       'EiB'),
       
   110         'EXA_BINARY_BYTE'  => array('1152921504606846976',       'EiB'),
       
   111         'EXABYTE_SI'       => array('1000000000000000000',       'EB.'),
       
   112         'ZETTABYTE'        => array('1180591620717411303424',    'ZB'),
       
   113         'ZEBIBYTE'         => array('1180591620717411303424',    'ZiB'),
       
   114         'ZETTA_BINARY_BYTE'=> array('1180591620717411303424',    'ZiB'),
       
   115         'ZETTABYTE_SI'     => array('1000000000000000000000',    'ZB.'),
       
   116         'YOTTABYTE'        => array('1208925819614629174706176', 'YB'),
       
   117         'YOBIBYTE'         => array('1208925819614629174706176', 'YiB'),
       
   118         'YOTTA_BINARY_BYTE'=> array('1208925819614629174706176', 'YiB'),
       
   119         'YOTTABYTE_SI'     => array('1000000000000000000000000', 'YB.'),
       
   120         'STANDARD'         => 'BYTE'
       
   121     );
       
   122 }