1 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 9 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; } 26 /** 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); 32 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; 41 friend class SkImageBaseBitmap; 42}; 43 44#endif // SkBase64_DEFINED 45