1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsIStringStream.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsIInputStream.idl" 1.10 + 1.11 +/** 1.12 + * nsIStringInputStream 1.13 + * 1.14 + * Provides scriptable and specialized C++-only methods for initializing a 1.15 + * nsIInputStream implementation with a simple character array. 1.16 + */ 1.17 +[scriptable, uuid(450cd2d4-f0fd-424d-b365-b1251f80fd53)] 1.18 +interface nsIStringInputStream : nsIInputStream 1.19 +{ 1.20 + /** 1.21 + * SetData - assign data to the input stream (copied on assignment). 1.22 + * 1.23 + * @param data - stream data 1.24 + * @param dataLen - stream data length (-1 if length should be computed) 1.25 + * 1.26 + * NOTE: C++ code should consider using AdoptData or ShareData to avoid 1.27 + * making an extra copy of the stream data. 1.28 + * 1.29 + * NOTE: For JS callers, the given data must not contain null characters 1.30 + * (other than a null terminator) because a null character in the middle of 1.31 + * the data string will be seen as a terminator when the data is converted 1.32 + * from a JS string to a C++ character array. 1.33 + */ 1.34 + void setData(in string data, in long dataLen); 1.35 + 1.36 + /** 1.37 + * NOTE: the following methods are designed to give C++ code added control 1.38 + * over the ownership and lifetime of the stream data. Use with care :-) 1.39 + */ 1.40 + 1.41 + /** 1.42 + * AdoptData - assign data to the input stream. the input stream takes 1.43 + * ownership of the given data buffer and will nsMemory::Free it when 1.44 + * the input stream is destroyed. 1.45 + * 1.46 + * @param data - stream data 1.47 + * @param dataLen - stream data length (-1 if length should be computed) 1.48 + */ 1.49 + [noscript] void adoptData(in charPtr data, in long dataLen); 1.50 + 1.51 + /** 1.52 + * ShareData - assign data to the input stream. the input stream references 1.53 + * the given data buffer until the input stream is destroyed. the given 1.54 + * data buffer must outlive the input stream. 1.55 + * 1.56 + * @param data - stream data 1.57 + * @param dataLen - stream data length (-1 if length should be computed) 1.58 + */ 1.59 + [noscript] void shareData(in string data, in long dataLen); 1.60 +};