intl/unicharutil/nsEntityConverter.h
author Mike Hommey <mh+mozilla@glandium.org>
Thu, 26 Mar 2015 12:07:17 +0900
changeset 258314 fc1e894eec2fbd34b745cd94f505080427d24705
parent 257987 a20c7910a82fa2df2f3398c1108d102bac9128b0
child 271927 b42e82ef33d929c3894e77d45a6159b9db35edea
permissions -rw-r--r--
Bug 1147207 - Add a ComposedFinder class that acts like a FileFinder proxy over multiple FileFinders. r=gps, a=sledru

/* -*- 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;
    char16_t mEntityListName[kVERSION_STRING_LEN+1];
    nsCOMPtr<nsIStringBundle> mEntities;
};

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

	//
	// nsISupports
	//
	NS_DECL_ISUPPORTS

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

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

protected:

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

  // map version number to version string
  const char16_t* 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

  virtual ~nsEntityConverter();
};

#endif