source: NonGTP/Xerces/xerces/include/xercesc/util/regx/RegxUtil.hpp @ 358

Revision 358, 2.8 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2001,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Id: RegxUtil.hpp,v 1.5 2004/09/08 13:56:47 peiyongz Exp $
19 */
20
21#if !defined(REGXUTIL_HPP)
22#define REGXUTIL_HPP
23
24// ---------------------------------------------------------------------------
25//  Includes
26// ---------------------------------------------------------------------------
27#include <xercesc/util/XMLUniDefs.hpp>
28
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32class MemoryManager;
33
34class XMLUTIL_EXPORT RegxUtil {
35public:
36
37        // -----------------------------------------------------------------------
38    //  Constructors and destructors
39    // -----------------------------------------------------------------------
40        ~RegxUtil() {}
41
42        static XMLInt32 composeFromSurrogate(const XMLCh high, const XMLCh low);
43        static bool isEOLChar(const XMLCh);
44        static bool isWordChar(const XMLCh);
45        static bool isLowSurrogate(const XMLCh ch);
46        static bool isHighSurrogate(const XMLCh ch);
47        static XMLCh* decomposeToSurrogates(XMLInt32 ch,
48                                        MemoryManager* const manager);
49        static XMLCh* stripExtendedComment(const XMLCh* const expression,
50                                       MemoryManager* const manager = 0);
51
52private:
53        // -----------------------------------------------------------------------
54    //  Unimplemented constructors and operators
55    // -----------------------------------------------------------------------
56    RegxUtil();
57};
58
59
60inline bool RegxUtil::isEOLChar(const XMLCh ch) {
61
62        return (ch == chLF || ch == chCR || ch == chLineSeparator
63           || ch == chParagraphSeparator);
64}
65
66inline XMLInt32 RegxUtil::composeFromSurrogate(const XMLCh high, const XMLCh low) {
67
68        return 0x10000 + ((high - 0xD800) << 10) + (low - 0xDC00);
69}
70
71inline bool RegxUtil::isLowSurrogate(const XMLCh ch) {
72
73        return (ch & 0xFC00) == 0xDC00;
74}
75
76inline bool RegxUtil::isHighSurrogate(const XMLCh ch) {
77
78        return (ch & 0xFC00) == 0xD800;
79}
80
81inline bool RegxUtil::isWordChar(const XMLCh ch) {
82
83        if ((ch == chUnderscore)
84                || (ch >= chDigit_0 && ch <= chDigit_9)
85                || (ch >= chLatin_A && ch <= chLatin_Z)
86                || (ch >= chLatin_a && ch <= chLatin_z))
87                return true;
88
89        return false;
90}
91
92XERCES_CPP_NAMESPACE_END
93
94#endif
95
96/**
97  * End of file RegxUtil.hpp
98  */
Note: See TracBrowser for help on using the repository browser.