OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkBase64_DEFINED | 8 #ifndef SkBase64_DEFINED |
11 #define SkBase64_DEFINED | 9 #define SkBase64_DEFINED |
12 | 10 |
13 #include "SkTypes.h" | 11 #include "SkTypes.h" |
14 | 12 |
15 struct SkBase64 { | 13 struct SkBase64 { |
16 public: | 14 public: |
17 enum Error { | 15 enum Error { |
18 kNoError, | 16 kNoError, |
19 kPadError, | 17 kPadError, |
20 kBadCharError | 18 kBadCharError |
21 }; | 19 }; |
22 | 20 |
23 SkBase64(); | 21 SkBase64(); |
24 Error decode(const char* src, size_t length); | 22 Error decode(const char* src, size_t length); |
25 char* getData() { return fData; } | 23 char* getData() { return fData; } |
26 /** | 24 /** |
27 Base64 encodes src into dst. encode is a pointer to at least 65 chars. | 25 Base64 encodes src into dst. encode is a pointer to at least 65 chars. |
28 encode[64] will be used as the pad character. Encodings other than the | 26 encode[64] will be used as the pad character. Encodings other than the |
29 default encoding cannot be decoded. | 27 default encoding cannot be decoded. |
30 */ | 28 */ |
31 static size_t Encode(const void* src, size_t length, void* dest, const char*
encode = NULL); | 29 static size_t Encode(const void* src, size_t length, void* dest, const char*
encode = NULL); |
32 | 30 |
33 #ifdef SK_SUPPORT_UNITTEST | |
34 static void UnitTest(); | |
35 #endif | |
36 private: | 31 private: |
37 Error decode(const void* srcPtr, size_t length, bool writeDestination); | 32 Error decode(const void* srcPtr, size_t length, bool writeDestination); |
38 | 33 |
39 size_t fLength; | 34 size_t fLength; |
40 char* fData; | 35 char* fData; |
41 friend class SkImageBaseBitmap; | 36 friend class SkImageBaseBitmap; |
42 }; | 37 }; |
43 | 38 |
44 #endif // SkBase64_DEFINED | 39 #endif // SkBase64_DEFINED |
OLD | NEW |