PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
tag_info.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
18#pragma once
19
20#include "dicom_tag.h"
21
22#include <cstdint>
23#include <optional>
24#include <string>
25#include <string_view>
26
27namespace kcenon::pacs::core {
28
42 uint32_t min{1};
43 std::optional<uint32_t> max{1};
44 uint32_t multiplier{1};
45
49 constexpr value_multiplicity() noexcept = default;
50
57 constexpr value_multiplicity(uint32_t min_val,
58 std::optional<uint32_t> max_val,
59 uint32_t mult = 1) noexcept
60 : min{min_val}, max{max_val}, multiplier{mult} {}
61
67 [[nodiscard]] constexpr auto is_valid(uint32_t count) const noexcept -> bool {
68 if (count < min) {
69 return false;
70 }
71 if (max.has_value()) {
72 return count <= max.value();
73 }
74 // Unbounded case - check multiplier constraint
75 if (multiplier > 1) {
76 return (count - min) % multiplier == 0;
77 }
78 return true;
79 }
80
85 [[nodiscard]] constexpr auto allows_multiple() const noexcept -> bool {
86 return !max.has_value() || max.value() > 1;
87 }
88
93 [[nodiscard]] constexpr auto is_unbounded() const noexcept -> bool {
94 return !max.has_value();
95 }
96
109 [[nodiscard]] static auto from_string(std::string_view str)
110 -> std::optional<value_multiplicity>;
111
116 [[nodiscard]] auto to_string() const -> std::string;
117};
118
138struct tag_info {
140 uint16_t vr{0};
142 std::string_view keyword;
143 std::string_view name;
144 bool retired{false};
145
150 [[nodiscard]] constexpr auto is_valid() const noexcept -> bool {
151 return !keyword.empty();
152 }
153
157 [[nodiscard]] constexpr auto operator==(const tag_info& other) const noexcept -> bool {
158 return tag == other.tag;
159 }
160
164 [[nodiscard]] constexpr auto operator<=>(const tag_info& other) const noexcept {
165 return tag <=> other.tag;
166 }
167};
168
169} // namespace kcenon::pacs::core
170
DICOM Tag representation (Group, Element pairs)
value_multiplicity vm
Value Multiplicity specification.
Definition tag_info.h:141
constexpr auto operator==(const tag_info &other) const noexcept -> bool
Compare tag_info by tag value.
Definition tag_info.h:157
dicom_tag tag
The DICOM tag (group, element)
Definition tag_info.h:139
constexpr auto operator<=>(const tag_info &other) const noexcept
Three-way comparison by tag value.
Definition tag_info.h:164
std::string_view keyword
Tag keyword (e.g., "PatientName")
Definition tag_info.h:142
constexpr auto is_valid() const noexcept -> bool
Check if this tag_info is valid (has non-empty keyword)
Definition tag_info.h:150
std::string_view name
Human-readable name (e.g., "Patient's Name")
Definition tag_info.h:143
Value Multiplicity (VM) specification.
Definition tag_info.h:41
static auto from_string(std::string_view str) -> std::optional< value_multiplicity >
Parse VM from string representation.
Definition tag_info.cpp:17
constexpr auto allows_multiple() const noexcept -> bool
Check if this VM allows multiple values.
Definition tag_info.h:85
uint32_t multiplier
For "n", "2n", "3n" patterns.
Definition tag_info.h:44
uint32_t min
Minimum number of values.
Definition tag_info.h:42
constexpr value_multiplicity() noexcept=default
Default constructor - creates VM "1".
constexpr auto is_unbounded() const noexcept -> bool
Check if this VM is unbounded (ends with "n")
Definition tag_info.h:93
constexpr auto is_valid(uint32_t count) const noexcept -> bool
Check if a count of values is valid for this VM.
Definition tag_info.h:67
std::optional< uint32_t > max
Maximum number of values (nullopt = unbounded)
Definition tag_info.h:43
auto to_string() const -> std::string
Convert to string representation.
Definition tag_info.cpp:87
vr_encoding vr