omni/core/Result.h
File members: omni/core/Result.h
// Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once
#include "../../carb/Defines.h"
#include "OmniAttr.h"
#include <cstdint>
namespace omni
{
namespace core
{
using Result OMNI_ATTR("constant, prefix=kResult") = std::int32_t;
#define OMNI_SUCCEEDED(x_) ((x_) >= 0)
#define OMNI_FAILED(x_) ((x_) < 0)
#define OMNI_RETURN_IF_FAILED(x_) \
do \
{ \
auto result = (x_); \
if (OMNI_FAILED(result)) \
{ \
return result; \
} \
} while (0)
constexpr Result kResultSuccess = 0;
constexpr Result kResultNotImplemented = 0x80004001;
constexpr Result kResultOperationAborted = 0x80004004;
constexpr Result kResultFail = 0x80004005;
constexpr Result kResultNotFound = 0x80070002;
constexpr Result kResultAccessDenied = 0x80070005;
constexpr Result kResultOutOfMemory = 0x8007000E;
constexpr Result kResultNotSupported = 0x80070032;
constexpr Result kResultInvalidArgument = 0x80070057;
constexpr Result kResultInvalidState = 0x80070004;
constexpr Result kResultVersionCheckFailure = 0x80070283;
constexpr Result kResultVersionParseError = 0x80070309;
constexpr Result kResultInsufficientBuffer = 0x8007007A;
constexpr Result kResultTryAgain = 0x8007106B;
constexpr Result kResultInterrupted = 0xa4310001;
constexpr Result kResultNoInterface = 0x80004002;
constexpr Result kResultNullPointer = 0x80004003;
constexpr Result kResultAlreadyExists = 0x80030050;
constexpr Result kResultInvalidOperation = 0x800710DD;
constexpr Result kResultNoMoreItems = 0x8009002A;
constexpr Result kResultInvalidIndex = 0x80091008;
constexpr Result kResultNotEnoughData = 0x80290101;
constexpr Result kResultTooMuchData = 0x80290102;
constexpr Result kResultInvalidDataType = 0x8031000B;
constexpr Result kResultInvalidDataSize = 0x8031000C;
// clang-format off
#define OMNI_RESULT_CODE_LIST(item_) \
/* (symbol, snek_symbol, message) */ \
item_(Success, success, "operation succeeded") \
item_(NotImplemented, not_implemented, "not implemented") \
item_(OperationAborted, operation_aborted, "aborted") \
item_(Fail, fail, "failure") \
item_(NotFound, not_found, "not found") \
item_(AccessDenied, access_denied, "access denied") \
item_(OutOfMemory, out_of_memory, "out of memory") \
item_(NotSupported, not_supported, "not supported") \
item_(InvalidArgument, invalid_argument, "invalid argument") \
item_(InvalidState, invalid_state, "invalid state") \
item_(VersionCheckFailure, version_check_failure, "version check failure") \
item_(VersionParseError, version_parse_error, "version parse error") \
item_(InsufficientBuffer, insufficient_buffer, "insufficient buffer") \
item_(TryAgain, try_again, "try again") \
item_(Interrupted, interrupted, "interrupted") \
item_(NoInterface, no_interface, "no interface") \
item_(NullPointer, null_pointer, "null pointer") \
item_(AlreadyExists, already_exists, "already exists") \
item_(InvalidOperation, invalid_operation, "invalid operation") \
item_(NoMoreItems, no_more_items, "no more items") \
item_(InvalidIndex, invalid_index, "invalid index") \
item_(NotEnoughData, not_enough_data, "not enough data") \
item_(TooMuchData, too_much_data, "too much data") \
item_(InvalidDataType, invalid_data_type, "invalid data type") \
item_(InvalidDataSize, invalid_data_size, "invalid data size")
// clang-format on
} // namespace core
} // namespace omni