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(); |
22 | |
24 Error decode(const char* src, size_t length); | 23 Error decode(const char* src, size_t length); |
24 | |
25 char* getData() { return fData; } | 25 char* getData() { return fData; } |
26 | |
27 size_t length() const { return fLength; } | |
mtklein
2014/01/30 02:33:02
Let's drop this and remove that assert in the test
tfarina
2014/01/30 02:44:59
Done.
| |
28 | |
26 /** | 29 /** |
27 Base64 encodes src into dst. encode is a pointer to at least 65 chars. | 30 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 | 31 encode[64] will be used as the pad character. Encodings other than the |
29 default encoding cannot be decoded. | 32 default encoding cannot be decoded. |
30 */ | 33 */ |
31 static size_t Encode(const void* src, size_t length, void* dest, const char* encode = NULL); | 34 static size_t Encode(const void* src, size_t length, void* dest, const char* encode = NULL); |
32 | 35 |
33 #ifdef SK_SUPPORT_UNITTEST | |
34 static void UnitTest(); | |
35 #endif | |
36 private: | 36 private: |
37 Error decode(const void* srcPtr, size_t length, bool writeDestination); | 37 Error decode(const void* srcPtr, size_t length, bool writeDestination); |
38 | 38 |
39 size_t fLength; | 39 size_t fLength; |
40 char* fData; | 40 char* fData; |
41 friend class SkImageBaseBitmap; | 41 friend class SkImageBaseBitmap; |
42 }; | 42 }; |
43 | 43 |
44 #endif // SkBase64_DEFINED | 44 #endif // SkBase64_DEFINED |
OLD | NEW |