OW_XMLEscape.cpp

Go to the documentation of this file.
00001 /* Generated by re2c 0.5 on Wed Jul 25 22:09:44 2001 */
00002 #line 1 "OW_XMLEscape.re"
00003 /*******************************************************************************
00004 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00005 *
00006 * Redistribution and use in source and binary forms, with or without
00007 * modification, are permitted provided that the following conditions are met:
00008 *
00009 *  - Redistributions of source code must retain the above copyright notice,
00010 *    this list of conditions and the following disclaimer.
00011 *
00012 *  - Redistributions in binary form must reproduce the above copyright notice,
00013 *    this list of conditions and the following disclaimer in the documentation
00014 *    and/or other materials provided with the distribution.
00015 *
00016 *  - Neither the name of Vintela, Inc. nor the names of its
00017 *    contributors may be used to endorse or promote products derived from this
00018 *    software without specific prior written permission.
00019 *
00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00024 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00025 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00026 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00029 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030 * POSSIBILITY OF SUCH DAMAGE.
00031 *******************************************************************************/
00032 
00037 /* a simple lexical scanner to escape xml */
00038 #include "OW_config.h"
00039 #include "OW_XMLEscape.hpp"
00040 #include "OW_StringBuffer.hpp"
00041 
00042 namespace OW_NAMESPACE
00043 {
00044 
00045 String XMLEscape(const char* escapedText, unsigned len)
00046 {
00047    StringBuffer rval(len * 2);
00048    const char* begin = escapedText;
00049    #define YYCTYPE char
00050    #define YYCURSOR        begin
00051    #define YYLIMIT         begin
00052    #define YYFILL(n)
00053 start:
00054    {
00055    YYCTYPE yych;
00056    goto yy0;
00057    ++YYCURSOR;
00058 yy0:
00059    if (YYLIMIT == YYCURSOR) YYFILL(1);
00060    yych = *YYCURSOR;
00061    switch (yych){
00062    case '\000':   goto yy20;
00063    case '\t':  goto yy16;
00064    case '\n':  goto yy14;
00065    case '\r':  goto yy12;
00066    case '"':   goto yy8;
00067    case '&':   goto yy6;
00068    case '\'':  goto yy10;
00069    case '<':   goto yy4;
00070    case '>':   goto yy2;
00071    default: goto yy18;
00072    }
00073 yy2:  yych = *++YYCURSOR;
00074 #line 57
00075    { rval += "&gt;"; goto start; }
00076 yy4:  yych = *++YYCURSOR;
00077 #line 58
00078    { rval += "&lt;"; goto start; }
00079 yy6:  yych = *++YYCURSOR;
00080 #line 59
00081    { rval += "&amp;"; goto start; }
00082 yy8:  yych = *++YYCURSOR;
00083 #line 60
00084    { rval += "&quot;"; goto start; }
00085 yy10: yych = *++YYCURSOR;
00086 #line 61
00087    { rval += "&apos;"; goto start; }
00088 yy12: yych = *++YYCURSOR;
00089 #line 62
00090    { rval += "&#13;"; goto start; }
00091 yy14: yych = *++YYCURSOR;
00092 #line 63
00093    { rval += "&#10;"; goto start; }
00094 yy16: yych = *++YYCURSOR;
00095 #line 64
00096    { rval += "&#9;"; goto start; }
00097 yy18: yych = *++YYCURSOR;
00098 #line 65
00099    { rval += *(YYCURSOR-1); goto start; }
00100 yy20: 
00101 #line 66
00102    { return rval.releaseString(); }
00103 }
00104 #line 67
00105    return rval.releaseString();
00106 }
00107 
00108 } // end namespace OW_NAMESPACE
00109 

Generated on Thu Feb 9 08:48:18 2006 for openwbem by  doxygen 1.4.6