# HG changeset patch # User Sebastien Jodogne # Date 1574269193 -3600 # Node ID 46a8050583a161d34d18abde7d9cad8a2ae7539b # Parent 74fc2a3b43bb5e50a61d20ba6396786e5bd427de OrthancPlugins::DicomPath::Format() diff -r 74fc2a3b43bb -r 46a8050583a1 Plugins/Samples/Common/DicomPath.cpp --- a/Plugins/Samples/Common/DicomPath.cpp Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomPath.cpp Wed Nov 20 17:59:53 2019 +0100 @@ -35,6 +35,8 @@ #include "OrthancPluginException.h" +#include + namespace OrthancPlugins { const DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) const @@ -97,4 +99,18 @@ AddToPrefix(sequence2, index2); AddToPrefix(sequence3, index3); } + + + std::string DicomPath::Format() const + { + std::string s; + + for (size_t i = 0; i < GetPrefixLength(); i++) + { + s += (GetPrefixTag(i).FormatHexadecimal() + " / " + + boost::lexical_cast(i) + " / "); + } + + return s + GetFinalTag().FormatHexadecimal(); + } } diff -r 74fc2a3b43bb -r 46a8050583a1 Plugins/Samples/Common/DicomPath.h --- a/Plugins/Samples/Common/DicomPath.h Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomPath.h Wed Nov 20 17:59:53 2019 +0100 @@ -112,5 +112,7 @@ { finalTag_ = tag; } + + std::string Format() const; }; } diff -r 74fc2a3b43bb -r 46a8050583a1 Plugins/Samples/Common/DicomTag.cpp --- a/Plugins/Samples/Common/DicomTag.cpp Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomTag.cpp Wed Nov 20 17:59:53 2019 +0100 @@ -108,4 +108,12 @@ ORTHANC_PLUGINS_THROW_EXCEPTION(NotImplemented); } } + + + std::string DicomTag::FormatHexadecimal() const + { + char buf[16]; + sprintf(buf, "(%04x,%04x)", group_, element_); + return buf; + } } diff -r 74fc2a3b43bb -r 46a8050583a1 Plugins/Samples/Common/DicomTag.h --- a/Plugins/Samples/Common/DicomTag.h Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomTag.h Wed Nov 20 17:59:53 2019 +0100 @@ -34,6 +34,7 @@ #pragma once #include +#include namespace OrthancPlugins { @@ -74,6 +75,8 @@ { return !(*this == other); } + + std::string FormatHexadecimal() const; };