载入中...
搜索中...
未找到
DiagnosticValue.h
浏览该文件的文档.
1#pragma once
2
8#include "common/Diagnostic.h"
9#include "common/Status.h"
10
11#include <concepts>
12#include <string_view>
13#include <type_traits>
14
15namespace eve {
16
18template <class T>
20
25template <class T>
26concept DiagnosticValue = std::is_enum_v<T> && requires(T value) {
27 { DiagnosticValueTraits<T>::name(value) } noexcept -> std::convertible_to<std::string_view>;
28 { DiagnosticValueTraits<T>::code(value) } noexcept -> std::same_as<DiagnosticCode>;
29};
30
32template <DiagnosticValue T>
34[[nodiscard]] constexpr std::string_view diagnosticValueName(T value) noexcept {
37}
38
40template <DiagnosticValue T>
42[[nodiscard]] constexpr DiagnosticCode diagnosticValueCode(T value) noexcept {
45}
46
48template <>
52 static constexpr std::string_view name(Severity value) noexcept { return severityName(value); }
57};
58
60template <>
64 static constexpr std::string_view name(DiagnosticCode value) noexcept { return diagnosticCodeName(value); }
66 static constexpr DiagnosticCode code(DiagnosticCode value) noexcept { return value; }
67};
68
70template <>
92
93} // namespace eve
double value
Stable, structured diagnostics shared by engine modules.
Structured operation status used by the common Result foundation.
A value with a stable protocol name and machine-readable diagnostic code.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47
constexpr std::string_view diagnosticValueName(T value) noexcept
Return the stable name supplied by a DiagnosticValue specialization.
constexpr std::string_view severityName(Severity severity) noexcept
Returns the stable lowercase severity spelling.
Definition Diagnostic.h:28
constexpr DiagnosticCode diagnosticValueCode(T value) noexcept
Return the stable machine-readable code supplied by a DiagnosticValue specialization.
StatusCode
Stable outcome category for an operation.
Definition Status.h:27
constexpr std::string_view statusCodeName(StatusCode code) noexcept
Return the stable protocol spelling of a status code.
Definition Status.h:45
Severity
Stable severity of a diagnostic, independent of its display text.
Definition Diagnostic.h:20
constexpr std::string_view diagnosticCodeName(DiagnosticCode code) noexcept
Return a stable, compact spelling useful for logs and diagnostics.
Definition Diagnostic.h:176
static constexpr std::string_view name(DiagnosticCode value) noexcept
Name.
static constexpr DiagnosticCode code(DiagnosticCode value) noexcept
Code.
static constexpr std::string_view name(Severity value) noexcept
Name.
static constexpr DiagnosticCode code(Severity value) noexcept
Code.
static constexpr DiagnosticCode code(StatusCode value) noexcept
Code.
static constexpr std::string_view name(StatusCode value) noexcept
Name.
Customization point for values that cross diagnostic boundaries.