Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:30:11

0001 /*
0002 Open Asset Import Library (assimp)
0003 ----------------------------------------------------------------------
0004 
0005 Copyright (c) 2006-2024, assimp team
0006 
0007 
0008 All rights reserved.
0009 
0010 Redistribution and use of this software in source and binary forms,
0011 with or without modification, are permitted provided that the
0012 following conditions are met:
0013 
0014 * Redistributions of source code must retain the above
0015   copyright notice, this list of conditions and the
0016   following disclaimer.
0017 
0018 * Redistributions in binary form must reproduce the above
0019   copyright notice, this list of conditions and the
0020   following disclaimer in the documentation and/or other
0021   materials provided with the distribution.
0022 
0023 * Neither the name of the assimp team, nor the names of its
0024   contributors may be used to endorse or promote products
0025   derived from this software without specific prior
0026   written permission of the assimp team.
0027 
0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0039 
0040 ----------------------------------------------------------------------
0041 */
0042 
0043 #pragma once
0044 #ifndef INCLUDED_ASSIMP_XML_TOOLS_H
0045 #define INCLUDED_ASSIMP_XML_TOOLS_H
0046 
0047 #ifdef __GNUC__
0048 #   pragma GCC system_header
0049 #endif
0050 
0051 #include <string>
0052 
0053 namespace Assimp {
0054     // XML escape the 5 XML special characters (",',<,> and &) in |data|
0055     // Based on http://stackoverflow.com/questions/5665231
0056     std::string XMLEscape(const std::string& data) {
0057         std::string buffer;
0058 
0059         const size_t size = data.size();
0060         buffer.reserve(size + size / 8);
0061         for(size_t i = 0; i < size; ++i) {
0062             const char c = data[i];
0063             switch(c) {
0064                 case '&' :
0065                     buffer.append("&amp;");
0066                     break;
0067                 case '\"':
0068                     buffer.append("&quot;");
0069                     break;
0070                 case '\'':
0071                     buffer.append("&apos;");
0072                     break;
0073                 case '<' :
0074                     buffer.append("&lt;");
0075                     break;
0076                 case '>' :
0077                     buffer.append("&gt;");
0078                     break;
0079                 default:
0080                     buffer.append(&c, 1);
0081                     break;
0082             }
0083         }
0084         return buffer;
0085     }
0086 }
0087 
0088 #endif // INCLUDED_ASSIMP_XML_TOOLS_H