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 "nsIInputStream.idl" michael@0: michael@0: /** michael@0: * nsIStringInputStream michael@0: * michael@0: * Provides scriptable and specialized C++-only methods for initializing a michael@0: * nsIInputStream implementation with a simple character array. michael@0: */ michael@0: [scriptable, uuid(450cd2d4-f0fd-424d-b365-b1251f80fd53)] michael@0: interface nsIStringInputStream : nsIInputStream michael@0: { michael@0: /** michael@0: * SetData - assign data to the input stream (copied on assignment). michael@0: * michael@0: * @param data - stream data michael@0: * @param dataLen - stream data length (-1 if length should be computed) michael@0: * michael@0: * NOTE: C++ code should consider using AdoptData or ShareData to avoid michael@0: * making an extra copy of the stream data. michael@0: * michael@0: * NOTE: For JS callers, the given data must not contain null characters michael@0: * (other than a null terminator) because a null character in the middle of michael@0: * the data string will be seen as a terminator when the data is converted michael@0: * from a JS string to a C++ character array. michael@0: */ michael@0: void setData(in string data, in long dataLen); michael@0: michael@0: /** michael@0: * NOTE: the following methods are designed to give C++ code added control michael@0: * over the ownership and lifetime of the stream data. Use with care :-) michael@0: */ michael@0: michael@0: /** michael@0: * AdoptData - assign data to the input stream. the input stream takes michael@0: * ownership of the given data buffer and will nsMemory::Free it when michael@0: * the input stream is destroyed. michael@0: * michael@0: * @param data - stream data michael@0: * @param dataLen - stream data length (-1 if length should be computed) michael@0: */ michael@0: [noscript] void adoptData(in charPtr data, in long dataLen); michael@0: michael@0: /** michael@0: * ShareData - assign data to the input stream. the input stream references michael@0: * the given data buffer until the input stream is destroyed. the given michael@0: * data buffer must outlive the input stream. michael@0: * michael@0: * @param data - stream data michael@0: * @param dataLen - stream data length (-1 if length should be computed) michael@0: */ michael@0: [noscript] void shareData(in string data, in long dataLen); michael@0: };