GME
13
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 /* 00019 * $Id: RegxUtil.cpp 678879 2008-07-22 20:05:05Z amassari $ 00020 */ 00021 00022 // --------------------------------------------------------------------------- 00023 // Includes 00024 // --------------------------------------------------------------------------- 00025 #include <xercesc/util/regx/RegxUtil.hpp> 00026 #include <xercesc/util/XMLString.hpp> 00027 00028 XERCES_CPP_NAMESPACE_BEGIN 00029 00030 XMLCh* RegxUtil::decomposeToSurrogates(XMLInt32 ch, 00031 MemoryManager* const manager) { 00032 00033 XMLCh* pszStr = (XMLCh*) manager->allocate(3 * sizeof(XMLCh));//new XMLCh[3]; 00034 00035 decomposeToSurrogates(ch, pszStr[0], pszStr[1]); 00036 00037 pszStr[2] = chNull; 00038 00039 return pszStr; 00040 } 00041 00042 00043 XMLCh* RegxUtil::stripExtendedComment(const XMLCh* const expression, 00044 MemoryManager* const manager) { 00045 00046 XMLCh* buffer = (manager) ? XMLString::replicate(expression, manager) 00047 : XMLString::replicate(expression); 00048 00049 if (buffer) 00050 { 00051 const XMLCh* inPtr = expression; 00052 XMLCh* outPtr = buffer; 00053 00054 while (*inPtr) { 00055 00056 XMLCh ch = *inPtr++; 00057 00058 if (ch == chFF || ch == chCR || ch == chLF 00059 || ch == chSpace || ch == chHTab) { 00060 continue; 00061 } 00062 00063 // Skips chracters between '#' and a line end. 00064 if (ch == chPound) { 00065 00066 while (*inPtr) { 00067 00068 ch = *inPtr++; 00069 if (ch == chLF || ch == chCR) 00070 break; 00071 } 00072 00073 continue; 00074 } 00075 00076 if (ch == chBackSlash && *inPtr) { 00077 00078 if ((ch = *inPtr++) == chPound || ch == chHTab || ch == chLF 00079 || ch == chFF || ch == chCR || ch == chSpace) { 00080 *outPtr++ = ch; 00081 } 00082 else { // Other escaped character. 00083 00084 *outPtr++ = chBackSlash; 00085 *outPtr++ = ch; 00086 } 00087 } 00088 else { // As is. 00089 *outPtr++ = ch; 00090 } 00091 } 00092 00093 *outPtr = chNull; // null terminate 00094 } 00095 00096 return buffer; 00097 } 00098 00099 XERCES_CPP_NAMESPACE_END 00100