PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
explicit_vr_big_endian_codec.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
21#ifndef PACS_ENCODING_EXPLICIT_VR_BIG_ENDIAN_CODEC_HPP
22#define PACS_ENCODING_EXPLICIT_VR_BIG_ENDIAN_CODEC_HPP
23
27
28#include <cstdint>
29#include <span>
30#include <vector>
31
32namespace kcenon::pacs::encoding {
33
70public:
74 template <typename T>
76
77 // ========================================================================
78 // Dataset Encoding/Decoding
79 // ========================================================================
80
86 [[nodiscard]] static std::vector<uint8_t> encode(
87 const core::dicom_dataset& dataset);
88
94 [[nodiscard]] static result<core::dicom_dataset> decode(
95 std::span<const uint8_t> data);
96
97 // ========================================================================
98 // Element Encoding/Decoding
99 // ========================================================================
100
106 [[nodiscard]] static std::vector<uint8_t> encode_element(
107 const core::dicom_element& element);
108
117 [[nodiscard]] static result<core::dicom_element> decode_element(
118 std::span<const uint8_t>& data);
119
120 // ========================================================================
121 // Byte Order Conversion
122 // ========================================================================
123
139 [[nodiscard]] static std::vector<uint8_t> to_big_endian(
140 vr_type vr, std::span<const uint8_t> data);
141
150 [[nodiscard]] static std::vector<uint8_t> from_big_endian(
151 vr_type vr, std::span<const uint8_t> data);
152
153private:
154 // Internal encoding helpers
155 static void encode_sequence(std::vector<uint8_t>& buffer,
156 const core::dicom_element& element);
157
158 static void encode_sequence_item(std::vector<uint8_t>& buffer,
159 const core::dicom_dataset& item);
160
161 // Internal decoding helpers
164 std::span<const uint8_t>& data);
165
167 std::span<const uint8_t>& data);
168};
169
170} // namespace kcenon::pacs::encoding
171
172#endif // PACS_ENCODING_EXPLICIT_VR_BIG_ENDIAN_CODEC_HPP
Encoder/decoder for Explicit VR Big Endian transfer syntax.
static std::vector< uint8_t > from_big_endian(vr_type vr, std::span< const uint8_t > data)
Convert element value from big-endian to little-endian.
static void encode_sequence_item(std::vector< uint8_t > &buffer, const core::dicom_dataset &item)
static std::vector< uint8_t > to_big_endian(vr_type vr, std::span< const uint8_t > data)
Convert element value from little-endian to big-endian.
static result< core::dicom_dataset > decode(std::span< const uint8_t > data)
Decode bytes to a dataset using Explicit VR Big Endian.
static result< core::dicom_element > decode_undefined_length(core::dicom_tag tag, vr_type vr, std::span< const uint8_t > &data)
static result< core::dicom_element > decode_element(std::span< const uint8_t > &data)
Decode a single element from bytes.
static std::vector< uint8_t > encode_element(const core::dicom_element &element)
Encode a single element to bytes.
static void encode_sequence(std::vector< uint8_t > &buffer, const core::dicom_element &element)
static std::vector< uint8_t > encode(const core::dicom_dataset &dataset)
Encode a dataset to bytes using Explicit VR Big Endian.
static result< core::dicom_dataset > decode_sequence_item(std::span< const uint8_t > &data)
DICOM Dataset - ordered collection of Data Elements.
DICOM Data Element representation (Tag, VR, Value)
vr_type
DICOM Value Representation (VR) types.
Definition vr_type.h:29
Result<T> type aliases and helpers for PACS system.
vr_encoding vr