Core/ErrorFlags: Turn this class into an inline class
This commit is contained in:
@@ -31,13 +31,15 @@ namespace Nz
|
||||
Error() = delete;
|
||||
~Error() = delete;
|
||||
|
||||
static ErrorModeFlags ApplyFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags);
|
||||
|
||||
static constexpr std::string_view GetCurrentFileRelativeToEngine(std::string_view file);
|
||||
static ErrorModeFlags GetFlags();
|
||||
static std::string GetLastError(std::string_view* file = nullptr, unsigned int* line = nullptr, std::string_view* function = nullptr);
|
||||
static unsigned int GetLastSystemErrorCode();
|
||||
static std::string GetLastSystemError(unsigned int code = GetLastSystemErrorCode());
|
||||
|
||||
static void SetFlags(ErrorModeFlags flags);
|
||||
static ErrorModeFlags SetFlags(ErrorModeFlags flags);
|
||||
|
||||
template<typename... Args> static void Trigger(ErrorType type, std::string_view error, Args&&... args);
|
||||
template<typename... Args> static void Trigger(ErrorType type, unsigned int line, std::string_view file, std::string_view function, std::string_view error, Args&&... args);
|
||||
|
||||
@@ -8,22 +8,21 @@
|
||||
#define NAZARA_CORE_ERRORFLAGS_HPP
|
||||
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API ErrorFlags
|
||||
class ErrorFlags
|
||||
{
|
||||
public:
|
||||
ErrorFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags = {});
|
||||
inline ErrorFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags = {});
|
||||
ErrorFlags(const ErrorFlags&) = delete;
|
||||
ErrorFlags(ErrorFlags&&) = delete;
|
||||
~ErrorFlags();
|
||||
inline ~ErrorFlags();
|
||||
|
||||
ErrorModeFlags GetPreviousFlags() const;
|
||||
inline ErrorModeFlags GetPreviousFlags() const;
|
||||
|
||||
void SetFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags = {});
|
||||
inline void SetFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags = {});
|
||||
|
||||
ErrorFlags& operator=(const ErrorFlags&) = delete;
|
||||
ErrorFlags& operator=(ErrorFlags&&) = delete;
|
||||
@@ -33,4 +32,6 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/ErrorFlags.inl>
|
||||
|
||||
#endif // NAZARA_CORE_ERRORFLAGS_HPP
|
||||
|
||||
60
include/Nazara/Core/ErrorFlags.inl
Normal file
60
include/Nazara/Core/ErrorFlags.inl
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \class Nz::ErrorFlags
|
||||
* \brief Core class that represents flags for error
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a ErrorFlags object with flags
|
||||
*
|
||||
* \param flags Flags for the error
|
||||
* \param replace Replace the entirely the old flag if true, else do a "OR"
|
||||
*/
|
||||
|
||||
inline ErrorFlags::ErrorFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags) :
|
||||
m_previousFlags(Error::ApplyFlags(orFlags, andFlags))
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Destructs the object and sets the old flag
|
||||
*/
|
||||
inline ErrorFlags::~ErrorFlags()
|
||||
{
|
||||
Error::SetFlags(m_previousFlags);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the previous flag
|
||||
* \return Previous flag
|
||||
*/
|
||||
inline ErrorModeFlags ErrorFlags::GetPreviousFlags() const
|
||||
{
|
||||
return m_previousFlags;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the flags
|
||||
*
|
||||
* \param flags Flags for the error
|
||||
* \param replace Replace the entirely the old flag if true, else do a "OR"
|
||||
*/
|
||||
inline void ErrorFlags::SetFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags)
|
||||
{
|
||||
ErrorModeFlags newFlags = m_previousFlags;
|
||||
newFlags |= orFlags;
|
||||
newFlags &= andFlags;
|
||||
|
||||
Error::SetFlags(newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user