Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2004/07/19 11:51:26 $
- Version: $Revision: 1.39 $
+ Date: $Date: 2004/07/28 21:23:20 $
+ Version: $Revision: 1.40 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief Construtor
* @param FileName from which to build the dictionary.
*/
-gdcmDict::gdcmDict(std::string & FileName) {
+gdcmDict::gdcmDict(std::string const & filename)
+{
uint16_t group;
uint16_t element;
- //char buff[1024];
TagName vr;
TagName fourth;
TagName name;
- std::ifstream from(FileName.c_str());
+ std::ifstream from( filename.c_str() );
dbg.Error(!from, "gdcmDict::gdcmDict: can't open dictionary",
- FileName.c_str());
+ filename.c_str());
- while (!from.eof()) {
+ while (!from.eof())
+ {
from >> std::hex;
from >> group; /// MEMORY LEAK in std::istream::operator>>
from >> element;
}
from.close();
- filename=FileName;
+ Filename = filename;
}
/**
* \brief Destructor
*/
-gdcmDict::~gdcmDict() {
+gdcmDict::~gdcmDict()
+{
for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
{
- gdcmDictEntry* EntryToDelete = tag->second;
- if ( EntryToDelete )
- delete EntryToDelete;
+ gdcmDictEntry* entryToDelete = tag->second;
+ if ( entryToDelete )
+ {
+ delete entryToDelete;
+ }
}
// Since AddNewEntry adds symetrical in both KeyHt and NameHT we can
// assume all the pointed gdcmDictEntries are already cleaned-up when
* Entries will be sorted by tag i.e. the couple (group, element).
* @param os The output stream to be written to.
*/
-void gdcmDict::Print(std::ostream &os) {
- os<<"Dict file name : "<<filename<<std::endl;
+void gdcmDict::Print(std::ostream &os)
+{
+ os << "Dict file name : " << Filename << std::endl;
PrintByKey(os);
}
* unpredictable result
* @param os The output stream to be written to.
*/
-void gdcmDict::PrintByName(std::ostream& os) {
+void gdcmDict::PrintByName(std::ostream& os)
+{
std::ostringstream s;
- for (TagNameHT::iterator tag = NameHt.begin(); tag != NameHt.end(); ++tag){
+ for (TagNameHT::iterator tag = NameHt.begin(); tag != NameHt.end(); ++tag)
+ {
s << "Entry : ";
s << tag->second->GetName() << ",";
s << tag->second->GetVR() << ", ";
*/
bool gdcmDict::AddNewEntry(gdcmDictEntry *NewEntry)
{
- gdcmTagKey key;
- key = NewEntry->GetKey();
+ gdcmTagKey key = NewEntry->GetKey();
if(KeyHt.count(key) == 1)
{
dbg.Verbose(1, "gdcmDict::AddNewEntry already present", key.c_str());
- return(false);
+ return false;
}
else
{
KeyHt[NewEntry->GetKey()] = NewEntry;
- NameHt[NewEntry->GetName()] = NewEntry; /// MEMORY LEAK in
- /// std::map<>::operator[]
- return(true);
+ NameHt[NewEntry->GetName()] = NewEntry;
+ return true;
}
}
* @param NewEntry new entry (overwrites any previous one with same tag)
* @return false if Dicom Element doesn't exist
*/
-bool gdcmDict::ReplaceEntry(gdcmDictEntry *NewEntry) {
- if ( RemoveEntry(NewEntry->gdcmDictEntry::GetKey()) ) {
+bool gdcmDict::ReplaceEntry(gdcmDictEntry *NewEntry)
+{
+ if ( RemoveEntry(NewEntry->gdcmDictEntry::GetKey()) )
+ {
KeyHt[NewEntry->GetKey()] = NewEntry;
NameHt[NewEntry->GetName()] = NewEntry;
- return (true);
+ return true;
}
- return (false);
+ return false;
}
/**
}
KeyHt.erase(key);
- return (true);
+ return true;
}
else
{
dbg.Verbose(1, "gdcmDict::RemoveEntry unfound entry", key.c_str());
- return (false);
+ return false;
}
}
* the name MAY CHANGE between two versions !
* @return the corresponding dictionnary entry when existing, NULL otherwise
*/
-gdcmDictEntry* gdcmDict::GetDictEntryByName(TagName name) {
- if ( ! NameHt.count(name))
- return NULL;
+gdcmDictEntry* gdcmDict::GetDictEntryByName(TagName name)
+{
+ if ( !NameHt.count(name))
+ {
+ return 0;
+ }
return NameHt.find(name)->second;
}
gdcmDictEntry* gdcmDict::GetDictEntryByNumber(uint16_t group, uint16_t element)
{
gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element);
- if ( ! KeyHt.count(key))
- return NULL;
+ if ( !KeyHt.count(key) )
+ {
+ return 0;
+ }
return KeyHt.find(key)->second;
}
* \sa gdcmDictSet::GetPubDictTagNamesByCategory
* @return A list of all entries of the public dicom dictionnary.
*/
-std::list<std::string>* gdcmDict::GetDictEntryNames(void)
+std::list<std::string>* gdcmDict::GetDictEntryNames()
{
- std::list<std::string> *Result = new std::list<std::string>;
+ std::list<std::string> *result = new std::list<std::string>;
for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
{
- Result->push_back( tag->second->GetName() );
+ result->push_back( tag->second->GetName() );
}
- return Result;
+ return result;
}
/**
*/
std::map<std::string, std::list<std::string> > *gdcmDict::GetDictEntryNamesByCategory(void)
{
- std::map<std::string, std::list<std::string> > *Result = new std::map<std::string, std::list<std::string> >;
+ std::map<std::string, std::list<std::string> > *result = new std::map<std::string, std::list<std::string> >;
for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
{
- (*Result)[tag->second->GetFourth()].push_back(tag->second->GetName());
+ (*result)[tag->second->GetFourth()].push_back(tag->second->GetName());
}
- return Result;
+
+ return result;
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDict.h,v $
Language: C++
- Date: $Date: 2004/07/02 13:55:27 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2004/07/28 21:23:20 $
+ Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* combined with all software versions...
* \see gdcmDictSet
*/
-class GDCM_EXPORT gdcmDict {
+class GDCM_EXPORT gdcmDict
+{
public:
- gdcmDict(std::string & FileName);
+ gdcmDict(std::string const & FileName);
~gdcmDict();
// Print
gdcmDictEntry *GetDictEntryByName(TagName name);
gdcmDictEntry *GetDictEntryByNumber(uint16_t group, uint16_t element);
- std::list<std::string> *GetDictEntryNames(void);
+ std::list<std::string> *GetDictEntryNames();
std::map<std::string, std::list<std::string> > *
- GetDictEntryNamesByCategory(void);
+ GetDictEntryNamesByCategory();
/// \brief Returns a ref to the Dicom Dictionary H table (map)
/// @return the Dicom Dictionary H table
- TagKeyHT & GetEntriesByKey(void) { return KeyHt; }
+ TagKeyHT & GetEntriesByKey() { return KeyHt; }
/// \brief Returns a ref to the Dicom Dictionary H table (map)
/// @return the Dicom Dictionary H table
- TagNameHT & GetEntriesByName(void) { return NameHt; }
+ TagNameHT & GetEntriesByName() { return NameHt; }
private:
/// ASCII file holding the Dictionnary
- std::string filename;
+ std::string Filename;
/// Access through gdcmTagKey (see alternate access with NameHt)
TagKeyHT KeyHt;
/// Access through TagName (see alternate access with KeyHt)