SkBase64.h 970 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifndef SkBase64_DEFINED
  8. #define SkBase64_DEFINED
  9. #include "include/core/SkTypes.h"
  10. struct SkBase64 {
  11. public:
  12. enum Error {
  13. kNoError,
  14. kPadError,
  15. kBadCharError
  16. };
  17. SkBase64();
  18. Error decode(const char* src, size_t length);
  19. char* getData() { return fData; }
  20. /**
  21. Base64 encodes src into dst. encode is a pointer to at least 65 chars.
  22. encode[64] will be used as the pad character. Encodings other than the
  23. default encoding cannot be decoded.
  24. */
  25. static size_t Encode(const void* src, size_t length, void* dest, const char* encode = nullptr);
  26. private:
  27. Error decode(const void* srcPtr, size_t length, bool writeDestination);
  28. size_t fLength;
  29. char* fData;
  30. friend class SkImageBaseBitmap;
  31. };
  32. #endif // SkBase64_DEFINED