/*========================================================================= Program: gdcm Module: $RCSfile: gdcmContentEntry.cxx,v $ Language: C++ Date: $Date: 2005/01/25 15:21:20 $ Version: $Revision: 1.1 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "gdcmContentEntry.h" #include "gdcmVR.h" #include "gdcmTS.h" #include "gdcmGlobal.h" #include "gdcmUtil.h" #include "gdcmDebug.h" #include namespace gdcm { // CLEAN ME #define MAX_SIZE_PRINT_ELEMENT_VALUE 128 //----------------------------------------------------------------------------- // Constructor / Destructor /** * \brief Constructor from a given DictEntry * @param e Pointer to existing dictionary entry */ ContentEntry::ContentEntry(DictEntry *e) : DocEntry(e) { } /** * \brief Constructor from a given DocEntry * @param e Pointer to existing Doc entry */ ContentEntry::ContentEntry(DocEntry *e) : DocEntry(e->GetDictEntry()) { Copy(e); } /** * \brief Canonical destructor. */ ContentEntry::~ContentEntry () { } //----------------------------------------------------------------------------- // Public /** * \brief Writes the std::string representable' value of a ContentEntry * @param fp already open ofstream pointer * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...) */ void ContentEntry::WriteContent(std::ofstream *fp, FileType filetype) { DocEntry::WriteContent(fp, filetype); if ( GetGroup() == 0xfffe ) { return; //delimitors have NO value } const VRKey &vr = GetVR(); unsigned int lgr = GetLength(); if (vr == "US" || vr == "SS") { // some 'Short integer' fields may be multivaluated // each single value is separated from the next one by '\' // we split the string and write each value as a short int std::vector tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value Util::Tokenize (GetValue(), tokens, "\\"); for (unsigned int i=0; i tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value Util::Tokenize (GetValue(), tokens, "\\"); for (unsigned int i=0; i