std::, and all occurences of "using namespace std;" where removed.
This is to avoid pollution of global namespace in included files.
Apparently vtk does not avoid this pitfall: when using both
gdcm and vtk (as in vtk/vtkGdcmReader.cxx) this ended up in a
collision of various stl members (principally cout...).
- gdcmPython/demo/vtkGdcmReader.py added. This demo illustrates
the usage of the python wrapper of vtkGdcmReader vtk class.
* vtk/vtkGdcmReader.cxx: bug fixed (thanks to Benoit Regrain).
+ * src/*.[h] all occurences of stl classes are now prefixed with
+ std::, and all occurences of "using namespace std;" where removed.
+ This is to avoid pollution of global namespace in included files.
+ Apparently vtk does not avoid this pitfall: when using both
+ gdcm and vtk (as in vtk/vtkGdcmReader.cxx) this ended up in a
+ collision of various stl members (principally cout...).
2003-05-12 Eric Boix <Eric.Boix@creatis.insa-lyon.fr> with JPR
* src/gdcmHeader>[h/cxx] added gdcmHeader::GetPixelSize()
## Process this file with automake to produce Makefile.in
-SUBDIRS = src gdcmPython Test Dicts Doc vtk
+SUBDIRS = src vtk gdcmPython Test Dicts Doc
EXTRA_DIST = \
#include "gdcmElValSet.h"
#include "gdcmHeader.h"
#include "gdcmFile.h"
+using namespace std;
// Utility functions on strings for removing leading and trailing spaces
void EatLeadingAndTrailingSpaces(string & s) {
#endif
#include <string>
-#ifdef _MSC_VER
-using namespace std; // string type lives in the std namespace on VC++
-#endif
-typedef string TagKey;
-typedef string TagName;
+typedef std::string TagKey;
+typedef std::string TagName;
enum FileType {
Unknown = 0,
#include "gdcmCommon.h"
#include "gdcmDictEntry.h"
-typedef map<TagKey, gdcmDictEntry*> TagKeyHT;
-typedef map<TagName, gdcmDictEntry*> TagNameHT;
+typedef std::map<TagKey, gdcmDictEntry*> TagKeyHT;
+typedef std::map<TagName, gdcmDictEntry*> TagNameHT;
/*
* \defgroup gdcmDict
* \see gdcmDictSet
*/
class GDCM_EXPORT gdcmDict {
- string name;
- string filename;
+ std::string name;
+ std::string filename;
/// Access through TagKey (see alternate access with NameHt)
TagKeyHT KeyHt;
/// Access through TagName (see alternate access with KeyHt)
TagNameHT NameHt;
public:
- gdcmDict(string & FileName);
+ gdcmDict(std::string & FileName);
~gdcmDict();
int AddNewEntry (gdcmDictEntry* NewEntry);
int ReplaceEntry(gdcmDictEntry* NewEntry);
class GDCM_EXPORT gdcmDictEntry {
private:
- guint16 group; // e.g. 0x0010 // FIXME : s'en sert-on qq part
- guint16 element; // e.g. 0x0103 // si ce n'est pour fabriquer la TagKey ?
- string vr; // Value Representation i.e. some clue about the nature
- // of the data represented e.g. "FD" short for
- // "Floating Point Double"
+ // FIXME : were are the group and element used except from building up
+ // a TagKey. If the answer is nowhere then there is no need
+ // to store the group and element independently.
+ guint16 group; // e.g. 0x0010
+ guint16 element; // e.g. 0x0103
+ std::string vr; // Value Representation i.e. some clue about the nature
+ // of the data represented e.g. "FD" short for
+ // "Floating Point Double"
// CLEANME: find the official dicom name for this field !
- string fourth; // Fourth field containing some semantics. (Group Name abbr.)
- string name; // e.g. "Patient_Name"
- TagKey key; // Redundant with (group, element) but we add it
- // on efficiency purposes.
+ std::string fourth; // Fourth field containing some semantics.
+ //(Group Name abbr.)
+ std::string name; // e.g. "Patient_Name"
+ TagKey key; // Redundant with (group, element) but we add it
+ // on efficiency purposes.
// DCMTK has many fields for handling a DictEntry (see below). What are the
// relevant ones for gdcmlib ?
// struct DBI_SimpleEntry {
public:
gdcmDictEntry(guint16 group,
guint16 element,
- string vr = "Unknown",
- string fourth = "Unknown",
- string name = "Unknown");
+ std::string vr = "Unknown",
+ std::string fourth = "Unknown",
+ std::string name = "Unknown");
// fabrique une 'clé' par concaténation du numGroupe et du numElement
static TagKey TranslateToKey(guint16 group, guint16 element);
- guint16 GetGroup(void) { return group; };
- guint16 GetElement(void){return element;};
- string GetVR(void) {return vr; };
- void SetVR(string);
- void SetKey(string k){ key = k; }
- bool IsVrUnknown(void);
- string GetFourth(void) {return fourth;};
- string GetName(void) {return name; };
- string GetKey(void) {return key; };
+ guint16 GetGroup(void) { return group; };
+ guint16 GetElement(void){return element;};
+ std::string GetVR(void) {return vr; };
+ void SetVR(std::string);
+ void SetKey(std::string k){ key = k; };
+ bool IsVrUnknown(void);
+ std::string GetFourth(void) {return fourth;};
+ std::string GetName(void) {return name; };
+ std::string GetKey(void) {return key; };
};
#endif
#include <list>
#include "gdcmDict.h"
-typedef string DictKey;
-typedef map<DictKey, gdcmDict*> DictSetHT;
+typedef std::string DictKey;
+typedef std::map<DictKey, gdcmDict*> DictSetHT;
/*
* \defgroup gdcmDictSet
/// Hash table of all dictionaries contained in this gdcmDictSet
DictSetHT Dicts;
/// Directory path to dictionaries
- string DictPath;
+ std::string DictPath;
int AppendDict(gdcmDict* NewDict);
- void LoadDictFromFile(string filename, DictKey);
- string BuildDictPath(void);
+ void LoadDictFromFile(std::string filename, DictKey);
+ std::string BuildDictPath(void);
public:
- list<string> * GetPubDictTagNames(void);
- map<string, list<string> >* GetPubDictTagNamesByCategory(void);
+ std::list<std::string> * GetPubDictTagNames(void);
+ std::map<std::string, std::list<std::string> >*
+ GetPubDictTagNamesByCategory(void);
- // TODO Swig int LoadDictFromFile(string filename);
+ // TODO Swig int LoadDictFromFile(std::string filename);
// QUESTION: the following function might not be thread safe !? Maybe
// we need some mutex here, to avoid concurent creation of
// the same dictionary !?!?!
- // TODO Swig int LoadDictFromName(string filename);
- // TODO Swig int LoadAllDictFromDirectory(string DirectoryName);
- // TODO Swig string* GetAllDictNames();
+ // TODO Swig int LoadDictFromName(std::string filename);
+ // TODO Swig int LoadAllDictFromDirectory(std::string DirectoryName);
+ // TODO Swig std::string* GetAllDictNames();
gdcmDictSet(void);
~gdcmDictSet(void);
void Print(ostream&);
-// $Header: /cvs/public/gdcm/src/Attic/gdcmElValSet.h,v 1.11 2003/04/16 08:03:27 frog Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmElValSet.h,v 1.12 2003/05/21 14:42:46 frog Exp $
#ifndef GDCMELVALSET_H
#define GDCMELVALSET_H
////////////////////////////////////////////////////////////////////////////
// Container for a set of successfully parsed ElValues.
-typedef map<TagKey, gdcmElValue*> TagElValueHT;
-typedef map<string, gdcmElValue*> TagElValueNameHT;
+typedef std::map<TagKey, gdcmElValue*> TagElValueHT;
+typedef std::map<std::string, gdcmElValue*> TagElValueNameHT;
class GDCM_EXPORT gdcmElValSet {
TagElValueHT tagHt; // Both accesses with a TagKey or with a
TagElValueNameHT NameHt; // the DictEntry.Name are required.
- typedef string GroupKey;
- typedef map<GroupKey, int> GroupHT;
+ typedef std::string GroupKey;
+ typedef std::map<GroupKey, int> GroupHT;
public:
~gdcmElValSet();
int Write(FILE *fp, FileType type);
gdcmElValue* GetElementByNumber(guint16 group, guint16 element);
- gdcmElValue* GetElementByName (string);
- string GetElValueByNumber(guint16 group, guint16 element);
- string GetElValueByName (string);
+ gdcmElValue* GetElementByName (std::string);
+ std::string GetElValueByNumber(guint16 group, guint16 element);
+ std::string GetElValueByName (std::string);
TagElValueHT & GetTagHt(void);
- int SetElValueByNumber(string content, guint16 group, guint16 element);
- int SetElValueByName (string content, string TagName);
+ int SetElValueByNumber(std::string content, guint16 group, guint16 element);
+ int SetElValueByName (std::string content, std::string TagName);
int SetElValueLengthByNumber(guint32 l, guint16 group, guint16 element);
- int SetElValueLengthByName (guint32 l, string TagName);
+ int SetElValueLengthByName (guint32 l, std::string TagName);
guint32 GenerateFreeTagKeyInGroup(guint16 group);
-// $Header: /cvs/public/gdcm/src/Attic/gdcmElValue.h,v 1.4 2003/04/09 14:04:53 jpr Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmElValue.h,v 1.5 2003/05/21 14:42:46 frog Exp $
#ifndef GDCMELVALUE_H
#define GDCMELVALUE_H
//friend gdcmElValue * gdcmHeader::ReadNextElement(void);
friend class gdcmHeader;
public:
- string value;
+ std::string value;
size_t Offset; // Offset from the begining of file for direct user access
gdcmElValue(gdcmDictEntry*);
bool IsImplicitVr(void) { return ImplicitVr; };
gdcmDictEntry * GetDictEntry(void) { return entry; };
- guint16 GetGroup(void) { return entry->GetGroup(); };
- guint16 GetElement(void) { return entry->GetElement();};
- string GetKey(void) { return entry->GetKey(); };
- string GetName(void) { return entry->GetName(); };
- string GetVR(void) { return entry->GetVR(); };
- void SetVR(string v) { entry->SetVR(v); };
- void SetLength(guint32 l){ LgrElem = l; };
- guint32 GetLength(void) { return LgrElem; };
+ guint16 GetGroup(void) { return entry->GetGroup(); };
+ guint16 GetElement(void) { return entry->GetElement();};
+ std::string GetKey(void) { return entry->GetKey(); };
+ std::string GetName(void) { return entry->GetName(); };
+ std::string GetVR(void) { return entry->GetVR(); };
+ void SetVR(std::string v) { entry->SetVR(v); };
+ void SetLength(guint32 l){ LgrElem = l; };
+ guint32 GetLength(void) { return LgrElem; };
- void SetValue(string val){ value = val; };
- string GetValue(void) { return value;};
+ void SetValue(std::string val){ value = val; };
+ std::string GetValue(void) { return value;};
size_t GetOffset(void) { return Offset;};
};
#define GDCM_EXCEPTION_H
#include <string>
-#ifdef _MSC_VER
-using namespace std; // string type lives in the std namespace on VC++
-#endif
-
#include <iostream>
#include <exception>
-using namespace std;
-
-#ifdef _MSC_VER
-#define GDCM_EXPORT __declspec( dllexport )
-#else
-#define GDCM_EXPORT
-#endif
+#include "gdcmCommon.h"
/**
* Any exception thrown in the gdcm library
class GDCM_EXPORT gdcmException : public exception {
protected:
/// error message
- string from;
+ std::string from;
/// error message
- string error;
+ std::string error;
public:
/**
* @param from name of the thrower
* @param error error description string
*/
- explicit gdcmException(const string &from, const string &error = "")
+ explicit gdcmException(const std::string &from, const std::string &error = "")
throw();
}
/// returns error message
- const string &getError(void) const throw() {
+ const std::string &getError(void) const throw() {
return error;
}
static void fatal(const char *from) throw();
/// try to discover this (dynamic) class name
- virtual string getName() const throw();
+ virtual std::string getName() const throw();
- friend ostream& operator<<(ostream &os, const gdcmException &e);
+ friend std::ostream& operator<<(std::ostream &os, const gdcmException &e);
};
* @param from name of the thrower
* @param error error description string
*/
- explicit gdcmFileError(const string &from,
- const string &error = "File error")
+ explicit gdcmFileError(const std::string &from,
+ const std::string &error = "File error")
throw() : gdcmException(from, error) {
}
};
-
-
/**
* Invalid file format exception
*/
* @param from name of the thrower
* @param error error description string
*/
- explicit gdcmFormatError(const string &from,
- const string &error = "Invalid file format error")
+ explicit gdcmFormatError(const std::string &from,
+ const std::string &error = "Invalid file format error")
throw() : gdcmException(from, error) {
}
};
void* PixelData;
size_t lgrTotale;
int Parsed; // weather allready parsed
- string OrigFileName; // To avoid file overwrite
+ std::string OrigFileName; // To avoid file overwrite
void SwapZone(void* im, int swap, int lgr, int nb);
bool ReadPixelData(void * destination);
protected:
- int WriteBase(string FileName, FileType type);
+ int WriteBase(std::string FileName, FileType type);
public:
- gdcmFile(string & filename);
+ gdcmFile(std::string & filename);
gdcmFile(const char * filename);
// For promotion (performs a deepcopy of pointed header object)
// TODO Swig ~gdcmFile();
// On writing purposes. When instance was created through
- // gdcmFile(string filename) then the filename argument MUST be different
- // from the constructor's one (no overwriting allowed).
- // TODO Swig int SetFileName(string filename);
+ // gdcmFile(std::string filename) then the filename argument MUST be
+ // different from the constructor's one (no overwriting allowed).
+ // TODO Swig int SetFileName(std::string filename);
void SetPixelDataSizeFromHeader(void);
size_t GetImageDataSize();
// Aucun test n'est fait sur l'"Endiannerie" du processeur.
// Ca sera à l'utilisateur d'appeler son Reader correctement
- int WriteRawData (string nomFichier);
- int WriteDcmImplVR(string nomFichier);
+ int WriteRawData (std::string nomFichier);
+ int WriteDcmImplVR(std::string nomFichier);
int WriteDcmImplVR(const char * nomFichier);
- int WriteDcmExplVR(string nomFichier);
- int WriteAcr (string nomFichier);
+ int WriteDcmExplVR(std::string nomFichier);
+ int WriteAcr (std::string nomFichier);
};
#endif
-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.65 2003/05/12 14:32:43 frog Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.66 2003/05/21 14:42:46 frog Exp $
#include <stdio.h>
#include <cerrno>
#include <sstream>
#include "gdcmUtil.h"
#include "gdcmHeader.h"
+using namespace std;
// Refer to gdcmHeader::CheckSwap()
#define HEADER_LENGTH_TO_READ 256
-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.23 2003/05/12 14:32:43 frog Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.24 2003/05/21 14:42:46 frog Exp $
#ifndef GDCMHEADER_H
#define GDCMHEADER_H
#include "gdcmElValue.h"
#include "gdcmElValSet.h"
-typedef string VRKey;
-typedef string VRAtr;
-typedef map<VRKey, VRAtr> VRHT; // Value Representation Hash Table
+typedef std::string VRKey;
+typedef std::string VRAtr;
+typedef std::map<VRKey, VRAtr> VRHT; // Value Representation Hash Table
/// The purpose of an instance of gdcmHeader is to act as a container of
/// all the DICOM elements and their corresponding values (and
/// ELement VALueS parsed with the SHAdow dictionary.
gdcmElValSet ShaElValSet;
/// Refering underlying filename.
- string filename;
+ std::string filename;
// FIXME sw should be an enum e.g.
//enum EndianType {
void CheckSwap(void);
void SwitchSwapToBigEndian(void);
// CLEAN ME: NewManualElValToPubDict is NOT called any more.
- gdcmElValue* NewManualElValToPubDict(string NewTagName, string VR);
+ gdcmElValue* NewManualElValToPubDict(std::string NewTagName,
+ std::string VR);
void SetMaxSizeLoadElementValue(long);
gdcmDictEntry * GetDictEntryByNumber(guint16, guint16);
- gdcmDictEntry * GetDictEntryByName(string name);
+ gdcmDictEntry * GetDictEntryByName(std::string name);
// ElValue related utilities
gdcmElValue * ReadNextElement(void);
gdcmElValue * NewElValueByNumber(guint16 group, guint16 element);
- gdcmElValue * NewElValueByName(string name);
+ gdcmElValue * NewElValueByName(std::string name);
void FindLength(gdcmElValue *);
void FindVR(gdcmElValue *);
size_t GetPixelOffset(void);
int GetSwapCode(void) { return sw; }
- // TODO Swig int SetPubDict(string filename);
+ // TODO Swig int SetPubDict(std::string filename);
// When some proprietary shadow groups are disclosed, we can set up
// an additional specific dictionary to access extra information.
- // TODO Swig int SetShaDict(string filename);
+ // TODO Swig int SetShaDict(std::string filename);
- string GetPubElValByName(string TagName);
- string GetPubElValByNumber(guint16 group, guint16 element);
- string GetPubElValRepByName(string TagName);
- string GetPubElValRepByNumber(guint16 group, guint16 element);
+ std::string GetPubElValByName(std::string TagName);
+ std::string GetPubElValByNumber(guint16 group, guint16 element);
+ std::string GetPubElValRepByName(std::string TagName);
+ std::string GetPubElValRepByNumber(guint16 group, guint16 element);
TagElValueHT & GetPubElVal(void) { return PubElValSet.GetTagHt(); };
void PrintPubElVal(ostream & os = cout);
void PrintPubDict (ostream & os = cout);
- // TODO Swig string* GetShaTagNames();
- string GetShaElValByName(string TagName);
- string GetShaElValByNumber(guint16 group, guint16 element);
- string GetShaElValRepByName(string TagName);
- string GetShaElValRepByNumber(guint16 group, guint16 element);
-
- string GetElValByName(string TagName);
- string GetElValByNumber(guint16 group, guint16 element);
- string GetElValRepByName(string TagName);
- string GetElValRepByNumber(guint16 group, guint16 element);
-
- int SetPubElValByName(string content, string TagName);
- int SetPubElValByNumber(string content, guint16 group, guint16 element);
- int SetShaElValByName(string content, string ShadowTagName);
- int SetShaElValByNumber(string content, guint16 group, guint16 element);
+ // TODO Swig std::string* GetShaTagNames();
+ std::string GetShaElValByName(std::string TagName);
+ std::string GetShaElValByNumber(guint16 group, guint16 element);
+ std::string GetShaElValRepByName(std::string TagName);
+ std::string GetShaElValRepByNumber(guint16 group, guint16 element);
+
+ std::string GetElValByName(std::string TagName);
+ std::string GetElValByNumber(guint16 group, guint16 element);
+ std::string GetElValRepByName(std::string TagName);
+ std::string GetElValRepByNumber(guint16 group, guint16 element);
+
+ int SetPubElValByName(std::string content, std::string TagName);
+ int SetPubElValByNumber(std::string content, guint16 group, guint16 element);
+ int SetShaElValByName(std::string content, std::string ShadowTagName);
+ int SetShaElValByNumber(std::string content, guint16 group, guint16 element);
int SetPubElValLengthByNumber(guint32 lgr, guint16 group, guint16 element);
- int ReplaceOrCreateByNumber(string Value, guint16 Group, guint16 Elem);
+ int ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem);
int GetXSize(void);
int GetYSize(void);
int GetZSize(void);
int GetPixelSize(void);
- string GetPixelType(void);
+ std::string GetPixelType(void);
int Write(FILE *, FileType);
};
-// gdcmUtil.cxx
+// $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.10 2003/05/21 14:42:46 frog Exp $
#include <ctype.h> // For isspace
#include "gdcmUtil.h"
-// gdcmUtil.h
+// $Header: /cvs/public/gdcm/src/gdcmUtil.h,v 1.9 2003/05/21 14:42:46 frog Exp $
#ifndef GDCMUTIL_H
#define GDCMUTIL_H
#include <string>
#include "gdcmVR.h"
#include "gdcmDictSet.h"
-using namespace std;
class gdcmDebug {
private:
istream & eatwhite(istream & is);
-void Tokenize (const string& str,
- vector<string>& tokens,
- const string& delimiters = " ");
+void Tokenize (const std::string& str,
+ std::vector<std::string>& tokens,
+ const std::string& delimiters = " ");
extern gdcmDebug dbg;
#include <string>
#include "gdcmCommon.h"
-typedef string VRKey;
-typedef string VRAtr;
-typedef map<VRKey, VRAtr> VRHT; // Value Representation Hash Table
+typedef std::string VRKey;
+typedef std::string VRAtr;
+typedef std::map<VRKey, VRAtr> VRHT; // Value Representation Hash Table
/// Container for dicom Value Representation Hash Table
/// \note This is a singleton