Files
Gleb MazovetskiyandClaude Fable 5 63e85d9b1b Replace tl::expected with std::expected
Now that the project targets C++23, use the standard library's
std::expected instead of the vendored tl::expected polyfill:

- tl::expected -> std::expected, tl::unexpected/tl::make_unexpected -> std::unexpected
- .map()/.map_error() -> .transform()/.transform_error()
- #include <expected.hpp> -> #include <expected>, grouped with std headers
- Remove 3rdParty/tl/expected.hpp (the tl target remains for function_ref.hpp)

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-22 00:00:04 +02:00

67 lines
2.3 KiB
C++

#pragma once
#include <cstdint>
#include <expected>
#include <string>
#include "engine/clx_sprite.hpp"
#include "utils/pointer_value_union.hpp"
#include "utils/status_macros.hpp"
#ifdef UNPACKED_MPQS
#define DEVILUTIONX_CEL_EXT ".clx"
#else
#define DEVILUTIONX_CEL_EXT ".cel"
#endif
namespace devilution {
std::expected<OwnedClxSpriteListOrSheet, std::string> LoadCelListOrSheetWithStatus(const char *pszName, PointerOrValue<uint16_t> widthOrWidths);
OwnedClxSpriteListOrSheet LoadCelListOrSheet(const char *pszName, PointerOrValue<uint16_t> widthOrWidths);
inline OwnedClxSpriteList LoadCel(const char *pszName, uint16_t width)
{
return LoadCelListOrSheet(pszName, PointerOrValue<uint16_t> { width }).list();
}
inline OptionalOwnedClxSpriteList LoadOptionalCel(const char *pszName, uint16_t width)
{
std::expected<OwnedClxSpriteListOrSheet, std::string> result = LoadCelListOrSheetWithStatus(pszName, PointerOrValue<uint16_t> { width });
if (!result.has_value())
return std::nullopt;
return (*std::move(result)).list();
}
inline std::expected<OwnedClxSpriteList, std::string> LoadCelWithStatus(const char *pszName, uint16_t width)
{
ASSIGN_OR_RETURN(OwnedClxSpriteListOrSheet result, LoadCelListOrSheetWithStatus(pszName, PointerOrValue<uint16_t> { width }));
return std::move(result).list();
}
inline OwnedClxSpriteList LoadCel(const char *pszName, const uint16_t *widths)
{
return LoadCelListOrSheet(pszName, PointerOrValue<uint16_t> { widths }).list();
}
inline OptionalOwnedClxSpriteList LoadOptionalCel(const char *pszName, const uint16_t *widths)
{
std::expected<OwnedClxSpriteListOrSheet, std::string> result = LoadCelListOrSheetWithStatus(pszName, PointerOrValue<uint16_t> { widths });
if (!result.has_value())
return std::nullopt;
return (*std::move(result)).list();
}
inline std::expected<OwnedClxSpriteList, std::string> LoadCelWithStatus(const char *pszName, const uint16_t *widths)
{
ASSIGN_OR_RETURN(OwnedClxSpriteListOrSheet result, LoadCelListOrSheetWithStatus(pszName, PointerOrValue<uint16_t> { widths }));
return std::move(result).list();
}
inline OwnedClxSpriteSheet LoadCelSheet(const char *pszName, uint16_t width)
{
return LoadCelListOrSheet(pszName, PointerOrValue<uint16_t> { width }).sheet();
}
} // namespace devilution