1 /* 2 * Hunt - A refined core library for D programming language. 3 * 4 * Copyright (C) 2018-2019 HuntLabs 5 * 6 * Website: https://www.huntlabs.net/ 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.text.CharacterData.CharacterData; 13 14 abstract class CharacterData { 15 abstract int getProperties(int ch); 16 abstract int getType(int ch); 17 abstract bool isWhitespace(int ch); 18 abstract bool isMirrored(int ch); 19 abstract bool isJavaIdentifierStart(int ch); 20 abstract bool isJavaIdentifierPart(int ch); 21 abstract bool isUnicodeIdentifierStart(int ch); 22 abstract bool isUnicodeIdentifierPart(int ch); 23 abstract bool isIdentifierIgnorable(int ch); 24 abstract int toLowerCase(int ch); 25 abstract int toUpperCase(int ch); 26 abstract int toTitleCase(int ch); 27 abstract int digit(int ch, int radix); 28 abstract int getNumericValue(int ch); 29 abstract byte getDirectionality(int ch); 30 31 //need to implement for JSR204 32 int toUpperCaseEx(int ch) { 33 return toUpperCase(ch); 34 } 35 36 char[] toUpperCaseCharArray(int ch) { 37 return null; 38 } 39 40 bool isOtherLowercase(int ch) { 41 return false; 42 } 43 44 bool isOtherUppercase(int ch) { 45 return false; 46 } 47 48 bool isOtherAlphabetic(int ch) { 49 return false; 50 } 51 52 bool isIdeographic(int ch) { 53 return false; 54 } 55 56 // Character <= 0xff (basic latin) is handled by internal fast-path 57 // to avoid initializing large tables. 58 // Note: performance of this "fast-path" code may be sub-optimal 59 // in negative cases for some accessors due to complicated ranges. 60 // Should revisit after optimization of table initialization. 61 62 // static final CharacterData of(int ch) { 63 // if (ch >>> 8 == 0) { // fast-path 64 // return CharacterDataLatin1.instance; 65 // } else { 66 // switch(ch >>> 16) { //plane 00-16 67 // case(0): 68 // return CharacterData00.instance; 69 // case(1): 70 // return CharacterData01.instance; 71 // case(2): 72 // return CharacterData02.instance; 73 // case(14): 74 // return CharacterData0E.instance; 75 // case(15): // Private Use 76 // case(16): // Private Use 77 // return CharacterDataPrivateUse.instance; 78 // default: 79 // return CharacterDataUndefined.instance; 80 // } 81 // } 82 // } 83 }