Changeset 48

Show
Ignore:
Timestamp:
02/25/08 07:36:24 (9 months ago)
Author:
flithm
Message:

Remove toHexString

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/scrapple/util/Hex.d

    r45 r48  
    77        Version:        Aug 29 2007: Initial release 
    88            Feb 15 2007: add toHexString 
     9            Feb 25 2007: remove toHexString 
    910 
    1011        Authors:        Moritz Warning 
    11             Mandel 
    1212         
    1313        Handy routines for working in base 16 
     
    252252} 
    253253 
    254 /******************************************************************************* 
    255    
    256   Convert an arbitrary value or array to a hex string. 
    257    
    258   Params:       value =         The value to convert 
    259                 ub =            The return value 
    260  
    261   Example: 
    262   
    263   uint i = 1234; 
    264   toHexString!(true)(i) -> "0x04d2" 
    265   toHexString!(false)(i) -> "0x000004d2" 
    266  
    267   Author:                   Mandel 
    268  
    269 *******************************************************************************/ 
    270  
    271 char[] toHexString(T)(T value, char[] dst = null) 
    272 { 
    273     static if(isDynamicArrayType!(T)) 
    274     { 
    275         if(dst is null) 
    276         { 
    277             dst.length = value.length * T.sizeof * 2; 
    278         } 
    279          
    280         ubyte a, b; 
    281         for(auto i = 0; i < value.length; i++) 
    282         { 
    283             a = b = value[i]; 
    284             dst[i * 2] = DIGITS[a >> 4]; 
    285             dst[i * 2 + 1] = DIGITS[b & 0xF]; 
    286         } 
    287     } 
    288     else 
    289     { 
    290         if(dst is null) 
    291         { 
    292             dst.length = T.sizeof * 2; 
    293         } 
    294          
    295         ubyte a, b; 
    296         for(auto i = 0; i < value.sizeof; i++) 
    297         { 
    298             a = b = (cast(byte *) &value)[i]; 
    299             dst[i * 2] = DIGITS[a >> 4]; 
    300             dst[i * 2 + 1] = DIGITS[b & 0xF]; 
    301         } 
    302     } 
    303     return dst; 
    304 } 
    305  
    306 /*******************************************************************************/ 
    307  
    308254private 
    309255{