Updates will be applied on October 27th between 12pm - 12:45pm EDT (UTC-0400). Gitlab may be slow during the maintenance window.

Commit 503e86c9 authored by Kitware Robot's avatar Kitware Robot Committed by Ben Boeckel
Browse files

utf8 2017-11-22 (e8de6037)

Code extracted from:

    https://gitlab.kitware.com/third-party/utfcpp.git

at commit e8de6037bec6c3151e9df2c50555122acd850c2a (for/vtk).
parent 3090f6b8
......@@ -8,3 +8,4 @@ another source tree.
* Rename the namespace to not conflict with external copies.
* Add `.gitattributes` to pass VTK's commit checks.
* Fix shadowing warnings.
* Use `noexcept` rather than `throw()` to avoid warnings in VTK.
......@@ -31,6 +31,18 @@ DEALINGS IN THE SOFTWARE.
#include "core.h"
#include <stdexcept>
#if __cplusplus >= 201103L
#define VTKUTF8_NOEXCEPT noexcept
#elif defined(_MSC_VER)
#if _MSC_VER >= 1900
#define VTKUTF8_NOEXCEPT noexcept
#else
#define VTKUTF8_NOEXCEPT throw()
#endif
#else
#define VTKUTF8_NOEXCEPT throw()
#endif
namespace vtk_utf8
{
// Base for the exceptions that may be thrown from the library
......@@ -42,7 +54,7 @@ namespace vtk_utf8
uint32_t cp;
public:
invalid_code_point(uint32_t _cp) : cp(_cp) {}
virtual const char* what() const throw() { return "Invalid code point"; }
virtual const char* what() const VTKUTF8_NOEXCEPT { return "Invalid code point"; }
uint32_t code_point() const {return cp;}
};
......@@ -50,7 +62,7 @@ namespace vtk_utf8
uint8_t u8;
public:
invalid_utf8 (uint8_t u) : u8(u) {}
virtual const char* what() const throw() { return "Invalid UTF-8"; }
virtual const char* what() const VTKUTF8_NOEXCEPT { return "Invalid UTF-8"; }
uint8_t utf8_octet() const {return u8;}
};
......@@ -58,13 +70,13 @@ namespace vtk_utf8
uint16_t u16;
public:
invalid_utf16 (uint16_t u) : u16(u) {}
virtual const char* what() const throw() { return "Invalid UTF-16"; }
virtual const char* what() const VTKUTF8_NOEXCEPT { return "Invalid UTF-16"; }
uint16_t utf16_word() const {return u16;}
};
class not_enough_room : public exception {
public:
virtual const char* what() const throw() { return "Not enough space"; }
virtual const char* what() const VTKUTF8_NOEXCEPT { return "Not enough space"; }
};
/// The library API - functions intended to be called by the users
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment