opennurbs_base32.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #if !defined(ON_BASE32_INC_)
00018 #define ON_BASE32_INC_
00019 
00020 
00021 /*
00022 Description:
00023   Convert a number into base32 digits.
00024 Parameters:
00025   x - [in]
00026   x_count - [in]
00027     x[] is an array of length x_count and represents the value
00028     x[0]*2^(8*(x_count-1)) + ... + x[x_count-2]*256 + x[x_count-1].
00029   base32_digits - [out]
00030     When base32_digits is not a dynamic array, base32_digits[] 
00031     must a be an array of length at least
00032     ((8*x_count)/5) + (((8*x_count)%5)?1:0) or 1, 
00033     whichever is greater.
00034 
00035     The base32_digits[] array will be filled in with base32 digit 
00036     values (0 to 31) so that the value
00037     b[0]*32^(b_count-1) + ... + b[b_count-2]*32 + b[b_count-1]
00038     is the same as that defined by the x[] array.
00039 Returns
00040   The number of base 32 digits in the base32_digits[] array.
00041   If 0 is returned, the input is not valid.
00042 */
00043 ON_DECL
00044 int ON_GetBase32Digits( const ON_SimpleArray<unsigned char>& x, ON_SimpleArray<unsigned char>& base32_digits );
00045 ON_DECL
00046 int ON_GetBase32Digits( const unsigned char* x, int x_count, unsigned char* base32_digits );
00047 
00048 
00049 /*
00050 Description:
00051   Convert a list of base32 digits into a string form.
00052 Parameters:
00053   base32_digits - [in]
00054   base32_digit_count - [in]
00055     base32_digits[] is an array of length base32_digit_count. 
00056     Each element is in the range 0 to 31.
00057   sBase32 - [out]
00058     sBase32[] must be an array of length base32_digit_count+1 or 2,
00059     whichever is greater. The string representation of the base 32
00060     number will be put in this string. A hash mark symbol (#) is
00061     used to indicate an error in the input value.  The returned
00062     string is null terminated.
00063 Returns
00064   True if the input is valid.  False if the input is not valid,
00065   in which case hash marks indicate the invalid entries.
00066 */
00067 ON_DECL
00068 bool ON_Base32ToString( const ON_SimpleArray<unsigned char>& base32_digits, ON_String& sBase32 );
00069 ON_DECL
00070 bool ON_Base32ToString( const ON_SimpleArray<unsigned char>& base32_digits, ON_wString& sBase32 );
00071 ON_DECL
00072 bool ON_Base32ToString( const unsigned char* base32_digits, int base32_digit_count, char* sBase32 );
00073 
00074 
00075 /*
00076 Description:
00077   Fixt a common typos in sBase32 string.  Lower case letters are
00078   converted to upper case. The letters 'I', 'L', 'O' and 'S' are
00079   converted to '1' (one), '1' (one) '0' zero and '5' (five).
00080 Parameters:
00081   sBase32 - [in]
00082   sBase32clean - [out]
00083     (can be the same string as sBase32)
00084 Returns:
00085   If the input is valid, the length of the converted string is returned.
00086   If the input is not valid, 0 is returned.
00087 */
00088 ON_DECL
00089 int ON_CorrectBase32StringTypos( const wchar_t* sBase32, ON_wString& sBase32clean );
00090 ON_DECL
00091 int ON_CorrectBase32StringTypos( const char* sBase32, ON_String& sBase32clean );
00092 ON_DECL
00093 int ON_CorrectBase32StringTypos( const char* sBase32, char* sBase32clean );
00094 
00095 
00096 /*
00097 Description:
00098   Convert a null terminate string containing the 32 symbols 
00099 
00100   0 1 2 3 4 5 6 7 8 9 A B C D E F G H J K M N P Q R T U V W X Y Z
00101 
00102   (I,L,O and S are missing) into a list of base 32 digits.
00103 Parameters:
00104   sBase32 - [in]
00105     String with base 32 digits
00106   base32_digits - [out]
00107     base32_digits[] is an array of length strlen(sBase32). 
00108     The returned array, element will be in the range 0 to 31.
00109     sBase32[] must be an array of length base32_digit_count+1 or 2,
00110     whichever is greater. The string representation of the base 32
00111     number will be put in this string. A hash mark symbol (#) is
00112     used to indicate an error in the input value.  The returned
00113     string is null terminated.
00114 Returns
00115   True if the input is valid.  False if the input is not valid,
00116   in which case hash marks indicate the invalid entries.
00117 */
00118 ON_DECL
00119 int ON_StringToBase32(const ON_wString& sBase32, ON_SimpleArray<unsigned char>& base32_digits );
00120 ON_DECL
00121 int ON_StringToBase32(const ON_String& sBase32, ON_SimpleArray<unsigned char>& base32_digits );
00122 ON_DECL
00123 int ON_StringToBase32(const char* sBase32, unsigned char* base32_digits );
00124 
00125 
00126 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:26:59