intl/unicharutil/nsEntityConverter.h
author Gerald Squelart <gsquelart@mozilla.com>
Thu, 26 May 2016 19:24:35 +1000
changeset 371291 89a24835ba7432bffb9c0c095a98a619a5750658
parent 261034 b42e82ef33d929c3894e77d45a6159b9db35edea
child 489668 cbb8fdf1daf98a15f7d57f6b08d273bdf96aa1a0
permissions -rw-r--r--
Bug 1271483 - p16. gtest for list-string functions - r?cpearce Because it is templated code inside a cpp, the test includes a copy of that code. When we make this more public, the test should then include the proper header instead. MozReview-Commit-ID: 3vOvaj5VVhm

/* -*- 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"

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

    //
    // nsISupports
    //
    NS_DECL_ISUPPORTS

    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:
    // map version number to a string bundle
    nsIStringBundle* GetVersionBundleInstance(uint32_t versionNumber);

    // load a string bundle file
    already_AddRefed<nsIStringBundle> LoadEntityBundle(const char *fileName);

    const char* kHTML40LATIN1 = "html40Latin1.properties";
    const char* kHTML40SYMBOLS = "html40Symbols.properties";
    const char* kHTML40SPECIAL = "html40Special.properties";
    const char* kMATHML20 = "mathml20.properties";
    nsCOMPtr<nsIStringBundle> mHTML40Latin1Bundle;
    nsCOMPtr<nsIStringBundle> mHTML40SymbolsBundle;
    nsCOMPtr<nsIStringBundle> mHTML40SpecialBundle;
    nsCOMPtr<nsIStringBundle> mMathML20Bundle;

    virtual ~nsEntityConverter();
};

#endif