To string_view

This commit is contained in:
wozrer 2024-12-31 21:28:59 +03:00
parent 9058d32952
commit 10e80b624e

View File

@ -5,86 +5,86 @@
#pragma once
#include <exception>
#include <string>
#include <string_view>
class BaseException : public std::exception
{
public:
BaseException(const std::string &s) noexcept: m_s(s) {}
BaseException(const std::string_view &s) noexcept: m_s(s) {}
~BaseException() throw() = default;
virtual const char * what() const noexcept
{
return m_s.c_str();
return m_s.data();
}
protected:
std::string m_s;
std::string_view m_s;
};
class AlreadyExistsException : public BaseException {
public:
AlreadyExistsException(const std::string &s): BaseException(s) {}
AlreadyExistsException(const std::string_view &s): BaseException(s) {}
};
class VersionMismatchException : public BaseException {
public:
VersionMismatchException(const std::string &s): BaseException(s) {}
VersionMismatchException(const std::string_view &s): BaseException(s) {}
};
class FileNotGoodException : public BaseException {
public:
FileNotGoodException(const std::string &s): BaseException(s) {}
FileNotGoodException(const std::string_view &s): BaseException(s) {}
};
class DatabaseException : public BaseException {
public:
DatabaseException(const std::string &s): BaseException(s) {}
DatabaseException(const std::string_view &s): BaseException(s) {}
};
class SerializationError : public BaseException {
public:
SerializationError(const std::string &s): BaseException(s) {}
SerializationError(const std::string_view &s): BaseException(s) {}
};
class PacketError : public BaseException {
public:
PacketError(const std::string &s): BaseException(s) {}
PacketError(const std::string_view &s): BaseException(s) {}
};
class SettingNotFoundException : public BaseException {
public:
SettingNotFoundException(const std::string &s): BaseException(s) {}
SettingNotFoundException(const std::string_view &s): BaseException(s) {}
};
class ItemNotFoundException : public BaseException {
public:
ItemNotFoundException(const std::string &s): BaseException(s) {}
ItemNotFoundException(const std::string_view &s): BaseException(s) {}
};
class ServerError : public BaseException {
public:
ServerError(const std::string &s): BaseException(s) {}
ServerError(const std::string_view &s): BaseException(s) {}
};
class ClientStateError : public BaseException {
public:
ClientStateError(const std::string &s): BaseException(s) {}
ClientStateError(const std::string_view &s): BaseException(s) {}
};
class PrngException : public BaseException {
public:
PrngException(const std::string &s): BaseException(s) {}
PrngException(const std::string_view &s): BaseException(s) {}
};
class ShaderException : public BaseException {
public:
ShaderException(const std::string &s): BaseException(s) {}
ShaderException(const std::string_view &s): BaseException(s) {}
};
class ModError : public BaseException {
public:
ModError(const std::string &s): BaseException(s) {}
ModError(const std::string_view &s): BaseException(s) {}
};
@ -99,7 +99,7 @@ public:
"too much memory")
{}
InvalidNoiseParamsException(const std::string &s):
InvalidNoiseParamsException(const std::string_view &s):
BaseException(s)
{}
};
@ -110,7 +110,7 @@ public:
InvalidPositionException():
BaseException("Somebody tried to get/set something in a nonexistent position.")
{}
InvalidPositionException(const std::string &s):
InvalidPositionException(const std::string_view &s):
BaseException(s)
{}
};