mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-03-21 14:49:54 +01:00
Move the ConversionError class
This commit is contained in:
parent
a121c62c3b
commit
ced7b0c993
src/common
@ -5,7 +5,7 @@
|
||||
|
||||
#include "String.h"
|
||||
|
||||
std::string ByteString::ConversionError::formatError(ByteString::value_type const *at, ByteString::value_type const *upto)
|
||||
ByteString ConversionError::formatError(ByteString::value_type const *at, ByteString::value_type const *upto)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Could not convert sequence to UTF-8:";
|
||||
@ -77,7 +77,7 @@ ByteString String::ToUtf8() const
|
||||
}
|
||||
else if(result == std::codecvt_base::error)
|
||||
{
|
||||
throw ByteString::ConversionError(true);
|
||||
throw ConversionError(true);
|
||||
}
|
||||
else if(result == std::codecvt_base::partial)
|
||||
{
|
||||
|
@ -99,14 +99,6 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
class ConversionError : public std::runtime_error
|
||||
{
|
||||
static std::string formatError(value_type const *at, value_type const *upto);
|
||||
public:
|
||||
inline ConversionError(value_type const *at, value_type const *upto): std::runtime_error(formatError(at, upto)) {}
|
||||
inline ConversionError(bool to): std::runtime_error(to ? "Could not convert to UTF-8" : "Could not convert from UTF-8") {}
|
||||
};
|
||||
|
||||
String FromUtf8(bool ignoreError = true) const;
|
||||
inline String FromAscii() const;
|
||||
|
||||
@ -243,4 +235,13 @@ inline ByteString String::ToAscii() const
|
||||
destination[i] = ByteString::value_type(operator[](i));
|
||||
return destination;
|
||||
}
|
||||
|
||||
class ConversionError : public std::runtime_error
|
||||
{
|
||||
static ByteString formatError(ByteString::value_type const *at, ByteString::value_type const *upto);
|
||||
public:
|
||||
inline ConversionError(ByteString::value_type const *at, ByteString::value_type const *upto): std::runtime_error(formatError(at, upto)) {}
|
||||
inline ConversionError(bool to): std::runtime_error(to ? "Could not convert to UTF-8" : "Could not convert from UTF-8") {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user