2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-17 16:09:20 -07:00
|
|
|
#ifndef nsConverterInputStream_h
|
|
|
|
#define nsConverterInputStream_h
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIInputStream.h"
|
|
|
|
#include "nsIConverterInputStream.h"
|
|
|
|
#include "nsIUnicharLineInputStream.h"
|
2013-08-20 04:03:50 -07:00
|
|
|
#include "nsTArray.h"
|
2012-12-04 15:04:39 -08:00
|
|
|
#include "nsAutoPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIUnicodeDecoder.h"
|
2012-12-04 15:04:39 -08:00
|
|
|
#include "nsReadLine.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_CONVERTERINPUTSTREAM_CONTRACTID "@mozilla.org/intl/converter-input-stream;1"
|
|
|
|
|
|
|
|
// {2BC2AD62-AD5D-4b7b-A9DB-F74AE203C527}
|
|
|
|
#define NS_CONVERTERINPUTSTREAM_CID \
|
|
|
|
{ 0x2bc2ad62, 0xad5d, 0x4b7b, \
|
|
|
|
{ 0xa9, 0xdb, 0xf7, 0x4a, 0xe2, 0x3, 0xc5, 0x27 } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class nsConverterInputStream : public nsIConverterInputStream,
|
|
|
|
public nsIUnicharLineInputStream {
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIUNICHARINPUTSTREAM
|
|
|
|
NS_DECL_NSIUNICHARLINEINPUTSTREAM
|
|
|
|
NS_DECL_NSICONVERTERINPUTSTREAM
|
|
|
|
|
|
|
|
nsConverterInputStream() :
|
|
|
|
mLastErrorCode(NS_OK),
|
|
|
|
mLeftOverBytes(0),
|
|
|
|
mUnicharDataOffset(0),
|
|
|
|
mUnicharDataLength(0),
|
|
|
|
mReplacementChar(DEFAULT_REPLACEMENT_CHARACTER),
|
2012-07-30 07:20:58 -07:00
|
|
|
mLineBuffer(nullptr) { }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
2014-06-23 15:40:02 -07:00
|
|
|
virtual ~nsConverterInputStream() { Close(); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t Fill(nsresult *aErrorCode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIUnicodeDecoder> mConverter;
|
2013-08-20 04:03:50 -07:00
|
|
|
FallibleTArray<char> mByteData;
|
2014-01-04 07:02:17 -08:00
|
|
|
FallibleTArray<char16_t> mUnicharData;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIInputStream> mInput;
|
|
|
|
|
|
|
|
nsresult mLastErrorCode;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLeftOverBytes;
|
|
|
|
uint32_t mUnicharDataOffset;
|
|
|
|
uint32_t mUnicharDataLength;
|
2014-01-04 07:02:17 -08:00
|
|
|
char16_t mReplacementChar;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
nsAutoPtr<nsLineBuffer<char16_t> > mLineBuffer;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
2013-10-17 16:09:20 -07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|