intl/unicharutil/src/nsSaveAsCharset.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsSaveAsCharset_h__
     7 #define nsSaveAsCharset_h__
     9 #include "nsStringFwd.h"
    10 #include "nsTArray.h"
    11 #include "nsISaveAsCharset.h"
    14 #define MASK_FALLBACK(a) (nsISaveAsCharset::mask_Fallback & (a))
    15 #define MASK_ENTITY(a) (nsISaveAsCharset::mask_Entity & (a))
    16 #define MASK_CHARSET_FALLBACK(a) (nsISaveAsCharset::mask_CharsetFallback & (a))
    17 #define ATTR_NO_FALLBACK(a) (nsISaveAsCharset::attr_FallbackNone == MASK_FALLBACK(a) && \
    18                              nsISaveAsCharset::attr_EntityAfterCharsetConv != MASK_ENTITY(a))
    20 class nsIUnicodeEncoder;
    21 class nsIEntityConverter;
    23 class nsSaveAsCharset : public nsISaveAsCharset
    24 {
    25 public:
    27 	//
    28 	// implementation methods
    29 	//
    30   nsSaveAsCharset();
    31   virtual ~nsSaveAsCharset();
    33 	//
    34 	// nsISupports
    35 	//
    36 	NS_DECL_ISUPPORTS
    38 	//
    39 	// nsIEntityConverter
    40 	//
    41   NS_IMETHOD Init(const char *charset, uint32_t attr, uint32_t entityVersion);
    43   NS_IMETHOD Convert(const char16_t *inString, char **_retval);
    45   NS_IMETHODIMP GetCharset(char * *aCharset);
    47 protected:
    49   NS_IMETHOD DoCharsetConversion(const char16_t *inString, char **outString);
    51   NS_IMETHOD DoConversionFallBack(uint32_t inUCS4, char *outString, int32_t bufferLength);
    53   // do the fallback, reallocate the buffer if necessary
    54   // need to pass destination buffer info (size, current position and estimation of rest of the conversion)
    55   NS_IMETHOD HandleFallBack(uint32_t character, char **outString, int32_t *bufferLength, 
    56                             int32_t *currentPos, int32_t estimatedLength);
    58   nsresult SetupUnicodeEncoder(const char* charset);
    60   nsresult SetupCharsetList(const char *charsetList);
    62   const char * GetNextCharset();
    64   uint32_t mAttribute;                    // conversion attribute
    65   uint32_t mEntityVersion;                // see nsIEntityConverter
    66   nsCOMPtr<nsIUnicodeEncoder> mEncoder;   // encoder (convert from unicode)
    67   nsCOMPtr<nsIEntityConverter> mEntityConverter;
    68   nsTArray<nsCString> mCharsetList;
    69   int32_t        mCharsetListIndex;
    70 };
    72 #endif

mercurial