QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_base32.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2009 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(ON_BASE32_INC_)
17#define ON_BASE32_INC_
18
19
20/*
21Description:
22 Convert a number into base32 digits.
23Parameters:
24 x - [in]
25 x_count - [in]
26 x[] is an array of length x_count and represents the value
27 x[0]*2^(8*(x_count-1)) + ... + x[x_count-2]*256 + x[x_count-1].
28 base32_digits - [out]
29 When base32_digits is not a dynamic array, base32_digits[]
30 must a be an array of length at least
31 ((8*x_count)/5) + (((8*x_count)%5)?1:0) or 1,
32 whichever is greater.
33
34 The base32_digits[] array will be filled in with base32 digit
35 values (0 to 31) so that the value
36 b[0]*32^(b_count-1) + ... + b[b_count-2]*32 + b[b_count-1]
37 is the same as that defined by the x[] array.
38Returns
39 The number of base 32 digits in the base32_digits[] array.
40 If 0 is returned, the input is not valid.
41*/
45int ON_GetBase32Digits( const unsigned char* x, int x_count, unsigned char* base32_digits );
46
47
48/*
49Description:
50 Convert a list of base32 digits into a string form.
51Parameters:
52 base32_digits - [in]
53 base32_digit_count - [in]
54 base32_digits[] is an array of length base32_digit_count.
55 Each element is in the range 0 to 31.
56 sBase32 - [out]
57 sBase32[] must be an array of length base32_digit_count+1 or 2,
58 whichever is greater. The string representation of the base 32
59 number will be put in this string. A hash mark symbol (#) is
60 used to indicate an error in the input value. The returned
61 string is null terminated.
62Returns
63 True if the input is valid. False if the input is not valid,
64 in which case hash marks indicate the invalid entries.
65*/
67bool ON_Base32ToString( const ON_SimpleArray<unsigned char>& base32_digits, ON_String& sBase32 );
69bool ON_Base32ToString( const ON_SimpleArray<unsigned char>& base32_digits, ON_wString& sBase32 );
71bool ON_Base32ToString( const unsigned char* base32_digits, int base32_digit_count, char* sBase32 );
72
73
74/*
75Description:
76 Fixt a common typos in sBase32 string. Lower case letters are
77 converted to upper case. The letters 'I', 'L', 'O' and 'S' are
78 converted to '1' (one), '1' (one) '0' zero and '5' (five).
79Parameters:
80 sBase32 - [in]
81 sBase32clean - [out]
82 (can be the same string as sBase32)
83Returns:
84 If the input is valid, the length of the converted string is returned.
85 If the input is not valid, 0 is returned.
86*/
88int ON_CorrectBase32StringTypos( const wchar_t* sBase32, ON_wString& sBase32clean );
90int ON_CorrectBase32StringTypos( const char* sBase32, ON_String& sBase32clean );
92int ON_CorrectBase32StringTypos( const char* sBase32, char* sBase32clean );
93
94
95/*
96Description:
97 Convert a null terminate string containing the 32 symbols
98
99 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
100
101 (I,L,O and S are missing) into a list of base 32 digits.
102Parameters:
103 sBase32 - [in]
104 String with base 32 digits
105 base32_digits - [out]
106 base32_digits[] is an array of length strlen(sBase32).
107 The returned array, element will be in the range 0 to 31.
108 sBase32[] must be an array of length base32_digit_count+1 or 2,
109 whichever is greater. The string representation of the base 32
110 number will be put in this string. A hash mark symbol (#) is
111 used to indicate an error in the input value. The returned
112 string is null terminated.
113Returns
114 True if the input is valid. False if the input is not valid,
115 in which case hash marks indicate the invalid entries.
116*/
118int ON_StringToBase32(const ON_wString& sBase32, ON_SimpleArray<unsigned char>& base32_digits );
120int ON_StringToBase32(const ON_String& sBase32, ON_SimpleArray<unsigned char>& base32_digits );
122int ON_StringToBase32(const char* sBase32, unsigned char* base32_digits );
123
124
125#endif
Definition opennurbs_array.h:46
Definition opennurbs_string.h:150
Definition opennurbs_string.h:392
ON_DECL int ON_GetBase32Digits(const ON_SimpleArray< unsigned char > &x, ON_SimpleArray< unsigned char > &base32_digits)
Definition opennurbs_base32.cpp:191
ON_DECL int ON_StringToBase32(const ON_wString &sBase32, ON_SimpleArray< unsigned char > &base32_digits)
Definition opennurbs_base32.cpp:142
ON_DECL int ON_CorrectBase32StringTypos(const wchar_t *sBase32, ON_wString &sBase32clean)
Definition opennurbs_base32.cpp:90
ON_DECL bool ON_Base32ToString(const ON_SimpleArray< unsigned char > &base32_digits, ON_String &sBase32)
Definition opennurbs_base32.cpp:18
#define ON_DECL
Definition opennurbs_defines.h:92