intl/unicharutil/src/nsEntityConverter.h
author Wes Kocher <wkocher@mozilla.com>
Wed, 29 Jan 2014 15:30:42 -0800
changeset 176108 095aa30cb6ef6a6772808db30e4ec3685a2d7d76
parent 163794 19af7baaf26e984eceec910174b968386bbd7ed2
child 179103 5a9badd6db004310b9d1aca5db25ef4c275a4362
permissions -rw-r--r--
Backed out changeset 82bc631a9e53 (bug 950240) a=backout CLOSED TREE

/* -*- 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 http://mozilla.org/MPL/2.0/. */

#ifndef nsEntityConverter_h__
#define nsEntityConverter_h__

#include "nsIEntityConverter.h"
#include "nsIStringBundle.h"
#include "nsCOMPtr.h"

#define kVERSION_STRING_LEN 128

class nsEntityVersionList
{
public:
    nsEntityVersionList() {}
    
    uint32_t mVersion;
    PRUnichar mEntityListName[kVERSION_STRING_LEN+1];
    nsCOMPtr<nsIStringBundle> mEntities;
};

class nsEntityConverter: public nsIEntityConverter
{
public:
	
	//
	// implementation methods
	//
	nsEntityConverter();
	virtual ~nsEntityConverter();

	//
	// nsISupports
	//
	NS_DECL_ISUPPORTS

	//
	// nsIEntityConverter
	//
	NS_IMETHOD ConvertUTF32ToEntity(uint32_t character, uint32_t entityVersion, char **_retval);
	NS_IMETHOD ConvertToEntity(PRUnichar character, uint32_t entityVersion, char **_retval);

	NS_IMETHOD ConvertToEntities(const PRUnichar *inString, uint32_t entityVersion, PRUnichar **_retval);

protected:

  // load a version property file and generate a version list (number/name pair)
  NS_IMETHOD LoadVersionPropertyFile();

  // map version number to version string
  const PRUnichar* GetVersionName(uint32_t versionNumber);

  // map version number to a string bundle
  nsIStringBundle* GetVersionBundleInstance(uint32_t versionNumber);

  // load a string bundle file
  already_AddRefed<nsIStringBundle> LoadEntityBundle(uint32_t version);


  nsEntityVersionList *mVersionList;            // array of version number/name pairs
  uint32_t mVersionListLength;                  // number of supported versions
};

#endif