source: icXML/icXML-devel/src/xercesc/util/regx/ASCIIRangeFactory.cpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 5.0 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: ASCIIRangeFactory.cpp 678879 2008-07-22 20:05:05Z amassari $
20 */
21
22// ---------------------------------------------------------------------------
23//  Includes
24// ---------------------------------------------------------------------------
25#include <xercesc/util/regx/ASCIIRangeFactory.hpp>
26#include <xercesc/util/regx/RegxDefs.hpp>
27#include <xercesc/util/regx/TokenFactory.hpp>
28#include <xercesc/util/regx/RangeToken.hpp>
29#include <xercesc/util/regx/RangeTokenMap.hpp>
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33// ---------------------------------------------------------------------------
34//  ASCIIRangeFactory: Constructors and Destructor
35// ---------------------------------------------------------------------------
36ASCIIRangeFactory::ASCIIRangeFactory()
37{
38}
39
40ASCIIRangeFactory::~ASCIIRangeFactory() {
41
42}
43
44// ---------------------------------------------------------------------------
45//  ASCIIRangeFactory: Range creation methods
46// ---------------------------------------------------------------------------
47void ASCIIRangeFactory::buildRanges(RangeTokenMap *rangeTokMap) {
48
49    if (fRangesCreated)
50        return;
51
52    if (!fKeywordsInitialized) {
53        initializeKeywordMap(rangeTokMap);
54    }
55
56    TokenFactory* tokFactory = rangeTokMap->getTokenFactory();
57
58    // Create space ranges
59    RangeToken* tok = tokFactory->createRange();
60    tok->addRange(chHTab, chHTab);
61    tok->addRange(chLF, chLF);
62    tok->addRange(chFF, chFF);
63    tok->addRange(chCR, chCR);
64    tok->addRange(chSpace, chSpace);
65
66    // Build the internal map.
67    tok->createMap();
68
69    rangeTokMap->setRangeToken(fgASCIISpace, tok);
70
71    tok = RangeToken::complementRanges(tok, tokFactory);
72
73    // Build the internal map.
74    tok->createMap();
75
76    rangeTokMap->setRangeToken(fgASCIISpace, tok , true);
77
78    // Create digits ranges
79    tok = tokFactory->createRange();
80    tok->addRange(chDigit_0, chDigit_9);
81
82    // Build the internal map.
83    tok->createMap();
84
85    rangeTokMap->setRangeToken(fgASCIIDigit, tok);
86
87    tok = RangeToken::complementRanges(tok, tokFactory);
88
89    // Build the internal map.
90    tok->createMap();
91
92    rangeTokMap->setRangeToken(fgASCIIDigit, tok , true);
93
94    // Create word ranges
95    tok = tokFactory->createRange();
96    tok->addRange(chDigit_0, chDigit_9);
97    tok->addRange(chLatin_A, chLatin_Z);
98    tok->addRange(chUnderscore, chUnderscore);
99    tok->addRange(chLatin_a, chLatin_z);
100    // Build the internal map.
101    tok->createMap();
102    rangeTokMap->setRangeToken(fgASCIIWord, tok);
103
104    tok = RangeToken::complementRanges(tok, tokFactory);
105    // Build the internal map.
106    tok->createMap();
107    rangeTokMap->setRangeToken(fgASCIIWord, tok , true);
108
109    // Create xdigit ranges
110    tok = tokFactory->createRange();
111    tok->addRange(chDigit_0, chDigit_9);
112    tok->addRange(chLatin_A, chLatin_F);
113    tok->addRange(chLatin_a, chLatin_a);
114    // Build the internal map.
115    tok->createMap();
116
117    rangeTokMap->setRangeToken(fgASCIIXDigit, tok);
118
119    tok = RangeToken::complementRanges(tok, tokFactory);
120    // Build the internal map.
121    tok->createMap();
122    rangeTokMap->setRangeToken(fgASCIIXDigit, tok , true);
123
124    // Create ascii ranges
125    tok = tokFactory->createRange();
126    tok->addRange(0x00, 0x7F);
127    // Build the internal map.
128    tok->createMap();
129    rangeTokMap->setRangeToken(fgASCII, tok);
130
131    tok = RangeToken::complementRanges(tok, tokFactory);
132    // Build the internal map.
133    tok->createMap();
134    rangeTokMap->setRangeToken(fgASCII, tok , true);
135
136    fRangesCreated = true;
137}
138
139// ---------------------------------------------------------------------------
140//  ASCIIRangeFactory: Range creation methods
141// ---------------------------------------------------------------------------
142void ASCIIRangeFactory::initializeKeywordMap(RangeTokenMap *rangeTokMap) {
143
144    if (fKeywordsInitialized)
145        return;
146
147    rangeTokMap->addKeywordMap(fgASCIISpace, fgASCIICategory);
148    rangeTokMap->addKeywordMap(fgASCIIDigit, fgASCIICategory);
149    rangeTokMap->addKeywordMap(fgASCIIWord, fgASCIICategory);
150    rangeTokMap->addKeywordMap(fgASCIIXDigit, fgASCIICategory);
151    rangeTokMap->addKeywordMap(fgASCII, fgASCIICategory);
152
153    fKeywordsInitialized = true;
154}
155
156XERCES_CPP_NAMESPACE_END
157
158/**
159  * End of file ASCIIRangeFactory.cpp
160  */
Note: See TracBrowser for help on using the repository browser.