Bug 1910362 - Create new Nimbus helper r=aaronmt,ohorvath
[gecko.git] / xpcom / io / nsIStringStream.idl
blob8117dfb6bc82076e4c0b11734b12a6812e3ca6d5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsIInputStream.idl"
8 %{C++
9 #include "mozilla/MemoryReporting.h"
11 namespace mozilla {
12 class StreamBufferSource;
13 } // namespace mozilla
16 native MallocSizeOf(mozilla::MallocSizeOf);
17 [ptr] native StreamBufferSource(mozilla::StreamBufferSource);
19 /**
20 * nsIStringInputStream
22 * Provides scriptable and specialized C++-only methods for initializing a
23 * nsIInputStream implementation with a simple character array.
25 [scriptable, builtinclass, uuid(450cd2d4-f0fd-424d-b365-b1251f80fd53)]
26 interface nsIStringInputStream : nsIInputStream
28 /**
29 * SetData - assign data to the input stream from a byte string.
31 * @param data - stream data
33 * NOTE: For JS callers, no UTF-8 encoding will be performed.
35 void setByteStringData(in ACString data);
37 /**
38 * SetUTF8Data - encode input data to UTF-8 and assign it to the input
39 * stream.
41 * @param data - stream data
43 * NOTE: This method is meant to be used by JS callers,
45 void setUTF8Data(in AUTF8String data);
47 /**
48 * NOTE: the following methods are designed to give C++ code added control
49 * over the ownership and lifetime of the stream data. Use with care :-)
52 /**
53 * SetData - assign data to the input stream (copied on assignment).
55 * @param data - stream data
56 * @param dataLen - stream data length
58 * NOTE: C++ code should consider using AdoptData or ShareData to avoid
59 * making an extra copy of the stream data.
61 [noscript] void copyData(in string data, in size_t dataLen);
63 /**
64 * AdoptData - assign data to the input stream. the input stream takes
65 * ownership of the given data buffer and will free it when
66 * the input stream is destroyed.
68 * @param data - stream data
69 * @param dataLen - stream data length
71 [noscript] void adoptData(in charPtr data, in size_t dataLen);
73 /**
74 * ShareData - assign data to the input stream. the input stream references
75 * the given data buffer until the input stream is destroyed. the given
76 * data buffer must outlive the input stream.
78 * @param data - stream data
79 * @param dataLen - stream data length
81 [noscript] void shareData(in string data, in size_t dataLen);
83 /**
84 * SetDataSource - assign data to the input stream. the input stream holds
85 * a strong reference to the given data buffer until it is destroyed.
87 * @param source - stream data source
89 [noscript] void setDataSource(in StreamBufferSource source);
91 [noscript, notxpcom]
92 size_t SizeOfIncludingThisIfUnshared(in MallocSizeOf aMallocSizeOf);
94 [noscript, notxpcom]
95 size_t SizeOfIncludingThisEvenIfShared(in MallocSizeOf aMallocSizeOf);