michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIInputStream; michael@0: michael@0: /** michael@0: * nsIScriptableBase64Encoder efficiently encodes the contents michael@0: * of a nsIInputStream to a Base64 string. This avoids the need michael@0: * to read the entire stream into a buffer, and only then do the michael@0: * Base64 encoding. michael@0: * michael@0: * If you already have a buffer full of data, you should use michael@0: * btoa instead! michael@0: */ michael@0: [scriptable, uuid(9479c864-d1f9-45ab-b7b9-28b907bd2ba9)] michael@0: interface nsIScriptableBase64Encoder : nsISupports michael@0: { michael@0: /** michael@0: * These methods take an nsIInputStream and return a narrow or wide michael@0: * string with the contents of the nsIInputStream base64 encoded. michael@0: * michael@0: * The stream passed in must support ReadSegments and must not be michael@0: * a non-blocking stream that will return NS_BASE_STREAM_WOULD_BLOCK. michael@0: * If either of these restrictions are violated we will abort. michael@0: */ michael@0: ACString encodeToCString(in nsIInputStream stream, in unsigned long length); michael@0: AString encodeToString(in nsIInputStream stream, in unsigned long length); michael@0: };