From f3d931aa7cfaf96baef8383b59a8938779541ee7 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Thu, 15 Aug 2024 18:35:34 +0200 Subject: [IMP] Moved source code into dev/ folder. Signed-off-by: Amlal EL Mahrouss --- dev/Kernel/NewKit/ErrorOr.hxx | 72 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 dev/Kernel/NewKit/ErrorOr.hxx (limited to 'dev/Kernel/NewKit/ErrorOr.hxx') diff --git a/dev/Kernel/NewKit/ErrorOr.hxx b/dev/Kernel/NewKit/ErrorOr.hxx new file mode 100644 index 00000000..ae2763b2 --- /dev/null +++ b/dev/Kernel/NewKit/ErrorOr.hxx @@ -0,0 +1,72 @@ +/* + * ======================================================== + * + * Kernel + * Copyright ZKA Technologies., all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include +#include + +namespace Kernel +{ + using ErrorT = UInt; + + template + class ErrorOr final + { + public: + ErrorOr() = default; + ~ErrorOr() = default; + + public: + explicit ErrorOr(Int32 err) + : mId(err) + { + } + + explicit ErrorOr(nullPtr Null) + { + } + + explicit ErrorOr(T Class) + : mRef(Class, true) + { + } + + ErrorOr& operator=(const ErrorOr&) = default; + ErrorOr(const ErrorOr&) = default; + + ErrorOr& operator=(const Ref& refErr) + { + mRef = refErr; + return *this; + } + + Ref& Leak() + { + return mRef; + } + + Int32 Error() + { + return mId; + } + + operator bool() + { + return mRef; + } + + private: + Ref mRef; + Int32 mId{0}; + }; + + using ErrorOrAny = ErrorOr; + +} // namespace Kernel -- cgit v1.2.3