Make enum wxHexDecodeMode scoped

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-01-04 11:31:07 +01:00
parent fb0277dbfb
commit 7f600693c2
3 changed files with 10 additions and 11 deletions

View File

@ -104,11 +104,11 @@ inline wxString wxHexEncode(const wxMemoryBuffer& buf)
/// Elements of this enum specify the possible behaviours of wxHexDecode() /// Elements of this enum specify the possible behaviours of wxHexDecode()
/// when an invalid character is encountered. /// when an invalid character is encountered.
/// ///
enum wxHexDecodeMode enum class wxHexDecodeMode
{ {
wxHexDecodeMode_Strict, ///< Normal behaviour: stop at any invalid characters Strict, ///< Normal behaviour: stop at any invalid characters
wxHexDecodeMode_SkipWS, ///< Skip whitespace characters SkipWS, ///< Skip whitespace characters
wxHexDecodeMode_Relaxed, ///< The most lenient behaviour: simply ignore all invalid characters Relaxed, ///< The most lenient behaviour: simply ignore all invalid characters
}; };
@ -146,7 +146,7 @@ inline size_t wxHexDecodedSize(size_t len)
/// latter case the \p posErr is filled with the position where the decoding /// latter case the \p posErr is filled with the position where the decoding
/// stopped if it is not NULL /// stopped if it is not NULL
/// ///
size_t WXEXTEND_API wxHexDecode(void *dst, size_t dstLen, const char *src, size_t srcLen = wxNO_LEN, wxHexDecodeMode mode = wxHexDecodeMode_Strict, size_t *posErr = NULL); size_t WXEXTEND_API wxHexDecode(void *dst, size_t dstLen, const char *src, size_t srcLen = wxNO_LEN, wxHexDecodeMode mode = wxHexDecodeMode::Strict, size_t *posErr = NULL);
/// ///
@ -167,7 +167,7 @@ size_t WXEXTEND_API wxHexDecode(void *dst, size_t dstLen, const char *src, size_
/// latter case the \p posErr is filled with the position where the decoding /// latter case the \p posErr is filled with the position where the decoding
/// stopped if it is not NULL /// stopped if it is not NULL
/// ///
inline size_t wxHexDecode(void *dst, size_t dstLen, const wxString& src, wxHexDecodeMode mode = wxHexDecodeMode_Strict, size_t *posErr = NULL) inline size_t wxHexDecode(void *dst, size_t dstLen, const wxString& src, wxHexDecodeMode mode = wxHexDecodeMode::Strict, size_t *posErr = NULL)
{ {
// don't use str.length() here as the ASCII buffer is shorter than it is for // don't use str.length() here as the ASCII buffer is shorter than it is for
// strings with embedded NULs // strings with embedded NULs
@ -190,7 +190,7 @@ inline size_t wxHexDecode(void *dst, size_t dstLen, const wxString& src, wxHexDe
/// ///
/// \returns Destination buffer with decoded data or an empty buffer if an error occured during decoding /// \returns Destination buffer with decoded data or an empty buffer if an error occured during decoding
/// ///
wxMemoryBuffer WXEXTEND_API wxHexDecode(const char *src, size_t srcLen = wxNO_LEN, wxHexDecodeMode mode = wxHexDecodeMode_Strict, size_t *posErr = NULL); wxMemoryBuffer WXEXTEND_API wxHexDecode(const char *src, size_t srcLen = wxNO_LEN, wxHexDecodeMode mode = wxHexDecodeMode::Strict, size_t *posErr = NULL);
/// ///
@ -206,7 +206,7 @@ wxMemoryBuffer WXEXTEND_API wxHexDecode(const char *src, size_t srcLen = wxNO_LE
/// ///
/// \returns Destination buffer with decoded data or an empty buffer if an error occured during decoding /// \returns Destination buffer with decoded data or an empty buffer if an error occured during decoding
/// ///
inline wxMemoryBuffer wxHexDecode(const wxString& src, wxHexDecodeMode mode = wxHexDecodeMode_Strict, size_t *posErr = NULL) inline wxMemoryBuffer wxHexDecode(const wxString& src, wxHexDecodeMode mode = wxHexDecodeMode::Strict, size_t *posErr = NULL)
{ {
// don't use str.length() here as the ASCII buffer is shorter than it for // don't use str.length() here as the ASCII buffer is shorter than it for
// strings with embedded NULs // strings with embedded NULs

View File

@ -37,7 +37,6 @@ enum wxHexValidatorStyle
}; };
#ifdef __VISUALC__ #ifdef __VISUALC__
// non dll-interface class 'xxx' used as base for dll-interface class 'yyy' // non dll-interface class 'xxx' used as base for dll-interface class 'yyy'
#pragma warning (push) #pragma warning (push)

View File

@ -71,8 +71,8 @@ size_t WXEXTEND_API wxHexDecode(void *dst_, size_t dstLen, const char *src, size
else if ( 'A' <= c && c <= 'F' ) in = (in << 4) | (c - 'A' + 10), n++; else if ( 'A' <= c && c <= 'F' ) in = (in << 4) | (c - 'A' + 10), n++;
else if ( 'a' <= c && c <= 'f' ) in = (in << 4) | (c - 'a' + 10), n++; else if ( 'a' <= c && c <= 'f' ) in = (in << 4) | (c - 'a' + 10), n++;
else { else {
if ( mode == wxHexDecodeMode_Relaxed || if ( mode == wxHexDecodeMode::Relaxed ||
mode == wxHexDecodeMode_SkipWS && isspace(c) ) mode == wxHexDecodeMode::SkipWS && isspace(c) )
continue; continue;
if ( posErr ) if ( posErr )