aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkBase64.h
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-07 20:47:38 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-07 20:47:38 +0000
commitaf5bbf24498634142f4227eed2b120169a08156b (patch)
treede611b1b24c4cb2f2812e59d7024758a85e31a53 /src/utils/SkBase64.h
parent1f9767c03bad1ef85e5388d84e23e4b5dff4bc1a (diff)
Move SkBase64 to utils, allow user defined encoding.
git-svn-id: http://skia.googlecode.com/svn/trunk@3148 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/SkBase64.h')
-rw-r--r--src/utils/SkBase64.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/utils/SkBase64.h b/src/utils/SkBase64.h
new file mode 100644
index 0000000000..4f3b3234f1
--- /dev/null
+++ b/src/utils/SkBase64.h
@@ -0,0 +1,44 @@
+
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#ifndef SkBase64_DEFINED
+#define SkBase64_DEFINED
+
+#include "SkTypes.h"
+
+struct SkBase64 {
+public:
+ enum Error {
+ kNoError,
+ kPadError,
+ kBadCharError
+ };
+
+ SkBase64();
+ Error decode(const char* src, size_t length);
+ char* getData() { return fData; }
+ /**
+ Base64 encodes src into dst. encode is a pointer to at least 65 chars.
+ encode[64] will be used as the pad character. Encodings other than the
+ default encoding cannot be decoded.
+ */
+ static size_t Encode(const void* src, size_t length, void* dest, const char* encode = NULL);
+
+#ifdef SK_SUPPORT_UNITTEST
+ static void UnitTest();
+#endif
+private:
+ Error decode(const void* srcPtr, size_t length, bool writeDestination);
+
+ size_t fLength;
+ char* fData;
+ friend class SkImage;
+};
+
+#endif // SkBase64_DEFINED