xpcom/io/nsStringStream.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsStringStream_h__
michael@0 7 #define nsStringStream_h__
michael@0 8
michael@0 9 #include "nsIStringStream.h"
michael@0 10 #include "nsStringGlue.h"
michael@0 11 #include "nsMemory.h"
michael@0 12
michael@0 13 /**
michael@0 14 * Implements:
michael@0 15 * nsIStringInputStream
michael@0 16 * nsIInputStream
michael@0 17 * nsISeekableStream
michael@0 18 * nsISupportsCString
michael@0 19 */
michael@0 20 #define NS_STRINGINPUTSTREAM_CONTRACTID "@mozilla.org/io/string-input-stream;1"
michael@0 21 #define NS_STRINGINPUTSTREAM_CID \
michael@0 22 { /* 0abb0835-5000-4790-af28-61b3ba17c295 */ \
michael@0 23 0x0abb0835, \
michael@0 24 0x5000, \
michael@0 25 0x4790, \
michael@0 26 {0xaf, 0x28, 0x61, 0xb3, 0xba, 0x17, 0xc2, 0x95} \
michael@0 27 }
michael@0 28
michael@0 29 /**
michael@0 30 * Factory method to get an nsInputStream from a byte buffer. Result will
michael@0 31 * implement nsIStringInputStream and nsISeekableStream.
michael@0 32 *
michael@0 33 * If aAssignment is NS_ASSIGNMENT_COPY, then the resulting stream holds a copy
michael@0 34 * of the given buffer (aStringToRead), and the caller is free to discard
michael@0 35 * aStringToRead after this function returns.
michael@0 36 *
michael@0 37 * If aAssignment is NS_ASSIGNMENT_DEPEND, then the resulting stream refers
michael@0 38 * directly to the given buffer (aStringToRead), so the caller must ensure that
michael@0 39 * the buffer remains valid for the lifetime of the stream object. Use with
michael@0 40 * care!!
michael@0 41 *
michael@0 42 * If aAssignment is NS_ASSIGNMENT_ADOPT, then the resulting stream refers
michael@0 43 * directly to the given buffer (aStringToRead) and will free aStringToRead
michael@0 44 * once the stream is closed.
michael@0 45 *
michael@0 46 * If aLength is less than zero, then the length of aStringToRead will be
michael@0 47 * determined by scanning the buffer for the first null byte.
michael@0 48 */
michael@0 49 extern nsresult
michael@0 50 NS_NewByteInputStream(nsIInputStream** aStreamResult,
michael@0 51 const char* aStringToRead, int32_t aLength = -1,
michael@0 52 nsAssignmentType aAssignment = NS_ASSIGNMENT_DEPEND);
michael@0 53
michael@0 54 /**
michael@0 55 * Factory method to get an nsInputStream from an nsAString. Result will
michael@0 56 * implement nsIStringInputStream and nsISeekableStream.
michael@0 57 *
michael@0 58 * The given string data will be converted to a single-byte data buffer via
michael@0 59 * truncation (i.e., the high-order byte of each character will be discarded).
michael@0 60 * This could result in data-loss, so be careful when using this function.
michael@0 61 */
michael@0 62 extern nsresult
michael@0 63 NS_NewStringInputStream(nsIInputStream** aStreamResult,
michael@0 64 const nsAString& aStringToRead);
michael@0 65
michael@0 66 /**
michael@0 67 * Factory method to get an nsInputStream from an nsACString. Result will
michael@0 68 * implement nsIStringInputStream and nsISeekableStream.
michael@0 69 */
michael@0 70 extern nsresult
michael@0 71 NS_NewCStringInputStream(nsIInputStream** aStreamResult,
michael@0 72 const nsACString& aStringToRead);
michael@0 73
michael@0 74 #endif // nsStringStream_h__

mercurial