michael@0: /* -*- Mode: C; tab-width: 4; 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: #ifndef nsConverterInputStream_h michael@0: #define nsConverterInputStream_h michael@0: michael@0: #include "nsIInputStream.h" michael@0: #include "nsIConverterInputStream.h" michael@0: #include "nsIUnicharLineInputStream.h" michael@0: #include "nsTArray.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIUnicodeDecoder.h" michael@0: #include "nsReadLine.h" michael@0: michael@0: #define NS_CONVERTERINPUTSTREAM_CONTRACTID "@mozilla.org/intl/converter-input-stream;1" michael@0: michael@0: // {2BC2AD62-AD5D-4b7b-A9DB-F74AE203C527} michael@0: #define NS_CONVERTERINPUTSTREAM_CID \ michael@0: { 0x2bc2ad62, 0xad5d, 0x4b7b, \ michael@0: { 0xa9, 0xdb, 0xf7, 0x4a, 0xe2, 0x3, 0xc5, 0x27 } } michael@0: michael@0: michael@0: michael@0: class nsConverterInputStream : public nsIConverterInputStream, michael@0: public nsIUnicharLineInputStream { michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIUNICHARINPUTSTREAM michael@0: NS_DECL_NSIUNICHARLINEINPUTSTREAM michael@0: NS_DECL_NSICONVERTERINPUTSTREAM michael@0: michael@0: nsConverterInputStream() : michael@0: mLastErrorCode(NS_OK), michael@0: mLeftOverBytes(0), michael@0: mUnicharDataOffset(0), michael@0: mUnicharDataLength(0), michael@0: mReplacementChar(DEFAULT_REPLACEMENT_CHARACTER), michael@0: mLineBuffer(nullptr) { } michael@0: michael@0: virtual ~nsConverterInputStream() { Close(); } michael@0: michael@0: private: michael@0: michael@0: michael@0: uint32_t Fill(nsresult *aErrorCode); michael@0: michael@0: nsCOMPtr mConverter; michael@0: FallibleTArray mByteData; michael@0: FallibleTArray mUnicharData; michael@0: nsCOMPtr mInput; michael@0: michael@0: nsresult mLastErrorCode; michael@0: uint32_t mLeftOverBytes; michael@0: uint32_t mUnicharDataOffset; michael@0: uint32_t mUnicharDataLength; michael@0: char16_t mReplacementChar; michael@0: michael@0: nsAutoPtr > mLineBuffer; michael@0: }; michael@0: michael@0: #endif michael@0: