intl/uconv/src/nsConverterInputStream.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/uconv/src/nsConverterInputStream.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsConverterInputStream_h
    1.10 +#define nsConverterInputStream_h
    1.11 +
    1.12 +#include "nsIInputStream.h"
    1.13 +#include "nsIConverterInputStream.h"
    1.14 +#include "nsIUnicharLineInputStream.h"
    1.15 +#include "nsTArray.h"
    1.16 +#include "nsAutoPtr.h"
    1.17 +#include "nsCOMPtr.h"
    1.18 +#include "nsIUnicodeDecoder.h"
    1.19 +#include "nsReadLine.h"
    1.20 +
    1.21 +#define NS_CONVERTERINPUTSTREAM_CONTRACTID "@mozilla.org/intl/converter-input-stream;1"
    1.22 +
    1.23 +// {2BC2AD62-AD5D-4b7b-A9DB-F74AE203C527}
    1.24 +#define NS_CONVERTERINPUTSTREAM_CID \
    1.25 +  { 0x2bc2ad62, 0xad5d, 0x4b7b, \
    1.26 +   { 0xa9, 0xdb, 0xf7, 0x4a, 0xe2, 0x3, 0xc5, 0x27 } }
    1.27 +
    1.28 +
    1.29 +
    1.30 +class nsConverterInputStream : public nsIConverterInputStream,
    1.31 +                               public nsIUnicharLineInputStream {
    1.32 +
    1.33 + public:
    1.34 +    NS_DECL_ISUPPORTS
    1.35 +    NS_DECL_NSIUNICHARINPUTSTREAM
    1.36 +    NS_DECL_NSIUNICHARLINEINPUTSTREAM
    1.37 +    NS_DECL_NSICONVERTERINPUTSTREAM
    1.38 +
    1.39 +    nsConverterInputStream() :
    1.40 +        mLastErrorCode(NS_OK),
    1.41 +        mLeftOverBytes(0),
    1.42 +        mUnicharDataOffset(0),
    1.43 +        mUnicharDataLength(0),
    1.44 +        mReplacementChar(DEFAULT_REPLACEMENT_CHARACTER),
    1.45 +        mLineBuffer(nullptr) { }
    1.46 +    
    1.47 +    virtual ~nsConverterInputStream() { Close(); }
    1.48 +
    1.49 + private:
    1.50 +
    1.51 +
    1.52 +    uint32_t Fill(nsresult *aErrorCode);
    1.53 +    
    1.54 +    nsCOMPtr<nsIUnicodeDecoder> mConverter;
    1.55 +    FallibleTArray<char> mByteData;
    1.56 +    FallibleTArray<char16_t> mUnicharData;
    1.57 +    nsCOMPtr<nsIInputStream> mInput;
    1.58 +
    1.59 +    nsresult  mLastErrorCode;
    1.60 +    uint32_t  mLeftOverBytes;
    1.61 +    uint32_t  mUnicharDataOffset;
    1.62 +    uint32_t  mUnicharDataLength;
    1.63 +    char16_t mReplacementChar;
    1.64 +
    1.65 +    nsAutoPtr<nsLineBuffer<char16_t> > mLineBuffer;
    1.66 +};
    1.67 +
    1.68 +#endif
    1.69 +

mercurial