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/. */
5 #include "nsBase64Encoder.h"
7 #include "mozilla/Base64.h"
9 NS_IMPL_ISUPPORTS(nsBase64Encoder
, nsIOutputStream
)
12 nsBase64Encoder::Close() { return NS_OK
; }
15 nsBase64Encoder::Flush() { return NS_OK
; }
18 nsBase64Encoder::StreamStatus() { return NS_OK
; }
21 nsBase64Encoder::Write(const char* aBuf
, uint32_t aCount
, uint32_t* _retval
) {
22 mData
.Append(aBuf
, aCount
);
28 nsBase64Encoder::WriteFrom(nsIInputStream
* aStream
, uint32_t aCount
,
30 return NS_ERROR_NOT_IMPLEMENTED
;
34 nsBase64Encoder::WriteSegments(nsReadSegmentFun aReader
, void* aClosure
,
35 uint32_t aCount
, uint32_t* _retval
) {
36 return NS_ERROR_NOT_IMPLEMENTED
;
40 nsBase64Encoder::IsNonBlocking(bool* aNonBlocking
) {
41 *aNonBlocking
= false;
45 nsresult
nsBase64Encoder::Finish(nsACString
& result
) {
46 nsresult rv
= mozilla::Base64Encode(mData
, result
);
51 // Free unneeded memory and allow reusing the object