ac9dc02b51
Replace the nullable unique_ptr returned by CaptureFactory::create() with CaptureResult<std::unique_ptr<CaptureSession>> using the new CaptureError/CaptureResult pattern, mirroring codec/error.h. The stub now reports 'not implemented yet' as an error instead of returning nullptr. Update handoff memory with the review outcome and forward-looking notes for phases 3, 5, and 7.
37 lines
980 B
C++
37 lines
980 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <variant>
|
|
|
|
namespace sc {
|
|
|
|
struct CaptureError {
|
|
std::string message;
|
|
};
|
|
|
|
// C++20 does not provide std::expected. Use a variant-based result type so
|
|
// fallible capture operations do not rely on exceptions.
|
|
template <typename T> using CaptureResult = std::variant<T, CaptureError>;
|
|
|
|
template <typename T> constexpr bool is_capture_error(const CaptureResult<T>& result) noexcept {
|
|
return std::holds_alternative<CaptureError>(result);
|
|
}
|
|
|
|
template <typename T> T& capture_value(CaptureResult<T>& result) {
|
|
return std::get<T>(result);
|
|
}
|
|
|
|
template <typename T> const T& capture_value(const CaptureResult<T>& result) {
|
|
return std::get<T>(result);
|
|
}
|
|
|
|
template <typename T> CaptureError& capture_error(CaptureResult<T>& result) {
|
|
return std::get<CaptureError>(result);
|
|
}
|
|
|
|
template <typename T> const CaptureError& capture_error(const CaptureResult<T>& result) {
|
|
return std::get<CaptureError>(result);
|
|
}
|
|
|
|
} // namespace sc
|