X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDocEntrySet.cxx;h=a054d86e7f990360c22b91aa1d123403f9bdb4fc;hb=ebbbfdba2841d733f3ac30a2861e1d66daa2ba81;hp=666b72a100c506ae9fc422eb4a208d88980e14be;hpb=b0f62020f3423bf7663fdf856000dc245e417d9a;p=gdcm.git diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index 666b72a1..a054d86e 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2005/08/24 12:09:13 $ - Version: $Revision: 1.58 $ + Date: $Date: 2005/09/06 15:28:49 $ + Version: $Revision: 1.59 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,6 +25,7 @@ #include "gdcmSeqEntry.h" #include "gdcmValEntry.h" #include "gdcmBinEntry.h" +#include "gdcmUtil.h" namespace gdcm { @@ -41,7 +42,7 @@ DocEntrySet::DocEntrySet() * @param group Group number of the searched tag. * @param elem Element number of the searched tag. * @return Corresponding element value when it exists, - * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. + * and the string GDCM_UNFOUND otherwise. */ std::string DocEntrySet::GetEntryValue(uint16_t group, uint16_t elem) { @@ -65,6 +66,34 @@ void *DocEntrySet::GetEntryBinArea(uint16_t group, uint16_t elem) return 0; } +/** + * \brief Return the value of the BinEntry if it's "std::string representable" + * @param group Group number of the searched tag. + * @param elem Element number of the searched tag. + * @return Corresponding element value when it's "std::string representable" + * and the string GDCM_NOTASCII otherwise. + */ +std::string DocEntrySet::GetEntryForcedAsciiValue(uint16_t group, uint16_t elem) +{ + DocEntry *d = GetDocEntry(group,elem); + if ( !d ) + return GDCM_UNFOUND; + + if (ValEntry *v = dynamic_cast(d)) + return v->GetValue(); + + if (BinEntry *b = dynamic_cast(d)) + { + uint8_t *a = b->GetBinArea(); + if (!b) + return GDCM_NOTLOADED; + // TODO : unify those two methods. + if (Util::IsCleanArea(a, b->GetLength()) ) + return Util::CreateCleanString(a, b->GetLength()); + } + return GDCM_NOTASCII; +} + /** * \brief Searches within Header Entries (Dicom Elements) parsed with * the public and private dictionaries