blob: 13350b7b682cd30fe7d2e22e37ffd16e4778aec4 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
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.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkBase64_DEFINED
9#define SkBase64_DEFINED
10
11#include "SkTypes.h"
12
13struct SkBase64 {
14public:
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.comaf5bbf22012-02-07 20:47:38 +000024 /**
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 */
halcanary96fcdcc2015-08-27 07:41:13 -070029 static size_t Encode(const void* src, size_t length, void* dest, const char* encode = nullptr);
reed@android.com8a1c16f2008-12-17 15:59:43 +000030
reed@android.com8a1c16f2008-12-17 15:59:43 +000031private:
32 Error decode(const void* srcPtr, size_t length, bool writeDestination);
33
34 size_t fLength;
35 char* fData;
reed@google.combdae0272012-07-27 15:30:40 +000036 friend class SkImageBaseBitmap;
reed@android.com8a1c16f2008-12-17 15:59:43 +000037};
38
39#endif // SkBase64_DEFINED