(file) Return to Base64.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Base64.cpp between version 1.25 and 1.26

version 1.25, 2006/01/30 16:16:46 version 1.26, 2006/11/07 21:30:36
Line 29 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org)  
 //  
 // Modified By: David Dillard, VERITAS Software Corp.  
 //                  (david.dillard@veritas.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "Base64.h" #include "Base64.h"
Line 50 
Line 45 
 //********************************************************** //**********************************************************
 /*  Encode thanslates one six-bit pattern into a base-64 character. /*  Encode thanslates one six-bit pattern into a base-64 character.
     Unsigned char is used to represent a six-bit stream of date.     Unsigned char is used to represent a six-bit stream of date.
   
 */ */
 inline PEGASUS_COMMON_LINKAGE char Base64::_Encode(Uint8 uc) inline PEGASUS_COMMON_LINKAGE char Base64::_Encode(Uint8 uc)
 { {
Line 69 
Line 63 
     return '/';     return '/';
 }; };
  
  //Helper function returns true is a character is a valid base-64 character and false otherwise.  // Helper function returns true is a character is a valid base-64 character
   // and false otherwise.
  
 inline Boolean Base64::_IsBase64(char c) inline Boolean Base64::_IsBase64(char c)
 { {
Line 129 
Line 124 
     // for every character in the input array taken 3 bytes at a time     // for every character in the input array taken 3 bytes at a time
     for (Uint32 i=0; i < vby.size(); i+=3)     for (Uint32 i=0; i < vby.size(); i+=3)
     {     {
   
         // Create from 3 8 bit values to 4 6 bit values         // Create from 3 8 bit values to 4 6 bit values
         Uint8 by1=0,by2=0,by3=0;         Uint8 by1=0,by2=0,by3=0;
         by1 = vby[i];         by1 = vby[i];
Line 174 
Line 168 
  
     return retArray;     return retArray;
 }; };
 /*I checked for the zero length. The algorithm would also work for zero length input stream, but I’m pretty adamant about handling border conditions. They are often the culprits of run-time production failures.  
 The algorithm goes thru each three bytes of data at a time. The first thing I do is to shift the bits around from three 8-bit values to four 6-bit values. Then I encode the 6-bit values and add then one at a time to the output stream. This is actually quite inefficient. The STL character array is being allocated one byte at a time. The algorithm would be much faster, if I pre-allocated that array. I’ll leave that as an optimization practical exercise for the reader.  /*
       I checked for the zero length. The algorithm would also work for zero
       length input stream, but I’m pretty adamant about handling border
       conditions. They are often the culprits of run-time production failures.
       The algorithm goes thru each three bytes of data at a time. The first
       thing I do is to shift the bits around from three 8-bit values to four
       6-bit values. Then I encode the 6-bit values and add then one at a time
       to the output stream. This is actually quite inefficient. The STL
       character array is being allocated one byte at a time. The algorithm
       would be much faster, if I pre-allocated that array. I’ll leave that as
       an optimization practical exercise for the reader.
 */ */
  
 /*  The decode static method takes a base-64 stream and converts it /*  The decode static method takes a base-64 stream and converts it


Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2