blob: 5bf90066327b2c4fdb5ada39c96b6e2ae4de00cd [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#ifndef SkBase64_DEFINED
11#define SkBase64_DEFINED
12
13#include "SkTypes.h"
14
15struct SkBase64 {
16public:
17 enum Error {
18 kNoError,
19 kPadError,
20 kBadCharError
21 };
22
23 SkBase64();
24 Error decode(const char* src, size_t length);
25 char* getData() { return fData; }
bungeman@google.comaf5bbf22012-02-07 20:47:38 +000026 /**
27 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
29 default encoding cannot be decoded.
30 */
31 static size_t Encode(const void* src, size_t length, void* dest, const char* encode = NULL);
reed@android.com8a1c16f2008-12-17 15:59:43 +000032
33#ifdef SK_SUPPORT_UNITTEST
34 static void UnitTest();
35#endif
36private:
37 Error decode(const void* srcPtr, size_t length, bool writeDestination);
38
39 size_t fLength;
40 char* fData;
reed@google.combdae0272012-07-27 15:30:40 +000041 friend class SkImageBaseBitmap;
reed@android.com8a1c16f2008-12-17 15:59:43 +000042};
43
44#endif // SkBase64_DEFINED