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
8#ifndef SkBase64_DEFINED
9#define SkBase64_DEFINED
10
11#include "include/core/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; }
24 size_t getDataSize() { return fLength; }
25 /**
26 Base64 encodes src into dst. encode is a pointer to at least 65 chars.
27 encode[64] will be used as the pad character. Encodings other than the
28 default encoding cannot be decoded.
29 */
30 static size_t Encode(const void* src, size_t length, void* dest, const char* encode = nullptr);
31
32private:
33 Error decode(const void* srcPtr, size_t length, bool writeDestination);
34
35 size_t fLength;
36 char* fData;
37 friend class SkImageBaseBitmap;
38};
39
40#endif // SkBase64_DEFINED
41