Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C; tab-width: 4; 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 nsConverterInputStream_h |
michael@0 | 7 | #define nsConverterInputStream_h |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIInputStream.h" |
michael@0 | 10 | #include "nsIConverterInputStream.h" |
michael@0 | 11 | #include "nsIUnicharLineInputStream.h" |
michael@0 | 12 | #include "nsTArray.h" |
michael@0 | 13 | #include "nsAutoPtr.h" |
michael@0 | 14 | #include "nsCOMPtr.h" |
michael@0 | 15 | #include "nsIUnicodeDecoder.h" |
michael@0 | 16 | #include "nsReadLine.h" |
michael@0 | 17 | |
michael@0 | 18 | #define NS_CONVERTERINPUTSTREAM_CONTRACTID "@mozilla.org/intl/converter-input-stream;1" |
michael@0 | 19 | |
michael@0 | 20 | // {2BC2AD62-AD5D-4b7b-A9DB-F74AE203C527} |
michael@0 | 21 | #define NS_CONVERTERINPUTSTREAM_CID \ |
michael@0 | 22 | { 0x2bc2ad62, 0xad5d, 0x4b7b, \ |
michael@0 | 23 | { 0xa9, 0xdb, 0xf7, 0x4a, 0xe2, 0x3, 0xc5, 0x27 } } |
michael@0 | 24 | |
michael@0 | 25 | |
michael@0 | 26 | |
michael@0 | 27 | class nsConverterInputStream : public nsIConverterInputStream, |
michael@0 | 28 | public nsIUnicharLineInputStream { |
michael@0 | 29 | |
michael@0 | 30 | public: |
michael@0 | 31 | NS_DECL_ISUPPORTS |
michael@0 | 32 | NS_DECL_NSIUNICHARINPUTSTREAM |
michael@0 | 33 | NS_DECL_NSIUNICHARLINEINPUTSTREAM |
michael@0 | 34 | NS_DECL_NSICONVERTERINPUTSTREAM |
michael@0 | 35 | |
michael@0 | 36 | nsConverterInputStream() : |
michael@0 | 37 | mLastErrorCode(NS_OK), |
michael@0 | 38 | mLeftOverBytes(0), |
michael@0 | 39 | mUnicharDataOffset(0), |
michael@0 | 40 | mUnicharDataLength(0), |
michael@0 | 41 | mReplacementChar(DEFAULT_REPLACEMENT_CHARACTER), |
michael@0 | 42 | mLineBuffer(nullptr) { } |
michael@0 | 43 | |
michael@0 | 44 | virtual ~nsConverterInputStream() { Close(); } |
michael@0 | 45 | |
michael@0 | 46 | private: |
michael@0 | 47 | |
michael@0 | 48 | |
michael@0 | 49 | uint32_t Fill(nsresult *aErrorCode); |
michael@0 | 50 | |
michael@0 | 51 | nsCOMPtr<nsIUnicodeDecoder> mConverter; |
michael@0 | 52 | FallibleTArray<char> mByteData; |
michael@0 | 53 | FallibleTArray<char16_t> mUnicharData; |
michael@0 | 54 | nsCOMPtr<nsIInputStream> mInput; |
michael@0 | 55 | |
michael@0 | 56 | nsresult mLastErrorCode; |
michael@0 | 57 | uint32_t mLeftOverBytes; |
michael@0 | 58 | uint32_t mUnicharDataOffset; |
michael@0 | 59 | uint32_t mUnicharDataLength; |
michael@0 | 60 | char16_t mReplacementChar; |
michael@0 | 61 | |
michael@0 | 62 | nsAutoPtr<nsLineBuffer<char16_t> > mLineBuffer; |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | #endif |
michael@0 | 66 |