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