nsBase64Encoder.h 828 B

123456789101112131415161718192021222324252627282930313233
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef NSBASE64ENCODER_H_
  5. #define NSBASE64ENCODER_H_
  6. #include "nsIOutputStream.h"
  7. #include "nsString.h"
  8. #include "mozilla/Attributes.h"
  9. /**
  10. * A base64 encoder. Usage: Instantiate class, write to it using
  11. * Write(), then call Finish() to get the base64-encoded data.
  12. */
  13. class nsBase64Encoder final : public nsIOutputStream {
  14. public:
  15. nsBase64Encoder() {}
  16. NS_DECL_ISUPPORTS
  17. NS_DECL_NSIOUTPUTSTREAM
  18. nsresult Finish(nsCSubstring& _result);
  19. private:
  20. ~nsBase64Encoder() {}
  21. /// The data written to this stream. nsCString can deal fine with
  22. /// binary data.
  23. nsCString mData;
  24. };
  25. #endif