author Nicolas B. Pierron <>
Wed, 01 Oct 2014 19:17:51 +0200
changeset 208230 ed4b995667b58b364d2a7ce9b2111fc22dc1f622
parent 196042 80aec550b1e06b59ccd4c0f1a33420221421141e
child 222341 cdbe4d2202d7b7451398a92a2e73b9b341d89d27
permissions -rw-r--r--
Bug 1074911 - Replace JS_ASSERT by MOZ_ASSERT. r=jorendorff Apply the following script sed -i ' /JS_ASSERT(/ { s/JS_ASSERT(/MOZ_ASSERT(/; :b; s/ \\$/\\/; /;/ { p; d; }; n; s/^/ /; b b; }; s/JS_ASSERT (/MOZ_ASSERT(/; ' Except where the JS_ASSERT macro does not end with a semi-colon, where empty lines are in the middle of the macro, and where the backslahes are always the same-length after the expression.

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 */

#ifndef nsSaveAsCharset_h__
#define nsSaveAsCharset_h__

#include "nsStringFwd.h"
#include "nsTArray.h"
#include "nsISaveAsCharset.h"
#include "nsCOMPtr.h"

#define MASK_FALLBACK(a) (nsISaveAsCharset::mask_Fallback & (a))
#define MASK_ENTITY(a) (nsISaveAsCharset::mask_Entity & (a))
#define MASK_CHARSET_FALLBACK(a) (nsISaveAsCharset::mask_CharsetFallback & (a))
#define ATTR_NO_FALLBACK(a) (nsISaveAsCharset::attr_FallbackNone == MASK_FALLBACK(a) && \
                             nsISaveAsCharset::attr_EntityAfterCharsetConv != MASK_ENTITY(a))

class nsIUnicodeEncoder;
class nsIEntityConverter;

class nsSaveAsCharset : public nsISaveAsCharset
	// implementation methods

	// nsISupports

	// nsIEntityConverter
  NS_IMETHOD Init(const char *charset, uint32_t attr, uint32_t entityVersion);

  NS_IMETHOD Convert(const char16_t *inString, char **_retval);

  NS_IMETHODIMP GetCharset(char * *aCharset);


  virtual ~nsSaveAsCharset();

  NS_IMETHOD DoCharsetConversion(const char16_t *inString, char **outString);

  NS_IMETHOD DoConversionFallBack(uint32_t inUCS4, char *outString, int32_t bufferLength);

  // do the fallback, reallocate the buffer if necessary
  // need to pass destination buffer info (size, current position and estimation of rest of the conversion)
  NS_IMETHOD HandleFallBack(uint32_t character, char **outString, int32_t *bufferLength, 
                            int32_t *currentPos, int32_t estimatedLength);

  nsresult SetupUnicodeEncoder(const char* charset);

  nsresult SetupCharsetList(const char *charsetList);

  const char * GetNextCharset();

  uint32_t mAttribute;                    // conversion attribute
  uint32_t mEntityVersion;                // see nsIEntityConverter
  nsCOMPtr<nsIUnicodeEncoder> mEncoder;   // encoder (convert from unicode)
  nsCOMPtr<nsIEntityConverter> mEntityConverter;
  nsTArray<nsCString> mCharsetList;
  int32_t        mCharsetListIndex;