2001-12-01 01:48:47 +03:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2001-12-01 01:48:47 +03:00
|
|
|
|
2013-10-18 03:09:20 +04:00
|
|
|
#ifndef nsConverterInputStream_h
|
|
|
|
#define nsConverterInputStream_h
|
|
|
|
|
2005-06-24 23:44:50 +04:00
|
|
|
#include "nsIInputStream.h"
|
2001-12-01 01:48:47 +03:00
|
|
|
#include "nsIConverterInputStream.h"
|
2005-07-05 16:56:31 +04:00
|
|
|
#include "nsIUnicharLineInputStream.h"
|
2013-08-20 15:03:50 +04:00
|
|
|
#include "nsTArray.h"
|
2012-12-05 03:04:39 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2001-12-01 01:48:47 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2012-12-05 03:04:39 +04:00
|
|
|
#include "nsReadLine.h"
|
2017-04-27 13:27:03 +03:00
|
|
|
#include "mozilla/Encoding.h"
|
2001-12-01 01:48:47 +03: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 } }
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-05 16:56:31 +04:00
|
|
|
class nsConverterInputStream : public nsIConverterInputStream,
|
|
|
|
public nsIUnicharLineInputStream {
|
2001-12-01 01:48:47 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2005-06-24 23:44:50 +04:00
|
|
|
NS_DECL_NSIUNICHARINPUTSTREAM
|
2005-07-05 16:56:31 +04:00
|
|
|
NS_DECL_NSIUNICHARLINEINPUTSTREAM
|
2005-06-24 23:44:50 +04:00
|
|
|
NS_DECL_NSICONVERTERINPUTSTREAM
|
2001-12-01 01:48:47 +03:00
|
|
|
|
2017-04-27 13:27:03 +03:00
|
|
|
nsConverterInputStream()
|
|
|
|
: mLastErrorCode(NS_OK)
|
|
|
|
, mLeftOverBytes(0)
|
|
|
|
, mUnicharDataOffset(0)
|
|
|
|
, mUnicharDataLength(0)
|
|
|
|
, mErrorsAreFatal(false)
|
|
|
|
, mLineBuffer(nullptr)
|
|
|
|
{
|
|
|
|
}
|
2001-12-01 01:48:47 +03:00
|
|
|
|
2017-04-27 13:27:03 +03:00
|
|
|
private:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsConverterInputStream() { Close(); }
|
2001-12-01 01:48:47 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t Fill(nsresult *aErrorCode);
|
2017-04-27 13:27:03 +03:00
|
|
|
|
|
|
|
mozilla::UniquePtr<mozilla::Decoder> mConverter;
|
2013-08-20 15:03:50 +04:00
|
|
|
FallibleTArray<char> mByteData;
|
2014-01-04 19:02:17 +04:00
|
|
|
FallibleTArray<char16_t> mUnicharData;
|
2001-12-01 01:48:47 +03:00
|
|
|
nsCOMPtr<nsIInputStream> mInput;
|
2002-08-28 03:47:25 +04:00
|
|
|
|
2005-06-24 23:44:50 +04:00
|
|
|
nsresult mLastErrorCode;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mLeftOverBytes;
|
|
|
|
uint32_t mUnicharDataOffset;
|
|
|
|
uint32_t mUnicharDataLength;
|
2017-04-27 13:27:03 +03:00
|
|
|
bool mErrorsAreFatal;
|
2005-06-24 23:44:50 +04:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
nsAutoPtr<nsLineBuffer<char16_t> > mLineBuffer;
|
2001-12-01 01:48:47 +03:00
|
|
|
};
|
2013-10-18 03:09:20 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|