blob: d547cb4d0a447b3c19ce5829485b1df2e080782a [file] [log] [blame]
Cary Clarka6c75fd2018-06-19 16:00:31 -04001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkTypes.h"
Cary Clarka6c75fd2018-06-19 16:00:31 -040012
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 /**
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 = nullptr);
30
31private:
32 Error decode(const void* srcPtr, size_t length, bool writeDestination);
33
34 size_t fLength;
35 char* fData;
36 friend class SkImageBaseBitmap;
37};
38
39#endif // SkBase64_DEFINED