1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unesctrn.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,110 @@ 1.4 +/* 1.5 + ********************************************************************** 1.6 + * Copyright (c) 2001-2007, International Business Machines 1.7 + * Corporation and others. All Rights Reserved. 1.8 + ********************************************************************** 1.9 + * Date Name Description 1.10 + * 11/20/2001 aliu Creation. 1.11 + ********************************************************************** 1.12 + */ 1.13 +#ifndef UNESCTRN_H 1.14 +#define UNESCTRN_H 1.15 + 1.16 +#include "unicode/utypes.h" 1.17 + 1.18 +#if !UCONFIG_NO_TRANSLITERATION 1.19 + 1.20 +#include "unicode/translit.h" 1.21 + 1.22 +U_NAMESPACE_BEGIN 1.23 + 1.24 +/** 1.25 + * A transliterator that converts Unicode escape forms to the 1.26 + * characters they represent. Escape forms have a prefix, a suffix, a 1.27 + * radix, and minimum and maximum digit counts. 1.28 + * 1.29 + * <p>This class is package private. It registers several standard 1.30 + * variants with the system which are then accessed via their IDs. 1.31 + * 1.32 + * @author Alan Liu 1.33 + */ 1.34 +class UnescapeTransliterator : public Transliterator { 1.35 + 1.36 + private: 1.37 + 1.38 + /** 1.39 + * The encoded pattern specification. The pattern consists of 1.40 + * zero or more forms. Each form consists of a prefix, suffix, 1.41 + * radix, minimum digit count, and maximum digit count. These 1.42 + * values are stored as a five character header. That is, their 1.43 + * numeric values are cast to 16-bit characters and stored in the 1.44 + * string. Following these five characters, the prefix 1.45 + * characters, then suffix characters are stored. Each form thus 1.46 + * takes n+5 characters, where n is the total length of the prefix 1.47 + * and suffix. The end is marked by a header of length one 1.48 + * consisting of the character END. 1.49 + */ 1.50 + UChar* spec; // owned; may not be NULL 1.51 + 1.52 + public: 1.53 + 1.54 + /** 1.55 + * Registers standard variants with the system. Called by 1.56 + * Transliterator during initialization. 1.57 + */ 1.58 + static void registerIDs(); 1.59 + 1.60 + /** 1.61 + * Constructor. Takes the encoded spec array (does not adopt it). 1.62 + * @param ID the string identifier for this transliterator 1.63 + * @param spec the encoded spec array 1.64 + */ 1.65 + UnescapeTransliterator(const UnicodeString& ID, 1.66 + const UChar *spec); 1.67 + 1.68 + /** 1.69 + * Copy constructor. 1.70 + */ 1.71 + UnescapeTransliterator(const UnescapeTransliterator&); 1.72 + 1.73 + /** 1.74 + * Destructor. 1.75 + */ 1.76 + virtual ~UnescapeTransliterator(); 1.77 + 1.78 + /** 1.79 + * Transliterator API. 1.80 + */ 1.81 + virtual Transliterator* clone() const; 1.82 + 1.83 + /** 1.84 + * ICU "poor man's RTTI", returns a UClassID for the actual class. 1.85 + */ 1.86 + virtual UClassID getDynamicClassID() const; 1.87 + 1.88 + /** 1.89 + * ICU "poor man's RTTI", returns a UClassID for this class. 1.90 + */ 1.91 + U_I18N_API static UClassID U_EXPORT2 getStaticClassID(); 1.92 + 1.93 + protected: 1.94 + 1.95 + /** 1.96 + * Implements {@link Transliterator#handleTransliterate}. 1.97 + * @param text the buffer holding transliterated and 1.98 + * untransliterated text 1.99 + * @param offset the start and limit of the text, the position 1.100 + * of the cursor, and the start and limit of transliteration. 1.101 + * @param incremental if true, assume more text may be coming after 1.102 + * pos.contextLimit. Otherwise, assume the text is complete. 1.103 + */ 1.104 + virtual void handleTransliterate(Replaceable& text, UTransPosition& offset, 1.105 + UBool isIncremental) const; 1.106 + 1.107 +}; 1.108 + 1.109 +U_NAMESPACE_END 1.110 + 1.111 +#endif /* #if !UCONFIG_NO_TRANSLITERATION */ 1.112 + 1.113 +#endif