intl/unicharutil/src/nsSaveAsCharset.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/unicharutil/src/nsSaveAsCharset.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     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 nsSaveAsCharset_h__
    1.10 +#define nsSaveAsCharset_h__
    1.11 +
    1.12 +#include "nsStringFwd.h"
    1.13 +#include "nsTArray.h"
    1.14 +#include "nsISaveAsCharset.h"
    1.15 +
    1.16 +
    1.17 +#define MASK_FALLBACK(a) (nsISaveAsCharset::mask_Fallback & (a))
    1.18 +#define MASK_ENTITY(a) (nsISaveAsCharset::mask_Entity & (a))
    1.19 +#define MASK_CHARSET_FALLBACK(a) (nsISaveAsCharset::mask_CharsetFallback & (a))
    1.20 +#define ATTR_NO_FALLBACK(a) (nsISaveAsCharset::attr_FallbackNone == MASK_FALLBACK(a) && \
    1.21 +                             nsISaveAsCharset::attr_EntityAfterCharsetConv != MASK_ENTITY(a))
    1.22 +
    1.23 +class nsIUnicodeEncoder;
    1.24 +class nsIEntityConverter;
    1.25 +
    1.26 +class nsSaveAsCharset : public nsISaveAsCharset
    1.27 +{
    1.28 +public:
    1.29 +	
    1.30 +	//
    1.31 +	// implementation methods
    1.32 +	//
    1.33 +  nsSaveAsCharset();
    1.34 +  virtual ~nsSaveAsCharset();
    1.35 +
    1.36 +	//
    1.37 +	// nsISupports
    1.38 +	//
    1.39 +	NS_DECL_ISUPPORTS
    1.40 +
    1.41 +	//
    1.42 +	// nsIEntityConverter
    1.43 +	//
    1.44 +  NS_IMETHOD Init(const char *charset, uint32_t attr, uint32_t entityVersion);
    1.45 +
    1.46 +  NS_IMETHOD Convert(const char16_t *inString, char **_retval);
    1.47 +
    1.48 +  NS_IMETHODIMP GetCharset(char * *aCharset);
    1.49 +
    1.50 +protected:
    1.51 +
    1.52 +  NS_IMETHOD DoCharsetConversion(const char16_t *inString, char **outString);
    1.53 +
    1.54 +  NS_IMETHOD DoConversionFallBack(uint32_t inUCS4, char *outString, int32_t bufferLength);
    1.55 +
    1.56 +  // do the fallback, reallocate the buffer if necessary
    1.57 +  // need to pass destination buffer info (size, current position and estimation of rest of the conversion)
    1.58 +  NS_IMETHOD HandleFallBack(uint32_t character, char **outString, int32_t *bufferLength, 
    1.59 +                            int32_t *currentPos, int32_t estimatedLength);
    1.60 +
    1.61 +  nsresult SetupUnicodeEncoder(const char* charset);
    1.62 +
    1.63 +  nsresult SetupCharsetList(const char *charsetList);
    1.64 +
    1.65 +  const char * GetNextCharset();
    1.66 +
    1.67 +  uint32_t mAttribute;                    // conversion attribute
    1.68 +  uint32_t mEntityVersion;                // see nsIEntityConverter
    1.69 +  nsCOMPtr<nsIUnicodeEncoder> mEncoder;   // encoder (convert from unicode)
    1.70 +  nsCOMPtr<nsIEntityConverter> mEntityConverter;
    1.71 +  nsTArray<nsCString> mCharsetList;
    1.72 +  int32_t        mCharsetListIndex;
    1.73 +};
    1.74 +
    1.75 +#endif

mercurial