The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
utf8transliterator.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * utf8transliterator.h - class UTF8Transliterator: a Filter to
4  * transliterate a UTF8 text stream into
5  * an alternate script. e.g., Hebrew to Latin
6  *
7  * $Id: utf8transliterator.h 3786 2020-08-30 11:35:14Z scribe $
8  *
9  * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
10  * CrossWire Bible Society
11  * P. O. Box 2528
12  * Tempe, AZ 85280-2528
13  *
14  * This program is free software; you can redistribute it and/or modify it
15  * under the terms of the GNU General Public License as published by the
16  * Free Software Foundation version 2.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * General Public License for more details.
22  *
23  */
24 
25 #ifndef UTF8TRANSLITERATOR_H
26 #define UTF8TRANSLITERATOR_H
27 
29 /*one-way (to) transliterators*/
31 /*two-way transliterators*/
33 /*SE_TENGWAR, SE_CIRTH,*/
34 /*one-way (from) transliterators*/
36 };
37 
38 #define NUMSCRIPTS 49
39 #define NUMTARGETSCRIPTS 2 //NUMSCRIPTS-3//6
40 
41 #include <swoptfilter.h>
42 
43 #include <unicode/unistr.h>
44 
45 #include <unicode/translit.h>
46 
47 #include <defs.h>
48 #include <map>
49 
51 
52 class SWModule;
53 
54 struct SWTransData {
55  icu::UnicodeString resource;
56  UTransDirection dir;
57 };
58 typedef std::map<const icu::UnicodeString, SWTransData> SWTransMap;
59 typedef std::pair<icu::UnicodeString, SWTransData> SWTransPair;
60 
64 
65 private:
66  unsigned char option;
67 
68  static const char optionstring[NUMTARGETSCRIPTS][16];
69 
70  static const char optName[];
71  static const char optTip[];
73 
74 #ifdef ICU_CUSTOM_RESOURCE_BUILDING
75  static const char SW_RB_RULE_BASED_IDS[];
76  static const char SW_RB_RULE[];
77  static const char SW_RESDATA[];
78  static SWTransMap transMap;
79  UErrorCode utf8status;
80 
81  void load(UErrorCode &status);
82  void registerTrans(const UnicodeString& ID, const UnicodeString& resource, UTransDirection dir, UErrorCode &status);
83  bool checkTrans(const UnicodeString& ID, UErrorCode &status);
84 #endif
85  bool addTrans(const char* newTrans, SWBuf* transList);
86  icu::Transliterator *createTrans(const icu::UnicodeString& ID, UTransDirection dir, UErrorCode &status);
87 
88 public:
91  virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0);
92  virtual const char *getOptionName() { return optName; }
93  virtual const char *getOptionTip() { return optTip; }
94  virtual void setOptionValue(const char *ival);
95  virtual const char *getOptionValue();
96  virtual StringList getOptionValues() { return options; }
97 };
98 
100 #endif
#define SWORD_NAMESPACE_START
Definition: defs.h:39
Definition: swbuf.h:47
#define SWDLLEXPORT
Definition: defs.h:171
SWText * module
Definition: osis2mod.cpp:105
scriptEnum
virtual const char * getOptionTip()
std::list< SWBuf > StringList
Definition: swmodule.cpp:91
UTransDirection dir
const char * optName
Definition: swoptfilter.h:51
std::map< const icu::UnicodeString, SWTransData > SWTransMap
virtual StringList getOptionValues()
virtual char processText(SWBuf &text, const SWKey *key=0, const SWModule *module=0)=0
#define NUMTARGETSCRIPTS
virtual const char * getOptionName()
virtual void setOptionValue(const char *ival)
Definition: swoptfilter.cpp:52
const char * optTip
Definition: swoptfilter.h:52
std::pair< icu::UnicodeString, SWTransData > SWTransPair
#define SWORD_NAMESPACE_END
Definition: defs.h:40
virtual const char * getOptionValue()
Definition: swoptfilter.cpp:62
Definition: swkey.h:77
icu::UnicodeString resource