/* Copyright 2016-2018 Amebis Copyright 2016 GÉANT This file is part of wxExtend. wxExtend is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. wxExtend is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with wxExtend. If not, see . */ #pragma once #include "common.h" #include "crypto.h" #include #include /// \addtogroup wxExtend /// @{ /// /// Escapes text string for XML insertion /// /// \param[in] str Text string /// \returns Escaped string /// inline wxString wxXmlEscapeText(_In_ const wxString& str) { wxString escaped; escaped.reserve(str.length()); for (auto i = str.begin(); i != str.end(); ++i) { const wxChar c = *i; switch (c) { case wxS('<'): escaped.append(wxS("<")); break; case wxS('>'): escaped.append(wxS(">")); break; case wxS('&'): escaped.append(wxS("&")); break; case wxS('\r'): escaped.append(wxS(" ")); break; default: escaped.append(c); } } return escaped; } /// /// Escapes attribute value string for XML insertion /// /// \param[in] str Attribute value /// /// \returns Escaped string /// inline wxString wxXmlEscapeAttr(_In_ const wxString& str) { wxString escaped; escaped.reserve(str.length()); for (auto i = str.begin(); i != str.end(); ++i) { const wxChar c = *i; switch (c) { case wxS('<'): escaped.append(wxS("<")); break; case wxS('>'): escaped.append(wxS(">")); break; case wxS('&'): escaped.append(wxS("&")); break; case wxS('\r'): escaped.append(wxS(" ")); break; case wxS('"'): escaped.append(wxS(""")); break; case wxS('\t'): escaped.append(wxS(" ")); break; case wxS('\n'): escaped.append(wxS(" ")); break; default: escaped.append(c); } } return escaped; } /// /// Calculates hash of the node and all its children /// /// \param[in] hash Handle of a hash object /// \param[in] node Root node /// /// bool WXEXTEND_API wxXmlHashNode(_In_ wxCryptoHash &hash, _In_ const wxXmlNode *node); /// @}