- static std::ostringstream s;
- const VRKey &vr = GetVR();
-
- s.str("");
- StrArea="";
-
- if( !BinArea )
- return StrArea;
-
- // When short integer(s) are stored, convert the following (n * 2) characters
- // as a displayable string, the values being separated by a back-slash
-
- if( vr == "US" || vr == "SS" )
- {
- uint16_t *data=(uint16_t *)BinArea;
-
- for (unsigned int i=0; i < GetValueCount(); i++)
- {
- if( i!=0 )
- s << '\\';
- s << data[i];
- }
- StrArea=s.str();
- }
- // See above comment on multiple short integers (mutatis mutandis).
- else if( vr == "UL" || vr == "SL" )
- {
- uint32_t *data=(uint32_t *)BinArea;
-
- for (unsigned int i=0; i < GetValueCount(); i++)
- {
- if( i!=0 )
- s << '\\';
- s << data[i];
- }
- StrArea=s.str();
- }
- else if( vr == "FL" )
- {
- float *data=(float *)BinArea;
+ static std::ostringstream s;
+ const VRKey &vr = GetVR();
+ s.str("");
+
+ if (!StrArea)
+ StrArea = new std::string();
+ else
+ *StrArea="";
+
+ if( !BinArea )
+ return *StrArea;
+ // When short integer(s) are stored, convert the following (n * 2) characters
+ // as a displayable string, the values being separated by a back-slash
+ if( vr == "US" )
+ {
+ uint16_t *data=(uint16_t *)BinArea;
+ for (unsigned int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ *StrArea=s.str();
+ }
+ else if (vr == "SS" )
+ {
+ int16_t *data=(int16_t *)BinArea;
+ for (unsigned int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ *StrArea=s.str();
+ } // See above comment on multiple short integers (mutatis mutandis).
+ else if( vr == "UL" )
+ {
+ uint32_t *data=(uint32_t *)BinArea;
+ for (unsigned int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ *StrArea=s.str();
+ }
+ else if( vr == "SL" )
+ {
+ int32_t *data=(int32_t *)BinArea;
+ for (unsigned int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ *StrArea=s.str();
+ } else if( vr == "FL" )
+ {
+ float *data=(float *)BinArea;
+ for (unsigned int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ *StrArea=s.str();
+ }
+ else if( vr == "FD" )
+ {
+ double *data=(double *)BinArea;
+ for (unsigned int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ *StrArea=s.str();
+ }
+ else
+ {
+ StrArea->append((const char *)BinArea,GetLength());
+ // to avoid gdcm to propagate oddities in lengthes
+ if ( GetLength()%2)
+ StrArea->append(" ",1); }
+ return *StrArea;
+}