1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/unicharutil/src/nsEntityConverter.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 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 nsEntityConverter_h__ 1.10 +#define nsEntityConverter_h__ 1.11 + 1.12 +#include "nsIEntityConverter.h" 1.13 +#include "nsIStringBundle.h" 1.14 +#include "nsCOMPtr.h" 1.15 + 1.16 +#define kVERSION_STRING_LEN 128 1.17 + 1.18 +class nsEntityVersionList 1.19 +{ 1.20 +public: 1.21 + nsEntityVersionList() {} 1.22 + 1.23 + uint32_t mVersion; 1.24 + char16_t mEntityListName[kVERSION_STRING_LEN+1]; 1.25 + nsCOMPtr<nsIStringBundle> mEntities; 1.26 +}; 1.27 + 1.28 +class nsEntityConverter: public nsIEntityConverter 1.29 +{ 1.30 +public: 1.31 + 1.32 + // 1.33 + // implementation methods 1.34 + // 1.35 + nsEntityConverter(); 1.36 + virtual ~nsEntityConverter(); 1.37 + 1.38 + // 1.39 + // nsISupports 1.40 + // 1.41 + NS_DECL_ISUPPORTS 1.42 + 1.43 + // 1.44 + // nsIEntityConverter 1.45 + // 1.46 + NS_IMETHOD ConvertUTF32ToEntity(uint32_t character, uint32_t entityVersion, char **_retval); 1.47 + NS_IMETHOD ConvertToEntity(char16_t character, uint32_t entityVersion, char **_retval); 1.48 + 1.49 + NS_IMETHOD ConvertToEntities(const char16_t *inString, uint32_t entityVersion, char16_t **_retval); 1.50 + 1.51 +protected: 1.52 + 1.53 + // load a version property file and generate a version list (number/name pair) 1.54 + NS_IMETHOD LoadVersionPropertyFile(); 1.55 + 1.56 + // map version number to version string 1.57 + const char16_t* GetVersionName(uint32_t versionNumber); 1.58 + 1.59 + // map version number to a string bundle 1.60 + nsIStringBundle* GetVersionBundleInstance(uint32_t versionNumber); 1.61 + 1.62 + // load a string bundle file 1.63 + already_AddRefed<nsIStringBundle> LoadEntityBundle(uint32_t version); 1.64 + 1.65 + 1.66 + nsEntityVersionList *mVersionList; // array of version number/name pairs 1.67 + uint32_t mVersionListLength; // number of supported versions 1.68 +}; 1.69 + 1.70 +#endif