Simon Rozman 45598f8ef8 Suppress wxWidgets code analysis warnings
Rather than addressing numerous code analysis warnings Microsoft Visual
Studio 2019 reports for wxWidgets upstream, disable code analysis for
the time being. But only for the wxWidgets part. We still want to know
what the code analysis has to say about our code.

Signed-off-by: Simon Rozman <simon@rozman.si>
2020-02-12 12:16:30 +01:00

127 lines
3.2 KiB
C

/*
Copyright 2016-2020 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common.h"
#include "crypto.h"
#include <codeanalysis\warnings.h>
#pragma warning(push)
#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
#include <wx/string.h>
#include <wx/xml/xml.h>
#pragma warning(pop)
/// \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("&lt;"));
break;
case wxS('>'):
escaped.append(wxS("&gt;"));
break;
case wxS('&'):
escaped.append(wxS("&amp;"));
break;
case wxS('\r'):
escaped.append(wxS("&#xD;"));
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("&lt;"));
break;
case wxS('>'):
escaped.append(wxS("&gt;"));
break;
case wxS('&'):
escaped.append(wxS("&amp;"));
break;
case wxS('\r'):
escaped.append(wxS("&#xD;"));
break;
case wxS('"'):
escaped.append(wxS("&quot;"));
break;
case wxS('\t'):
escaped.append(wxS("&#x9;"));
break;
case wxS('\n'):
escaped.append(wxS("&#xA;"));
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);
/// @}