Error1.h#
Fully qualified name: carb/detail/Error1.h
File members: carb/detail/Error1.h
// SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once
// For v1, redefine carb_ErrorApi_latest to be 1.1
#ifndef carb_ErrorApi_latest
# error Must include via ../Error.h
#endif
#if CARB_VERSION_ATLEAST(carb_ErrorApi, 2, 0)
# error Version too high to be included
#endif
#include "../Defines.h"
#include "../Interface.h"
#include "../Types.h"
#include "../Version.h"
#include "../cpp/StringView.h"
#include "../detail/DeferredLoad.h"
#include "../extras/Errors.h"
#include "../../omni/core/Result.h"
#include "../../omni/String.h"
#include <cinttypes>
namespace carb
{
#ifndef DOXYGEN_BUILD
inline namespace v1
{
#endif
class Error;
struct IError
{
CARB_PLUGIN_INTERFACE_EX("carb::ErrorApi", carb_ErrorApi_latest, carb_ErrorApi)
Error const*(CARB_ABI* viewCurrentError)(Result* code);
Error*(CARB_ABI* takeCurrentError)(Result* code);
CARB_ERRORAPI_DEPRECATED("Use internalSetErrorS() instead")
Result(CARB_ABI* internalSetError)(Result code, char const* message, std::size_t message_size);
Result(CARB_ABI* setErrorTo)(Error* error);
void(CARB_ABI* setErrorOom)();
Result(CARB_ABI* errorRelease)(Error* error);
Error*(CARB_ABI* errorClone)(Error const* source);
CARB_ERRORAPI_DEPRECATED("Use errorCreateS() instead")
Error*(CARB_ABI* errorCreate)(Result code, const char* message, std::size_t message_size);
CARB_ERRORAPI_DEPRECATED("Use getErrorInfoS() instead")
Result(CARB_ABI* getErrorInfo)(Error const* error, Result* code, char const** message, std::size_t* message_size);
CARB_ERRORAPI_DEPRECATED("Use getCodeDescriptionS() instead")
Result(CARB_ABI* getCodeDescription)(
Result code, char const** name, std::size_t* name_size, char const** message, std::size_t* message_size);
//
// Inline helper functions
//
Result setError(Result code, cpp::string_view message = {}) const noexcept;
Result(CARB_ABI* internalSetErrorS)(Result code, cpp::string_view message);
Error*(CARB_ABI* internalErrorCreateS)(Result code, cpp::string_view message);
// v1.1 member functions that delegate to the internal function pointers
Result setErrorS(Result code, cpp::string_view message) const noexcept;
Error* errorCreateS(Result code, cpp::string_view message = {}) const noexcept;
Result(CARB_ABI* getErrorInfoS)(Error const* error, Result* code, carb::cpp::string_view* message);
Result(CARB_ABI* getCodeDescriptionS)(Result code, carb::cpp::string_view* name, carb::cpp::string_view* message);
};
// Inline helper for convenient string_view overload
inline Result IError::setError(Result code, cpp::string_view message) const noexcept
{
CARB_IGNORE_DEPRECATION_BEGIN
return internalSetError(code, message.empty() ? nullptr : message.data(), message.size());
CARB_IGNORE_DEPRECATION_END
}
// v1.1 inline helpers that delegate to the internal function pointers
inline Result IError::setErrorS(Result code, cpp::string_view message) const noexcept
{
return internalSetErrorS(code, message);
}
inline Error* IError::errorCreateS(Result code, cpp::string_view message) const noexcept
{
return internalErrorCreateS(code, message);
}
#ifndef DOXYGEN_BUILD
} // inline namespace v1
#endif
} // namespace carb