# gdcmPrivateTag.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2010 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00009
    00010      This software is distributed WITHOUT ANY WARRANTY; without even
    00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00012      PURPOSE.  See the above copyright notice for more information.
    00013
    00014 =========================================================================*/
    00015 #ifndef GDCMPRIVATETAG_H
    00016 #define GDCMPRIVATETAG_H
    00017
    00018 #include "gdcmTag.h"
    00019 #include "gdcmSystem.h" // FIXME
    00020
    00021 #include <iostream>
    00022 #include <iomanip>
    00023 #include <algorithm>
    00024
    00025 #include <string.h> // strlen
    00026
    00027 namespace gdcm
    00028 {
    00029
    00035 class GDCM_EXPORT PrivateTag : public Tag
    00036 {
    00037   friend std::ostream& operator<<(std::ostream &_os, const PrivateTag &_val);
    00038 public:
    00039   PrivateTag(uint16_t group = 0, uint16_t element = 0, const char *owner = ""):Tag(group,element),Owner(owner) {
    00040     std::transform(Owner.begin(), Owner.end(), Owner.begin(), tolower);
    00041     //assert( element > 0x0010 && element < 0x100 );
    00042   }
    00043
    00044   const char *GetOwner() const { return Owner.c_str(); }
    00045   void SetOwner(const char *owner) { Owner = owner; }
    00046
    00047   bool operator<(const PrivateTag &_val) const
    00048     {
    00049     const Tag & t1 = *this;
    00050     const Tag & t2 = _val;
    00051     if( t1 == t2 )
    00052       {
    00053       const char *s1 = Owner.c_str();
    00054       const char *s2 = _val.GetOwner();
    00055       assert( s1[strlen(s1)-1] != ' ' );
    00056       assert( s2[strlen(s2)-1] != ' ' );
    00057       bool res = strcmp(s1, s2) < 0;
    00058 #ifndef NDEBUG
    00059       if( *s1 && *s2 && gdcm::System::StrCaseCmp(s1,s2) == 0 && strcmp(s1,s2) != 0 )
    00060         {
    00061         // FIXME:
    00062         // Typically this should only happen with the "Philips MR Imaging DD 001" vs "PHILIPS MR IMAGING DD 001"
    00063         // or "Philips Imaging DD 001" vr "PHILIPS IMAGING DD 001"
    00064         //assert( strcmp(Owner.c_str(), _val.GetOwner()) == 0 );
    00065         //return true;
    00066         res = gdcm::System::StrCaseCmp(s1,s2) < 0;
    00067 assert(0);
    00068         }
    00069 #endif
    00070       return res;
    00071       }
    00072     else return t1 < t2;
    00073     }
    00074
    00075   bool ReadFromCommaSeparatedString(const char *str);
    00076
    00077 private:
    00078   // SIEMENS MED, GEMS_PETD_01 ...
    00079   std::string Owner;
    00080 };
    00081
    00082 inline std::ostream& operator<<(std::ostream &os, const PrivateTag &val)
    00083 {
    00084   //assert( !val.Owner.empty() );
    00085   os.setf( std::ios::right );
    00086   os << std::hex << '(' << std::setw( 4 ) << std::setfill( '0' )
    00087     << val[0] << ',' << std::setw( 4 ) << std::setfill( '0' )
    00088     << val[1] << ')' << std::setfill( ' ' ) << std::dec;
    00089   os << val.Owner;
    00090   return os;
    00091 }
    00092
    00093 } // end namespace gdcm
    00094
    00095 #endif //GDCMPRIVATETAG_H
    00096