// --------------------------------------------------------------------------- // BlockRangeFactory: Range creation methods // --------------------------------------------------------------------------- void BlockRangeFactory::buildRanges() { if (fRangesCreated) return; if (!fKeywordsInitialized) { initializeKeywordMap(); } RangeTokenMap* rangeTokMap = RangeTokenMap::instance(); TokenFactory* tokFactory = rangeTokMap->getTokenFactory(); //for performance, once the desired specials and private use are found //don't need to compareString anymore bool foundSpecial = false; bool foundPrivate = false; for (int i=0; i < BLOCKNAMESIZE; i++) { RangeToken* tok = tokFactory->createRange(); tok->addRange(blockRanges[i*2], blockRanges[(i*2)+1]); if (!foundSpecial && XMLString::equals((XMLCh*)fgBlockNames[i] , (XMLCh*) fgBlockIsSpecials)) { tok->addRange(0xFFF0, 0xFFFD); foundSpecial = true; } if (!foundPrivate && XMLString::equals((XMLCh*)fgBlockNames[i] , (XMLCh*) fgBlockIsPrivateUse)) { tok->addRange(0xF0000, 0xFFFFD); tok->addRange(0x100000, 0x10FFFD); foundPrivate = true; } rangeTokMap->setRangeToken(fgBlockNames[i], tok); } fRangesCreated = true; }
// --------------------------------------------------------------------------- // BlockRangeFactory: Range creation methods // --------------------------------------------------------------------------- void BlockRangeFactory::initializeKeywordMap() { if (fKeywordsInitialized) return; RangeTokenMap* rangeTokMap = RangeTokenMap::instance(); for (int i=0; i< BLOCKNAMESIZE; i++) { rangeTokMap->addKeywordMap(fgBlockNames[i], fgBlockCategory); } fKeywordsInitialized = true; }
// --------------------------------------------------------------------------- // ASCIIRangeFactory: Range creation methods // --------------------------------------------------------------------------- void ASCIIRangeFactory::initializeKeywordMap() { if (fKeywordsInitialized) return; RangeTokenMap* rangeTokMap = RangeTokenMap::instance(); rangeTokMap->addKeywordMap(fgASCIISpace, fgASCIICategory); rangeTokMap->addKeywordMap(fgASCIIDigit, fgASCIICategory); rangeTokMap->addKeywordMap(fgASCIIWord, fgASCIICategory); rangeTokMap->addKeywordMap(fgASCIIXDigit, fgASCIICategory); rangeTokMap->addKeywordMap(fgASCII, fgASCIICategory); fKeywordsInitialized = true; }
// --------------------------------------------------------------------------- // ASCIIRangeFactory: Range creation methods // --------------------------------------------------------------------------- void ASCIIRangeFactory::buildRanges() { if (fRangesCreated) return; if (!fKeywordsInitialized) { initializeKeywordMap(); } RangeTokenMap* rangeTokMap = RangeTokenMap::instance(); TokenFactory* tokFactory = rangeTokMap->getTokenFactory(); // Create space ranges RangeToken* tok = tokFactory->createRange(); tok->addRange(chHTab, chHTab); tok->addRange(chLF, chLF); tok->addRange(chFF, chFF); tok->addRange(chCR, chCR); tok->addRange(chSpace, chSpace); rangeTokMap->setRangeToken(fgASCIISpace, tok); // Create digits ranges tok = tokFactory->createRange(); tok->addRange(chDigit_0, chDigit_9); rangeTokMap->setRangeToken(fgASCIIDigit, tok); // Create word ranges tok = tokFactory->createRange(); tok->addRange(chDigit_0, chDigit_9); tok->addRange(chLatin_A, chLatin_Z); tok->addRange(chUnderscore, chUnderscore); tok->addRange(chLatin_a, chLatin_z); rangeTokMap->setRangeToken(fgASCIIWord, tok); // Create xdigit ranges tok = tokFactory->createRange(); tok->addRange(chDigit_0, chDigit_9); tok->addRange(chLatin_A, chLatin_F); tok->addRange(chLatin_a, chLatin_a); rangeTokMap->setRangeToken(fgASCIIXDigit, tok); // Create ascii ranges tok = tokFactory->createRange(); tok->addRange(0x00, 0x7F); rangeTokMap->setRangeToken(fgASCII, tok); fRangesCreated = true; }